Home All Groups Group Topic Archive Search About

Relationship between two tables

Author
12 May 2005 11:45 PM
§Chrissi§
Hi,

We can create more than one
relationship between two tables.  Could you tell me a situation where we need two relationships between two tables?

Thanks

Author
12 May 2005 11:00 PM
Itzik Ben-Gan
Say you have a customers table and a table that represents a transaction between two customers holding two columns with a customer id. The referencing table would need to have two foreign keys pointing on the customerid

--
BG, SQL Server MVP
www.SolidQualityLearning.com


  "§Chrissi§" <anubisofthyde***@hotmail.com> wrote in message news:OM$bER0VFHA.1404@TK2MSFTNGP09.phx.gbl...
  Hi,

  We can create more than one
  relationship between two tables.  Could you tell me a situation where we need two relationships between two tables?

  Thanks
Author
13 May 2005 10:02 AM
Chandra
Hi
You can have that kind of relationship but it violates 2nd and 3rd Normal
Forms:

For Eg:
Table_Student
Name Subject-ID Room-Number

Table_Class Room
Subject-ID Subject-Desc Room-Number

was this your question?

--
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.developersdex.com/gurus/default.asp?p=4223
---------------------------------------



Show quote
"§Chrissi§" wrote:

>
Author
13 May 2005 4:46 PM
Thomas Coleman
> You can have that kind of relationship but it violates 2nd and 3rd Normal

Not necessarily. Suppose we have the following

Create Table Employees
(
    Id Int Primary Key
    , LastName VarChar(25)
    , FirstName VarChar(25)
)

Create Table ManagerStaff
(
    Id Int Primary Key
    , ManagerId Int References Employee(Id)
    , SubordinateId Int References Employee(Id)
    , StartDate DateTime
    , EndDate DateTime
)

I have two relationships to the Employees table yes this is still normalized to
third normal form.


Thomas

AddThis Social Bookmark Button