Middle
Hospital: need reports on patient visits by doctors. How many tables are needed and what is the relationship between them?
sobes.tech AI
Answer from AI
To generate reports on patient visits by doctors in the hospital, at least three tables are needed:
- Patients — stores data about patients (ID, name, date of birth, etc.).
- Doctors — stores data about doctors (ID, name, specialization, etc.).
- Visits — links patients and doctors, recording the visit details (ID, patient ID, doctor ID, date and time of visit, additional notes).
Relationships:
- The Visits table contains foreign keys to Patients and Doctors.
- This is a many-to-many relationship with additional information (date of visit), implemented through the Visits table.
This approach allows flexible reporting on visits, for example, how many times a specific doctor visited a specific patient during a period.