If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Many-To-Many Relationship

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-11-04, 11:22
RKSimpson RKSimpson is offline
Registered User
 
Join Date: Feb 2004
Location: Atlanta
Posts: 1
Many-To-Many Relationship

I have a logical/physical question that I'm hoping I can get some opinions around. I have three entities, a Customer Credit Card keyed by a Customer Id and a Credit Card Number, A Customer Agreement keyed by a Customer Id and an Agreement Id, and a Customer Credit Card Agreement to resolve a many-to-many relationship between the Customer Credit Card and the Customer Agreement with a key of Customer Id, Credit Card Number, and Agreement Id. There is also a Customer entity and an Agreement entity.

Is this the proper way to model a many-to-many relationship where both entities contain the same attribute, with the same value, as part of the key (Customer Id)?

With only one Customer Id in Customer Credit Card Agreement, how would RI (DB2)know which of the two tables to use from Customer Credit Card Agreement? Does the question make sense?
Reply With Quote
  #2 (permalink)  
Old 02-11-04, 11:30
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Re: Many-To-Many Relationship

You would need two foreign keys in Customer Credit Card Agreement:

1) (Customer Id, Credit Card Number) referencing Customer Credit Card

2) (Customer Id, Agreement ID) referencing Customer Agreement

Some people would prefer to have 2 Customer ID columns in the table, with a check constraint to ensure they are the same. Seems kind of redundant though!
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On