I am having a major issue with relating the following tables together. It is a many to many relationship between Patient and Nurse.
我将以下表格放在一起有一个重大问题。这是病人和护士之间的多对多关系。
Here is the relational table:
这是关系表:
Patient (PatientID (PK), Forename, surname, gender, date of birth, address, illness, prioirty)
seen_by (ID(PK) PatientID(FK to Patient.PatientID), NurseID(FK to Nurse.NurseID) )
Nurse (NurseID(PK), Forename, surname)
The issue I am getting is that, I want the PatientId to be assigned to a NurseID so I know what patient is seen by what nurse. Please note that the ID are all auto_increment values.
我得到的问题是,我希望将PatientId分配给NurseID,以便我知道哪位护士看到了哪名患者。请注意,ID都是auto_increment值。
Any suggesions, thanks in advance!
任何建议,提前谢谢!
1 个解决方案
#1
0
Why not create a join table that would be the relationship between the patient and the nurse?
为什么不创建一个连接表,这将是患者和护士之间的关系?
Table: Appointment (AppointmentID (PK), PatientID, NurseID)
Then you can assign the patient and the nurse to the appointment record and keep track of the relationship. This also gives you the benefit of keeping track of additional information regarding the appointment such as dates, prescriptions, etc.
然后,您可以将患者和护士分配到预约记录并跟踪关系。这也使您能够跟踪有关约会的其他信息,例如日期,处方等。
I'm not sure what development environment you're using but Rails has some nice patterns for accessing objects through these kinds of relationships.
我不确定你正在使用什么开发环境但Rails有一些很好的模式来通过这些关系访问对象。
#1
0
Why not create a join table that would be the relationship between the patient and the nurse?
为什么不创建一个连接表,这将是患者和护士之间的关系?
Table: Appointment (AppointmentID (PK), PatientID, NurseID)
Then you can assign the patient and the nurse to the appointment record and keep track of the relationship. This also gives you the benefit of keeping track of additional information regarding the appointment such as dates, prescriptions, etc.
然后,您可以将患者和护士分配到预约记录并跟踪关系。这也使您能够跟踪有关约会的其他信息,例如日期,处方等。
I'm not sure what development environment you're using but Rails has some nice patterns for accessing objects through these kinds of relationships.
我不确定你正在使用什么开发环境但Rails有一些很好的模式来通过这些关系访问对象。