dbTalk Databases Forums  

Using a seperate table to 'join' make a table relation

comp.databases.theory comp.databases.theory


Discuss Using a seperate table to 'join' make a table relation in the comp.databases.theory forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
bissatch@yahoo.co.uk
 
Posts: n/a

Default Using a seperate table to 'join' make a table relation - 01-10-2008 , 04:10 AM






Hi,

In the past I have always made the relationship between two tables
using foriegn keys. So, to link employee to employer I would have a
column in employee table called employer_id so that one employee could
have one employer and one employer may have many employees. Pretty
textbook stuff really but what if one employee had two jobs
(employers)?? For this I may create the following tables:

employee
employer_employer_join
employer

The table employer_employer_join would have two columns that would
make the join, employer_id and employee_id, and I would have no need
for employer_id in the employee table. This way I could create many
relations between the two and not fixed to single relationships for
either.

I adopted this technique in my last project and it worked for any join
I had to make but it was more work and more tables to manage. Is this
a recommeded method of implementing joins? Would I only use this
method when there are multiple rows on either side (many employees for
one employer but also many employers for one employee) or if some
tables use it, it makes more sense to make all joins in a project this
way to keep the design theory consistant? Should I carefully
deptermine the tables that dont require this and just implement
foriegn keys in those tables (eg. A car only even has at any one time
one colour)? And finally, does this technique have a name that I can
learn more about??

Hopefully the above is clear, Im newish to building large database
designs but I understand the importance of getting this part correct
from the start. Any help would be much appreciated. Thanks

Burnsy

Reply With Quote
  #2  
Old   
Bob Badour
 
Posts: n/a

Default Re: Using a seperate table to 'join' make a table relation - 01-10-2008 , 09:15 AM






bissatch (AT) yahoo (DOT) co.uk wrote:

Quote:
Hi,

In the past I have always made the relationship between two tables
using foriegn keys. So, to link employee to employer I would have a
column in employee table called employer_id so that one employee could
have one employer and one employer may have many employees. Pretty
textbook stuff really but what if one employee had two jobs
(employers)?? For this I may create the following tables:

employee
employer_employer_join
employer

The table employer_employer_join would have two columns that would
make the join, employer_id and employee_id, and I would have no need
for employer_id in the employee table. This way I could create many
relations between the two and not fixed to single relationships for
either.

I adopted this technique in my last project and it worked for any join
I had to make but it was more work and more tables to manage. Is this
a recommeded method of implementing joins? Would I only use this
method when there are multiple rows on either side (many employees for
one employer but also many employers for one employee)
Yes. That is exactly how one represents a many:many relationship.


or if some
Quote:
tables use it, it makes more sense to make all joins in a project this
way to keep the design theory consistant?
No. The data model should accurately reflect the business rules. If the
rules state 1:many, then the data model should reflect 1:many.


Should I carefully
Quote:
deptermine the tables that dont require this and just implement
foriegn keys in those tables (eg. A car only even has at any one time
one colour)?
I recommend due care for all tasks.


And finally, does this technique have a name that I can
Quote:
learn more about??
Join table. Association table. Probably others too.


Quote:
Hopefully the above is clear, Im newish to building large database
designs but I understand the importance of getting this part correct
from the start. Any help would be much appreciated. Thanks

Burnsy
Have you read anything on normalization? If not, I highly recommend
doing so.


Reply With Quote
  #3  
Old   
Bob Badour
 
Posts: n/a

Default Re: Using a seperate table to 'join' make a table relation - 01-10-2008 , 09:15 AM



bissatch (AT) yahoo (DOT) co.uk wrote:

Quote:
Hi,

In the past I have always made the relationship between two tables
using foriegn keys. So, to link employee to employer I would have a
column in employee table called employer_id so that one employee could
have one employer and one employer may have many employees. Pretty
textbook stuff really but what if one employee had two jobs
(employers)?? For this I may create the following tables:

employee
employer_employer_join
employer

The table employer_employer_join would have two columns that would
make the join, employer_id and employee_id, and I would have no need
for employer_id in the employee table. This way I could create many
relations between the two and not fixed to single relationships for
either.

