Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
csri
Starting Member
45 Posts |
Posted - 2009-03-26 : 13:49:50
|
Dear AllI have a question on one-Many Relationship in database design.I have two tables products and Featuredproducts.Products table columns are(productId is the primary key and other columns are catId,Name,Price)The FeaturedProducts table has two columns (text and saleprice)I think there is a one-Many Relationship between products and Featuredproducts.If it is , can I make the primary key of products table primary key in Featuredproducts.or Do I need to make primary keyof products table a foreign key in featuredproducts and add a new column and make it a primary key.which one is correct when there is a one-Many Relationship between products and Featuredproducts.Featuredproducts table columns areProductId primary keyTextsaleprice.Is it correct.when will the primary key column of one table becomesprimary key in another table in a 1-Many Relationship.Please somebody clarify my doubt.I am designing database for the first time.If any thing wrong please correct me.Really appreciate your answer.Thanks and RegardsSri |
|
dportas
Yak Posting Veteran
53 Posts |
Posted - 2009-03-28 : 12:51:45
|
This looks more like an optional 1-1 relationship rather than 1-many. I would expect your FeaturedProducts to look something like this:CREATE TABLE FeaturedProducts (ProductId INT NOT NULL REFERENCES Products (ProductId), Txt VARCHAR(MAX) NOT NULL, SalePrice NUMERIC(10,2) NOT NULL);"Text" is a poor choice for a column name because it's a reserved word. |
|
|
|
|
|