Answer to Exercise ER-2

In each of the below I drew the ER diagram and assume that you can read the cardinality and existence off of the diagram.

1

The optional on the left could be left out. It is not stated in the problem. Assumption: A person does not have to be employed by a department.

q2-1.png

2

The optional on both sides could be left out. It is not stated in the problem. Assumptions: A department does not have to have a manager. A manager does not have to manage a department.

q2-2.png

3

The optional on both sides could be left out. It is not stated in the problem. Assumptions: An author does not have to write a book. A book does not have to have an author.

q2-3.png

4

The mandatory on the right could be left out. It is not stated in the problem. Assumption: A team must have at least one player. FYI: If you see this type of ER diagram, you can know that it is not implemented this way. Ask yourself: If there aren't any teams or players in a database, and I need to enter my first team, then I can't because I don't have any players for it yet. Similarly, if I need to enter my first player, then I can't because I don't have any teams for him/her yet. So, generally, you'll see an optional on the many side of the relationship.

q2-4.png

5

The optional on the right could be left out. It is not stated in the problem. Assumption: A lecturer does not have to teach any courses.

q2-5.png

6

The straight-forward way of describing this situation is the following.

q2-6.png

But, you know, I don't really like the above. It doesn't capture what's really going on with a flight leg. A flight leg takes off from exactly one airport and lands at exactly one airport — why not make it so that the ER diagram represents the situation and emphasizes these facts?

q2-6a.png

To me, the above is a more natural representation of the situation, though the original description of the problem leads you to answer the problem similar to the first presentation.

7

The existence information on each side is not stated in the problem. Assumptions: A product does not have to be on any purchase orders. A purchase order must have at least one product.

q2-7.png

8

Everything you need is in the problem statement.

q2-8.png

Return to ER exercises.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License