I adopted this technique in my last project and it worked for any join
I had to make but it was more work and more tables to manage. Is this
a recommeded method of implementing joins? Would I only use this
method when there are multiple rows on either side (many employees for
one employer but also many employers for one employee)
Yes. That is exactly how one represents a many:many relationship.


or if some
Quote:
tables use it, it makes more sense to make all joins in a project this
way to keep the design theory consistant?
No. The data model should accurately reflect the business rules. If the
rules state 1:many, then the data model should reflect 1:many.


Should I carefully
Quote:
deptermine the tables that dont require this and just implement
foriegn keys in those tables (eg. A car only even has at any one time
one colour)?
I recommend due care for all tasks.


And finally, does this technique have a name that I can
Quote:
learn more about??
Join table. Association table. Probably others too.


Quote:
Hopefully the above is clear, Im newish to building large database
designs but I understand the importance of getting this part correct
from the start. Any help would be much appreciated. Thanks

Burnsy
Have you read anything on normalization? If not, I highly recommend
doing so.


Reply With Quote
  #4  
Old   
Bob Badour
 
Posts: n/a

Default Re: Using a seperate table to 'join' make a table relation - 01-10-2008 , 09:15 AM



bissatch (AT) yahoo (DOT) co.uk wrote:

Quote:
Hi,

In the past I have always made the relationship between two tables
using foriegn keys. So, to link employee to employer I would have a
column in employee table called employer_id so that one employee could
have one employer and one employer may have many employees. Pretty
textbook stuff really but what if one employee had two jobs
(employers)?? For this I may create the following tables:

employee
employer_employer_join
employer

The table employer_employer_join would have two columns that would
make the join, employer_id and employee_id, and I would have no need
for employer_id in the employee table. This way I could create many
relations between the two and not fixed to single relationships for
either.

I adopted this technique in my last project and it worked for any join
I had to make but it was more work and more tables to manage. Is this
a recommeded method of implementing joins? Would I only use this
method when there are multiple rows on either side (many employees for
one employer but also many employers for one employee)
Yes. That is exactly how one represents a many:many relationship.


or if some
Quote:
tables use it, it makes more sense to make all joins in a project this
way to keep the design theory consistant?
No. The data model should accurately reflect the business rules. If the
rules state 1:many, then the data model should reflect 1:many.


Should I carefully
Quote:
deptermine the tables that dont require this and just implement
foriegn keys in those tables (eg. A car only even has at any one time
one colour)?
I recommend due care for all tasks.


And finally, does this technique have a name that I can
Quote:
learn more about??
Join table. Association table. Probably others too.


Quote:
Hopefully the above is clear, Im newish to building large database
designs but I understand the importance of getting this part correct
from the start. Any help would be much appreciated. Thanks

Burnsy
Have you read anything on normalization? If not, I highly recommend
doing so.


Reply With Quote
  #5  
Old   
Bob Badour
 
Posts: n/a

Default Re: Using a seperate table to 'join' make a table relation - 01-10-2008 , 09:15 AM



bissatch (AT) yahoo (DOT) co.uk wrote:

Quote:
Hi,

In the past I have always made the relationship between two tables
using foriegn keys. So, to link employee to employer I would have a
column in employee table called employer_id so that one employee could
have one employer and one employer may have many employees. Pretty
textbook stuff really but what if one employee had two jobs
(employers)?? For this I may create the following tables:

employee
employer_employer_join
employer

The table employer_employer_join would have two columns that would
make the join, employer_id and employee_id, and I would have no need
for employer_id in the employee table. This way I could create many
relations between the two and not fixed to single relationships for
either.

I adopted this technique in my last project and it worked for any join
I had to make but it was more work and more tables to manage. Is this
a recommeded method of implementing joins? Would I only use this
method when there are multiple rows on either side (many employees for
one employer but also many employers for one employee)
Yes. That is exactly how one represents a many:many relationship.


or if some
Quote:
tables use it, it makes more sense to make all joins in a project this
way to keep the design theory consistant?
No. The data model should accurately reflect the business rules. If the
rules state 1:many, then the data model should reflect 1:many.


