I have an assignment which requires me to design a database.

I have 3 entity types WARD, BED, and BED_ASSIGMENT (which is the "composite" entity type between BED and WARD).

The BED primary key consists of the attributes bed_id and ward_id (each ward has bed number 1 for example, so I need ward_id to properly identify it)

My question is:

I have two attributes: total_bed_ count and total_vacant_bed_count. In which entity type should I place them?

  • 1
    You shouldn't have these attributes in any entity. I'm of the strong opinion this shouldn't be stored but queried. – Colin 't Hart Apr 22 at 9:13

Don't store redundant information. Both total_bed_count and total_vacant_bed_count can be queried.

total_bed_count would be something like select count(*) from bed, while total_vacant_bed_count could be queried if you know which beds don't have patients assigned to them, maybe something like select count(*) from bed where patient is null.

  • thank you Colin – Myaccount Apr 23 at 5:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.