| Author |
Topic |
|
skiabox
Posting Yak Master
169 Posts |
Posted - 2008-10-30 : 07:11:16
|
| I have a table with buildings(buildingID as primary key, streetName column streetNumber column) etc.I want to create a new table with some jobs that must be made uppon the building.I have created a new table with all the jobs as columns and with buildingID as a foreign key.What will be the primary key of this new table?I also believe that the relationship between the two tables must be one-to-one. |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-10-30 : 07:15:33
|
| No, the relationship would be one-to-many as you can have many jobs on one building surely?You can create a jobid as your primary key. |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2008-10-30 : 07:16:07
|
| Doesn't sound like it should be 1 to 1Surely there can be many jobs for the same building?Regards,-------------Charlie |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2008-10-30 : 07:16:34
|
| I'm too slow.-------------Charlie |
 |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-10-30 : 07:20:07
|
Nevermind.. |
 |
|
|
skiabox
Posting Yak Master
169 Posts |
Posted - 2008-10-30 : 07:20:16
|
| The buildings are unique of course but the jobs can vary depending on the current building. |
 |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-10-30 : 07:28:21
|
| Yes, but that still makes it a one to many and not a one to one. |
 |
|
|
skiabox
Posting Yak Master
169 Posts |
Posted - 2008-10-30 : 08:15:45
|
| So you suggest a table with two columns for example?(jobID as the primary key column and jobName with the name of the job) |
 |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-10-30 : 08:27:58
|
| No, I suggest it with three columns at least, jobid, buildingid, jobname etc.. |
 |
|
|
EugeneLim11
Posting Yak Master
167 Posts |
Posted - 2008-10-30 : 21:31:06
|
| skiabox, in reality, few tables are 1 to 1 relationship - because if it is 1 to 1 relationship, you are better off inserting it as a column in the same table than a separate table. It is usually 1 to many. Regards,Eugenecheck out my blog at http://www.aquariumlore.blogspot.com |
 |
|
|
|