Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
dohamsg
Starting Member
22 Posts |
Posted - 2012-06-02 : 03:58:04
|
Hi,'ProductA' can be of Quality1 or Quality2'ProductA, Quality1' can be of Color1 or Color2'ProductA, Quality2' can be of Color1 or Color2'ProductA, Quality1, Color1' has Price1'ProductA, Quality1, Color2' has Price2'ProductA, Quality2, Color1' has Price3'ProductA, Quality2, Color2' has Price4'ProductB' can be in Color1 or Color2, no Quality involved'ProductC' can be in Quality1 or Quality2, no Color involvedQuestion: How to model this in table schema?If a user selects for example : 'ProductA, Quality1, Color1', how to query to get the right price?The user can also query for : 'ProductB, Color1' to get its price.sumurtinggi3plg, do you have the SQL script of the book : len silverston data model resource book?Thanks. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-06-03 : 01:22:12
|
i would model it as followsa. Product table (ProductID,ProductName)with values1 ProductA2 ProductB3 ProductC....c.ProductAttribute table (AttributeValueID,ProductID (fk to product table),Quality,Color,Price)with values as1 1 Quality1 Color1 Price12 1 Quality1 Color2 Price23 1 Quality2 Color1 Price34 1 Quality2 Color2 Price45 2 NULL Color1 Price5... with values1 1 Price1------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
dohamsg
Starting Member
22 Posts |
Posted - 2012-06-03 : 05:28:39
|
Thanks indeed. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-06-03 : 15:20:06
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|
|
|