Welcome to WebmasterWorld Guest from 220.127.116.11
Forum Moderators: open
Trying to make my database, I am going through the process of normalization. Since I will have many rings with many sizes, I need to make a separate table for 'sizes' and then have a 'Size ID' in the main product table, correct?
Except that some of the products will not have any size associated with it (like the pendant). I'm not supposed to have 'NULL' values, so how should I handle it?
Thanks in advance for any help/advice.
Alternatively, you could have SizeID=1 to mean no size associated with it, then start the "real" SizeIDs from 2. (I only suggest this since some programming languages don't like 0 as an index in arrays.)
Oh, and Welcome to WebmasterWorld [webmasterworld.com]!
Then to join the ring and the sizes you use the tblRingHasSize... if a ring has no size then it won't join but won't give you null... also this allows your rings to have many sizes.
coalesce (s.size_desc, 'No Size') as size_desc,
left join tblRingHasSize rhs on r.ring_id = rhs.ring_id
left join tblSize s on s.size_id = rhs.size_id
Keep in mind if you do it this way and a ring has multiple sizes it will return the ring as many times as it has sizes. (ie, a ring has 3 sizes this SQL will return that ring 3 times, each time with a different size)