Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
if we have two tables in database..

one is the table products

Table Name: Products with attributes ( productid(pk), productname, productImage, UnitPrice, Description)

another table is of stock

TableName: Stock with attributes( stockid(pk),productid(fk),productname,orderquantity,delivarystatus,delivarydate)

i want to know that is it leagle to put productname again in stock table. can anyone explain this.
Posted

1 solution

It's legal to put a column in there, but it is not a good idea.
If you were to normalize these tables, you would rely on the productid(fk) to retrieve the productname from the products table whenever you need to. Adding the productname in the stock table serves no purpose and will in fact cause you grief when a productname is updated as you would have to ensure that the productname in stock gets updated every time a change is made to products.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-Apr-12 0:19am    
Good explanation, a 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900