Friday, March 30, 2012

Pros/Cons of Multivalue Database Columns

I'm just wondering what any pros and cons of using multivalue columns in a database are.

I'm designing a database which will have a column for FABRIC_TYPES_AVAILABLE for a certain FURNITURE_ITEM. Each FURNITURE_ITEM can have multiple FABRIC_TYPES_AVAILABLE of course. So I was just going to store a 2 or 3 digit number of the FABRIC_TYPES_AVAILABLE in that row. So I would have something like...34,24,453,32,23,45,67,65,43,21,21,45.

Anyway...thanks in advance for any information. Links I could read would be great too...b/c I did do a bit of searching, but didnt find much.::I'm just wondering what any pros and cons of using multivalue columns in a database are.

I suggest you read a book about database design. This is pretty well explained in about every into chapter about noirmalization that I have ever seen so far.

Look for (at amazon or in your local Bookstore):

"SQL for Dummies".|||do a look up table. they're faster to query than text based columns|||thona thx.

but i do know its not good for normalization; dont exactly have time to go read a book. hehe.

anyway...im going to go head and go for it, or i will use a lookup table.

thx fellaz|||http://www.sqlservercentral.com/columnists/dsumlin/lookupstrategy_printversion.asp

thats about the best info i could find about lookup tables. could you tell me a little bit more about them?

are they basically, just another table, with ID and Value columns for a certain datatype?

If thats true, i understand that...but then in the table where the values from the lookup table go...do you still store your ID as 23,32,43,54,3,25? I mean...if not...how else would a person know what rows to get from the reference table?

this is the way i was originally doing it; so im assuming there is a different/more correct way to do it, which i'm asking you about.|||you will normalize the database now, or you will normalize it in the future. If you don't exactly have the time to read a book, and you don't know how to normalize a database, I question your strength as a developer. I read constantly, and I always make room to read about something. Even if it's in the restroom. (yeah, I got tech mags in there. :))|||You will have three tables:
1. Furniture_Item
Furniture_ItemID
Furnite_Item (description, etc)
Blah blah (but no fabric type info on this table)

Your lookup table:
2.Fabric_Type
Fabric_TypeID
Fabric_Type (the description)

A link table because you have a many to many relationship between your Furniture_Items and Fabric_Type.
3.Item_FabricType
Item_FabricTypeID
Furniture_ItemID
Fabric_TypeID

The third table contains all the FabricTypes per Item,: so you have no FabricTypes on your Furniture_Item table.

I also suggest you do a bit of reading about database design; it's for your own good. :)

HTH

No comments:

Post a Comment