in reply to (OT) Database design: omitted partially filled fields.

Why are you trying to stuff all the different types of records into one table?

I suspect you have a situation similar to the following:

  1. I have pharmaceutical products. They have a set of attributes, plus a name and an ID.
  2. I have services. They have a different set of attributes, plus a name and an ID.
  3. I have lineitems. They need to FK to a given product, but one lineitem might be for a pharmaceutical and another for a service.

I created three tables. One is a general product table. It contains the name, ID, and any other common attributes. The others are detail tables. Every single row in the product table corresponds to a given detail table.

Now, you're looking at this and saying "What if I want every detail about every single product? That's a ton of outer joins!". And, you'd be right. But, my experience is that I already know if I want pharmaceuticals or services. I almost never want to pull both at the same time. If I do, it's usually just pulling the name (which is on the product table). If I want to drill down, I can do so.

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested

  • Comment on Re: (OT) Database design: omitted partially filled fields.