Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
TheOxblood
Starting Member
19 Posts |
Posted - 2011-09-18 : 01:55:19
|
| I have two tables (Company and Persons) in my reservation system,Company Table-CompanyID-CompanyName-Fname-Lname-Street-City-ContactNoPersons Table-PersonID-Fname-Lname-Street-City-ContactNoTheir only difference is the COMPANYNAME.Then each transaction can either be a COMPANY or PERSON..Reservation Table-ReservationNo-ClientID-...-...-...How can I insert a value for ClientID?Vonn Liquiran |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-18 : 03:17:09
|
| sorry not fully clearIs the question to get associated company/person who did reservation? or is it in populating Reservation table from Person/Company table?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2011-09-18 : 03:58:10
|
| If Persons are part of a Company then add a CompanyID column to the Persons TableIf Persons and Companies are not related/linked then either:a) have two columns in Reservation table, one for CompanyID and the other for PersonID and ensure that exact one is filled in on each rowb) Have a column that indicates whether the reservation is for an CompanyID or a PersonID and a single column that is the actual ID.Neither of these approaches is ideal though. |
 |
|
|
TheOxblood
Starting Member
19 Posts |
Posted - 2011-09-18 : 05:30:09
|
quote: Originally posted by visakh16 sorry not fully clearIs the question to get associated company/person who did reservation? or is it in populating Reservation table from Person/Company table?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/Yes, I want to know who did the reservation. I having a hard time in creating the relationship between the 3 tables I have.
Vonn Liquiran |
 |
|
|
TheOxblood
Starting Member
19 Posts |
Posted - 2011-09-18 : 05:39:57
|
quote: Originally posted by Kristen If Persons are part of a Company then add a CompanyID column to the Persons TableIf Persons and Companies are not related/linked then either:a) have two columns in Reservation table, one for CompanyID and the other for PersonID and ensure that exact one is filled in on each rowb) Have a column that indicates whether the reservation is for an CompanyID or a PersonID and a single column that is the actual ID.Neither of these approaches is ideal though.
I got your LETTER B idea! Thank You very much! I need to create One table for the CLIENTTYPE then relate it to the Reservation Table!THANKssss! :) This system is for my System and Analysis ProjectVonn Liquiran |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-18 : 05:51:46
|
quote: Originally posted by TheOxblood
quote: Originally posted by visakh16 sorry not fully clearIs the question to get associated company/person who did reservation? or is it in populating Reservation table from Person/Company table?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/Yes, I want to know who did the reservation. I having a hard time in creating the relationship between the 3 tables I have.
Vonn Liquiran
As Kristen suggested you can use either of twoFor first approach you might need a check constraint. But this is not very scalable as in future if you want to associate a third type of client you need to add a third column and alter check constraint.The second method is more scalable as any new client type means a new item added in relationship table.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
TheOxblood
Starting Member
19 Posts |
Posted - 2011-09-18 : 06:03:27
|
quote: Originally posted by visakh16
quote: Originally posted by TheOxblood
quote: Originally posted by visakh16 sorry not fully clearIs the question to get associated company/person who did reservation? or is it in populating Reservation table from Person/Company table?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/Yes, I want to know who did the reservation. I having a hard time in creating the relationship between the 3 tables I have.
Vonn Liquiran
As Kristen suggested you can use either of twoFor first approach you might need a check constraint. But this is not very scalable as in future if you want to associate a third type of client you need to add a third column and alter check constraint.The second method is more scalable as any new client type means a new item added in relationship table.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
Thanks! I got both of you! :) So that it would be easier for me in adding a new type of Client! :) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-18 : 08:13:50
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|