I have a query on database table structure.
My Patient Details table in a SQL Server 2008 database looks like this:
–PatientId(PK)– –PatientType– –DoctorId(FK)– –DateOfVisit– –PrescriptionId(FK)–
Each patient may visit the hospital multiple times. I need to link all the visits of a patient and show them in a linked way that the admin can navigate with the previous and next visits..
So I think I can do it only by having a record for each visit with a VisitId.
I need to be Careful that the database should not be loaded with unnecessary fields. Also it should not affect the fetching time badly.
I think these are the available ways. Suggest me if any available.
–PatientId(PK)– –PatientType– –DoctorId(FK)– –DateOfVisit– –PrescriptionId(FK)– –VisitId– –PrevVisitId– NextVisitId–
or
having a separate table for Visit as
–VisitId(PK)– -PrevVisitId(FK)– –NextVisitId(FK)–
Apologies if my post is duplicate.. Correct me, redirect me wherever/whenever needed.
You need a row for each visit. You need a key for each row. The key doesn’t need to be a single id number. I think the very least you need to record for each visit is
(Exact syntax varies depending on your dbms platform.) You can find the previous and next visits by fairly simple queries–“office_visit_start” will give you the order of a patient’s visits.
Example queries . . .