This is more of a question about structure more than the programming language itself. I have a very basic knowledge of SQL.
If you have a table with products and each product can have multiple or no colors.
Table: Color
Columns: Id, ColorName
1, Black
2, White
3, Purple
4, Red
and then we have
Table: Phone
Columns: Id, PhoneName, PhoneManf, ColorID
eg. Phone Table could have a HTC EVO that is available in black and white
would this mean that for every color of every phone there would be a record. i.e.
1, EVO, HTC, 1
2, EVO, HTC, 2
3, Curve, Blackberry,1
4, Curve, Blackberry,3
Or is there a way to have 1 record for each phone where the color key is like an array ?
Sorry if this is a very basic question, I am newish to this and want to make sure I am starting off right.
Duplicating essential data (like phone model and manufacturer) just because it is available under other colors is unecessary redundancy.
Better create a table like phone_color (IdPhone, IdColor)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With