![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a table of patient data. The patient has a patient ID which is the primary key. |
|
The table also has a foreign key which is the hospital that that patient is enrolled in. |
|
Two patients in the same hospital can not have the same Patient ID. But two patients can have the same patient ID in different hospitals. In MySQL workbench should both the patient ID and hospital be set as Unique (UQ) |
#3
| |||
| |||
|
|
I have a table of patient data. The patient has a patient ID which is the primary key. If two patients can have the same patient ID, then the patient ID by itself is NOT a primary key. The table also has a foreign key which is the hospital that that patient is enrolled in. Is that *THE* hospital, as in exactly one, or can there be more than one or less than one? |
|
Two patients in the same hospital can not have the same Patient ID. But two patients can have the same patient ID in different hospitals. In MySQL workbench should both the patient ID and hospital be set as Unique (UQ) No. *The combination of the two should be set as unique, as in: alter table patients add primary key (patientID, hospitalID); How is this handled properly? |
#4
| |||
| |||
|
|
I guess the same human could be enrolled in more than one hospital, but I'm not interested in ensuring that they have the same or differnt patient IDs in diffent hospitals. but a patient must have a hospital. |
#5
| |||
| |||
|
|
I have a table of patient data. The patient has a patient ID which is the primary key. The table also has a foreign key which is the hospital that that patient is enrolled in. Two patients in the same hospital can not have the same Patient ID. But two patients can have the same patient ID in different hospitals. In MySQL workbench should both the patient ID and hospital be set as Unique (UQ) How is this handled properly? |
#6
| |||
| |||
|
|
SpreadTooThin says... I guess the same human could be enrolled in more than one hospital, but I'm not interested in ensuring that they have the same or differnt patient IDs in diffent hospitals. but a patient must have a hospital. Call me a cynic, but ... If this was a real-world design, I'd run a book on how long it would be before someone decides that they want the facility to transfer a patient (complete with existing data attributes) from one hospital to another. |
![]() |
| Thread Tools | |
| Display Modes | |
| |