relational-model – Database Table with products (problem with product size)

Question:

Good morning first of all, let's imagine that my products table would have the fields ( product_code , name, gender, price, size), having the size field in this table would involve having the productcod1 repeated n times as many sizes as I had, such as I should get around this, I was in doubt if it would be correct to create a new table with (cod_produto, size) as a composite key… thanks.

Answer:

You have to create a new table:

tbl_sizes
cod_size (PK) – primary key
product_code (FK) – product_size foreign key

The relationship between them will be N:N.

Scroll to Top