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 > which way to link two tables!!!!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-17-09, 08:58
lloowen lloowen is offline
Registered User
 
Join Date: Sep 2009
Posts: 4
which way to link two tables!!!!

Hello,

If you have two tables and you want to link them together using a foreign key. One table is only going to have a limited number of rows, for example department but the other table called employees could have 1000s of rows.

If they where going to be linked, which would be the best way to link them and why? Or does it not make any difference?!!

6 rows: department ( dep_id, dep_name, dep_address, ..... , emp_id*)

1000s rows: employee ( emp_id, emp_name, emp_address, ..... )




6 rows: department ( dep_id, dep_name, dep_address, ..... )

1000s rows: employee ( emp_id, emp_name, emp_address, ..... , dep_id*)

Thanks,

newbie
Reply With Quote
  #2 (permalink)  
Old 09-17-09, 09:09
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
Do your departments contain one and only one employee?
Do your employees belong to one and only one department?

The answers to these questions should guide you.
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #3 (permalink)  
Old 09-17-09, 09:51
lloowen lloowen is offline
Registered User
 
Join Date: Sep 2009
Posts: 4
OK there are six different departments and there are 1000 employees
Reply With Quote
  #4 (permalink)  
Old 09-17-09, 09:53
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
yes - but what are the answers to the questions?
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #5 (permalink)  
Old 09-17-09, 11:02
lloowen lloowen is offline
Registered User
 
Join Date: Sep 2009
Posts: 4
Quote:
Do your departments contain one and only one employee?

Perhaps one department has one employee, and the rest of the departments could be divided between the other 999


Quote:
Do your employees belong to one and only one department?
could be perhaps a small number of emplyees are soley employed by one department. The rest of the employees are divided by three or more departments.

Quote:
The answers to these questions should guide you.
Still just as unclear..
Reply With Quote
  #6 (permalink)  
Old 09-17-09, 11:08
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
Ok - I'll put it another way. Suppose instead you have 1 department and 10 employees (to keep the numbers small).

Regarding your first suggested design:
For your one department you have a row. You enter an employee id for that row. Your department row now has an employee id entered in the emp_id column.
So - you have assigned 1 employee to your department and 9 employees not assigned to any department. How do you assign these 9 to departments?
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #7 (permalink)  
Old 09-17-09, 11:14
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
EDIT - Pat the Erudite phrased the questions better
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.

Last edited by pootle flump; 09-17-09 at 11:22.
Reply With Quote
  #8 (permalink)  
Old 09-17-09, 11:16
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
To re-prhase Pootle's questions:

1) How many employees can be in a department?

3) How many departments can an employee be in?

-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
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