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 |
sravanim
Yak Posting Veteran
58 Posts |
Posted - 2013-10-28 : 08:35:24
|
what is zero to many relation ship,Please explain with example? |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-10-28 : 08:38:13
|
It is used to describe the case where one side of the relationship may have zero or more entities that match the other side of the relationship.Think of a the classic example of customers and orders. Each customer may have placed zero or more orders. So if you were to store customer information in one table, and order information including a customer id in an order table, then there can be zero or more rows in the order table for any given customer id. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-10-28 : 09:02:22
|
And in DB you represent it by means of an intermediate tablelikeCustomer,Orders and CustomerOrdersCustomer will have details of customer like Number, name, contact details etcOrder will have details like Number, description, Quantity, Price, Date etcBased on who many orders a customer placed there will be 0 to multiple records in CustomerOrders which will just have fields CustomerID and OrderID to indicate relationship. The corresponding attributes are fetched from the master tables using foreign key relationships set------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2013-10-31 : 13:13:26
|
quote: Originally posted by visakh16 And in DB you represent it by means of an intermediate tablelikeCustomer,Orders and CustomerOrdersCustomer will have details of customer like Number, name, contact details etcOrder will have details like Number, description, Quantity, Price, Date etcBased on who many orders a customer placed there will be 0 to multiple records in CustomerOrders which will just have fields CustomerID and OrderID to indicate relationship. The corresponding attributes are fetched from the master tables using foreign key relationships set------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
That may help the OP, but what you are describing is a Many-to-Many. |
|
|
|
|
|
|
|