|
c0micrage
Starting Member
USA
1 Posts |
Posted - 12/22/2010 : 15:12:42
|
Hi,
I am using sql server 2008 and created link tables for 1 to many and many to many. Example, patients can have many different stays in the hospital. So, I have a patients, hospitalstays, patientshospitalstays tables. Patients will have the PatientId primary key. HospitalStays wil have HosStayId as its primary key. The PatientsHospitalStays table will only PatientId and HosStayId columns. When I added the foreign relationship, it tells me to us unique contraints on the PatientId and HosStayId columns, but that will enforce uniqueness on those columns. The PatientId columns will contain multiple occurrance of the same PatientId value.
How do I resolve this? |
|
|
sunitabeck
Flowing Fount of Yak Knowledge
5152 Posts |
Posted - 12/22/2010 : 15:40:27
|
You may not need a link table at all. Assuming this is a one to many (and not many to many relationship), you could add foreign key column in the hospitalstays table which references the patientId column from the patients table.
If a "hospital stay" is defined in such a way that many patients can share a single hospital stay, then you would need link tables etc. But, I can't visualize how that would be. (I cringe at the thought of more than one patient sharing even a single hospital room! :-)) |
 |
|