A faculty member can take multiple pieces of equipment of campus, and such equipment is specifically assigned to one person.
What would the entities in this data model look like and what would their relationship be?
Cheers
A faculty member can take multiple pieces of equipment of campus, and such equipment is specifically assigned to one person.
What would the entities in this data model look like and what would their relationship be?
Cheers
You have a one-to-many (1:n) relationship between faculty (1) and equipment (n).
So, I'd imagine a Faculty table and an Equipment table would be needed. The primary key of each would be some kind of unique ID (auto-generated like AUTO_INCREMENT, or explicitly given).
Since the 1:n relationship is Faculty:Equipment, you'd have the Faculty.id ("id" being a made-up column name for the primary key) be referenced in your Equipment table.
Therefore, the referential-relationship/bridge/match between these two tables would be Faculty.id and Equipment.faculty_id ("faculty_id" being a made-up column name which represents the corresponding Faculty table's primary key):
Faculty.id = Equipment.faculty_id
That's a classical 1:n relationship. Have one table for the faculty members, say members
with an ID as PK and
another table with the assets
. The assets have also an ID (which is irrelevant for this) and a FK, say assigned_to
which refers to the PK of the members
table.
If you ever want to know who check out what equipment over time, your design has to be a little more sophisticated. You need some sort of Equipment Checkout table in between to keep the history of pieces of equipment being checked out and checked back in. When a piece of equipment is being checked out by a faculty member, create the EquipmentCheckout record with pointers to the faculty member and the piece of equipment and the DateOut. Then, link the Equipment record to the EquipmentCheckout record. As long as the CheckoutId field is not null, nobody else can check out that piece of equipment. When the equipment is returned, edit the EquipmentCheckout record with the DateIn, and set the CheckoutId for that piece of equipment to null. Then, you will have a history of who checked out what.