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 > Primary Key Issue need help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-20-11, 04:04
ahashmi ahashmi is offline
Registered User
 
Join Date: Aug 2011
Posts: 5
Primary Key Issue need help

Table Emp

empno (pk)
fname
lname
hiredate

Table dept

deptid (pk)
deptname

Table Emp_dept

empno (fk)
deptid (fk)
fromdate
todate


Above is the scenario which is confusing me and i need help. As you can see the Emp_dept table has both the empno and deptid as foreign key.

I am confused that wheather a primary key to be established for this table or is it ok as is?

Would someone help plz.
Reply With Quote
  #2 (permalink)  
Old 08-20-11, 05:47
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
yes, the PK for that table would be the first three columns

the PK would not prevent logical inconsistencies, but it's better than no PK at all
__________________
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