Burak kaya
Burak kaya

Reputation: 11

How to create ternary relationship in sql

I'm trying to create a hospital RDBMS and i need to create a ternary relationship between doctor, department, and patient, the ER part of the ER diagram which they need be assigned in that way. But I couldn't create their tables in the database.

enter image description here

The relationships are :

Many doctor can assign many patients and patients can assign many doctor, but many of the two(doctor and patient) can assign one department.

How can I create their SQL tables ?

Upvotes: 0

Views: 647

Answers (1)

Srinika Pinnaduwage
Srinika Pinnaduwage

Reputation: 1042

Tables

Department
Doctor (with FK of Department)
Patient (with FK of Department)
DoctorPatient (With FKs of Doctor & Patient)

Upvotes: 0

Related Questions