how to express one and only one instance in erd?

Viewed 156

I am creating ERD for Hospital, where it has Doctors and Employees and many other entities.

This ERD is belong to only one Hospital, so I think I don't have to make the Hospital as Entity, because if I do, It will mean that I can add more than one hospital which I dont want.

The issue is this hospital is managed by One and Only One Doctor.

I thought of adding "manager" boolean attribute to the Doctors Entity, but this will allow more doctors to be a manager.

I also thought of adding "manage" relation between every Entity and the Doctor, but this will cause the same issue. I am looking for the best way to express this case or what do we call it in ERD.

1 Answers

So you've got one hospital, and one Doctor as a manager... dont really think you can get around making the Hospital to an entity ? the entity should ressemble an table in your db/model in your app, and if there is no model in your app/ table in your db, this would be a weird structure...

regarding the doctor issue. You can in ERD display this as recursive relation (your entity basically have a relationship to itself)

so a doctor is both managed by, and can manage doctors.

further reading

https://www.geeksforgeeks.org/recursive-relationships-in-er-diagrams/

Related