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.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 One-Many Relationship in database design

Author  Topic 

csri
Starting Member

45 Posts

Posted - 2009-03-26 : 13:49:50
Dear All

I 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 key
of 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 are
ProductId primary key
Text
saleprice.

Is it correct.when will the primary key column of one table becomes
primary 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 Regards
Sri

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.
Go to Top of Page
   

- Advertisement -