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 > Database Server Software > MySQL > newbie question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-25-10, 06:46
houlahan houlahan is offline
Registered User
 
Join Date: Mar 2010
Posts: 1
newbie question

Im trying to create a messaging service in java which uses a mysql database, i have 2 tables a person table and a message table which consist of:

Table Person:
PersonId
Name

Table Message:
MessageId
SourceId
DestinationId
Subject
Message

PersonId and MessageId are both primary keys SourceId and DestinationId will both be the id of a person so what kind of relationship would this be?

Thanks in advanced.
Reply With Quote
  #2 (permalink)  
Old 03-25-10, 08:49
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
foriegn key
Reply With Quote
  #3 (permalink)  
Old 03-25-10, 08:59
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
one-to-many
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #4 (permalink)  
Old 03-25-10, 18:05
thewebhosting thewebhosting is offline
Registered User
 
Join Date: Mar 2010
Posts: 16
Hi,

To make relationship to both database, I suggest you to add 'PersonId' in Table 'MessageId' as Foreign Key. After that you can handle both the table easily
Reply With Quote
  #5 (permalink)  
Old 03-25-10, 19:26
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
Quote:
Originally Posted by thewebhosting View Post
I suggest you to add 'PersonId' in Table 'MessageId' as Foreign Key.
this is, like, about the third thread recently where you just don't get what's going on

there already are ~two~ foreign keys to the person table in the message table
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
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