Question

Recently, a friend of mine asked me this question about the cardinality between a Department and Employee entities, I replied many to many, then he, my friend, showed me drawings from the internet which says otherwise, one to one. I objected the idea and told him don’t trust everything on the internet. However, after I examined books on Database Concepts I found the one to one relationship that my friend showed to me. As an example I took the following snapshot from “The Morgan Kaufmann Series in Database Management System: Database Modeling and Design 4th EditionSnapshot of one to one relationship

Fortunately, these guys mapped the entities depicting the foreign key relationship. Suppose after a year another employee is assigned to manage a department previously being managed by another employee. At this point are we going to update the mgr_id column and loose the history of the department and employee relationship?

Était-ce utile?

La solution

What is the cardinality of (this) entity relationship between Employee and Department?

Yes, this relationship ("managed-by") is an example of a one-to-one relationship. This doesn't forbid the two entities form having other relationships, (ie. "works-in") that are of different cardinality, one-to-many or many-to-many.

Suppose after a year another employee is assigned to manage a department previously being managed by another employee. At this point are we going to update the mgr_id column and loose the history of the department and employee relationship?

Yes, the department . mgr_id will be updated and the historical info will be lost. If you want to preserve historical data, the tables should be designed with this in mind. Some DBMS provide built-in support for such temporal data. For some more details, see Temporal databases.

Licencié sous: CC-BY-SA avec attribution
Non affilié à dba.stackexchange
scroll top