Should I carefully
Quote:
deptermine the tables that dont require this and just implement
foriegn keys in those tables (eg. A car only even has at any one time
one colour)?
I recommend due care for all tasks.


And finally, does this technique have a name that I can
Quote:
learn more about??
Join table. Association table. Probably others too.


Quote:
Hopefully the above is clear, Im newish to building large database
designs but I understand the importance of getting this part correct
from the start. Any help would be much appreciated. Thanks

Burnsy
Have you read anything on normalization? If not, I highly recommend
doing so.


Reply With Quote
  #6  
Old   
Bob Badour
 
Posts: n/a

Default Re: Using a seperate table to 'join' make a table relation - 01-10-2008 , 09:15 AM



bissatch (AT) yahoo (DOT) co.uk wrote:

Quote:
Hi,

In the past I have always made the relationship between two tables
using foriegn keys. So, to link employee to employer I would have a
column in employee table called employer_id so that one employee could
have one employer and one employer may have many employees. Pretty
textbook stuff really but what if one employee had two jobs
(employers)?? For this I may create the following tables:

employee
employer_employer_join
employer

The table employer_employer_join would have two columns that would
make the join, employer_id and employee_id, and I would have no need
for employer_id in the employee table. This way I could create many
relations between the two and not fixed to single relationships for
either.

I adopted this technique in my last project and it worked for any join
I had to make but it was more work and more tables to manage. Is this
a recommeded method of implementing joins? Would I only use this
method when there are multiple rows on either side (many employees for
one employer but also many employers for one employee)
Yes. That is exactly how one represents a many:many relationship.


or if some
Quote:
tables use it, it makes more sense to make all joins in a project this
way to keep the design theory consistant?
No. The data model should accurately reflect the business rules. If the
rules state 1:many, then the data model should reflect 1:many.


Should I carefully
Quote:
deptermine the tables that dont require this and just implement
foriegn keys in those tables (eg. A car only even has at any one time
one colour)?
I recommend due care for all tasks.


And finally, does this technique have a name that I can
Quote:
learn more about??
Join table. Association table. Probably others too.


Quote:
Hopefully the above is clear, Im newish to building large database
designs but I understand the importance of getting this part correct
from the start. Any help would be much appreciated. Thanks

Burnsy
Have you read anything on normalization? If not, I highly recommend
doing so.


Reply With Quote
  #7  
Old   
Bob Badour
 
Posts: n/a

Default Re: Using a seperate table to 'join' make a table relation - 01-10-2008 , 09:15 AM



bissatch (AT) yahoo (DOT) co.uk wrote:

Quote:
Hi,

In the past I have always made the relationship between two tables
using foriegn keys. So, to link employee to employer I would have a
column in employee table called employer_id so that one employee could
have one employer and one employer may have many employees. Pretty
textbook stuff really but what if one employee had two jobs
(employers)?? For this I may create the following tables:

employee
employer_employer_join
employer

The table employer_employer_join would have two columns that would
make the join, employer_id and employee_id, and I would have no need
for employer_id in the employee table. This way I could create many
relations between the two and not fixed to single relationships for
either.

I adopted this technique in my last project and it worked for any join
I had to make but it was more work and more tables to manage. Is this
a recommeded method of implementing joins? Would I only use this
method when there are multiple rows on either side (many employees for
one employer but also many employers for one employee)
Yes. That is exactly how one represents a many:many relationship.


or if some
Quote:
tables use it, it makes more sense to make all joins in a project this
way to keep the design theory consistant?
No. The data model should accurately reflect the business rules. If the
rules state 1:many, then the data model should reflect 1:many.


Should I carefully
Quote:
deptermine the tables that dont require this and just implement
foriegn keys in those tables (eg. A car only even has at any one time
one colour)?
I recommend due care for all tasks.


And finally, does this technique have a name that I can
Quote:
learn more about??
Join table. Association table. Probably others too.


Quote:
Hopefully the above is clear, Im newish to building large database
designs but I understand the importance of getting this part correct
from the start. Any help would be much appreciated. Thanks

