I currently have 3 simple tables: products (prodid, name and prodmatid), materials (matid, name) and prodmat (prodmatid, prodid and matid).
I am not sure if the above is a good design. Products can consist of different materials, the prodmat table only allows for one material at a time for a product – so if productA has 5 materials then it will require 5 rows in prodmat. Is this a silly way of doing it, how should I design this?
In your design, it looks like you have an extra column that is not needed in the
productstable. You can remove theprodmatidcolumn since you can find that relationship in theprodmattable.So your structure would be:
products (prodid, name),materials (matid, name), andprodmat (prodmatid, prodid, matid)This allows for a product ‘My Product’, materials ‘Material 1’ and ‘Material 2’, and the result would be: