SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 relationship
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sravanim
Yak Posting Veteran

58 Posts

Posted - 10/28/2013 :  08:35:24  Show Profile  Reply with Quote
what is zero to many relation ship,Please explain with example?

James K
Flowing Fount of Yak Knowledge

3554 Posts

Posted - 10/28/2013 :  08:38:13  Show Profile  Reply with Quote
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.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 10/28/2013 :  09:02:22  Show Profile  Reply with Quote
And in DB you represent it by means of an intermediate table
like
Customer,Orders and CustomerOrders
Customer will have details of customer like Number, name, contact details etc
Order will have details like Number, description, Quantity, Price, Date etc

Based 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 MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

Lamprey
Flowing Fount of Yak Knowledge

4603 Posts

Posted - 10/31/2013 :  13:13:26  Show Profile  Reply with Quote
quote:
Originally posted by visakh16

And in DB you represent it by means of an intermediate table
like
Customer,Orders and CustomerOrders
Customer will have details of customer like Number, name, contact details etc
Order will have details like Number, description, Quantity, Price, Date etc

Based 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 MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs


That may help the OP, but what you are describing is a Many-to-Many.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000