Burnsy
Have you read anything on normalization? If not, I highly recommend
doing so.


Reply With Quote
  #8  
Old   
Bob Badour
 
Posts: n/a

Default Re: Using a seperate table to 'join' make a table relation - 01-10-2008 , 09:15 AM



bissatch (AT) yahoo (DOT) co.uk wrote:

Quote:
Hi,

In the past I have always made the relationship between two tables
using foriegn keys. So, to link employee to employer I would have a
column in employee table called employer_id so that one employee could
have one employer and one employer may have many employees. Pretty
textbook stuff really but what if one employee had two jobs
(employers)?? For this I may create the following tables:

employee
employer_employer_join
employer

The table employer_employer_join would have two columns that would
make the join, employer_id and employee_id, and I would have no need
for employer_id in the employee table. This way I could create many
relations between the two and not fixed to single relationships for
either.

I adopted this technique in my last project and it worked for any join
I had to make but it was more work and more tables to manage. Is this
a recommeded method of implementing joins? Would I only use this
method when there are multiple rows on either side (many employees for
one employer but also many employers for one employee)
Yes. That is exactly how one represents a many:many relationship.


or if some
Quote:
tables use it, it makes more sense to make all joins in a project this
way to keep the design theory consistant?
No. The data model should accurately reflect the business rules. If the
rules state 1:many, then the data model should reflect 1:many.


Should I carefully
Quote:
deptermine the tables that dont require this and just implement
foriegn keys in those tables (eg. A car only even has at any one time
one colour)?
I recommend due care for all tasks.


And finally, does this technique have a name that I can
Quote:
learn more about??
Join table. Association table. Probably others too.


Quote:
Hopefully the above is clear, Im newish to building large database
designs but I understand the importance of getting this part correct
from the start. Any help would be much appreciated. Thanks

Burnsy
Have you read anything on normalization? If not, I highly recommend
doing so.


Reply With Quote
  #9  
Old   
Bob Badour
 
Posts: n/a

Default Re: Using a seperate table to 'join' make a table relation - 01-10-2008 , 09:15 AM



bissatch (AT) yahoo (DOT) co.uk wrote:

Quote:
Hi,

In the past I have always made the relationship between two tables
using foriegn keys. So, to link employee to employer I would have a
column in employee table called employer_id so that one employee could
have one employer and one employer may have many employees. Pretty
textbook stuff really but what if one employee had two jobs
(employers)?? For this I may create the following tables:

employee
employer_employer_join
employer

The table employer_employer_join would have two columns that would
make the join, employer_id and employee_id, and I would have no need
for employer_id in the employee table. This way I could create many
relations between the two and not fixed to single relationships for
either.

I adopted this technique in my last project and it worked for any join
I had to make but it was more work and more tables to manage. Is this
a recommeded method of implementing joins? Would I only use this
method when there are multiple rows on either side (many employees for
one employer but also many employers for one employee)
Yes. That is exactly how one represents a many:many relationship.


or if some
Quote:
tables use it, it makes more sense to make all joins in a project this
way to keep the design theory consistant?
No. The data model should accurately reflect the business rules. If the
rules state 1:many, then the data model should reflect 1:many.


Should I carefully
Quote:
deptermine the tables that dont require this and just implement
foriegn keys in those tables (eg. A car only even has at any one time
one colour)?
I recommend due care for all tasks.


And finally, does this technique have a name that I can
Quote:
learn more about??
Join table. Association table. Probably others too.


Quote:
Hopefully the above is clear, Im newish to building large database
designs but I understand the importance of getting this part correct
from the start. Any help would be much appreciated. Thanks

Burnsy
Have you read anything on normalization? If not, I highly recommend
doing so.


Reply With Quote
  #10  
Old   
bissatch@yahoo.co.uk
 
Posts: n/a

Default Re: Using a seperate table to 'join' make a table relation - 01-10-2008 , 04:31 PM



Thanks for all that, I did search for join table but got loads of SQL
JOIN command stuff but ill keep looking. I briefly touched on
normalization at uni but im going to do learn more on database design.

Anyway, good to see im somewhat on the correct track

Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.