[NCLUG] normalizing data

Rich Young rich at RepublicOfTech.com
Tue Jan 8 00:07:48 MST 2002


Wow, a topic I can contribute to!  FWIW, I've always thought that
normalizing database structure is both easier and cheaper than not
normalizing, and having to slog through a structure change and subsequent
(sometimes very difficult, depending on complexity) translation of the data
to the new structure.  Especially true if you are using a product that has
poor ALTER support (Postgres, for example).  The times I've knowingly
ignored respected database design practices have almost always ended in woe.

Then again, you're building something that is not terribly important -- no
offense to your dogs or flowers -- and you can afford some trial and error.
Of course, for this same reason, I should think that the performance hit of
a join would not matter.

So, specifics: if you're planning to have multiple pics per comment, and
never more than one comment per pic, then put a "comment_id" field in the
images table.  OTOH, if you want multiple comments per pic, and never more
than one pic per comment, put an "image_id" field in your comments table.
On the third hand, if it's a many-many relationship, use a junction table,
as you discussed.  Fourth possibility, strict one-to-one relationship, I
always roll everything like that into one table.  You probably already knew
all that if you know what "normalization" means, but just in case....

--Rich Young
rich at republicoftech.com






More information about the NCLUG mailing list