Product Table Database (problem with product size)

Asked

Viewed 89 times

3

Good morning before everything, let’s imagine that my products table would have the fields (product code, name, gender, price , size), by having the size field in this table would involve that by having the codproduct1 repeated n times how many sizes I had, how should I circumvent this, it was in doubt whether it would be correct to create new table with (cod_product, size) as composite key... thank you.

  • or else, I have the 2FN poorly made and the size field is not dependent on the product code, and should I make them the 2 composite key ? Hmmm have no experience, I have no idea of the right way out of this problem.. Whelp

1 answer

0


You have to create a new table:

tbl_sizes
cod_size (PK) - primary key
product code (FK) - foreign key product size

The relationship between them shall be N:N.

  • But, being this way, having 2 products with the same size in this relation, would have to stay N:N not? because N sizes = 1 products, or 1 sizes = N products, example size47 = product1,product2. I’m right or I’m just going about it wrong ?

  • Yeah, you’re right, I didn’t remember that detail. The ratio will be N:N. Either way you have to always have the size table, as I mentioned in the previous answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.