Databases Reference
In-Depth Information
2.2 M ODELING Y OUR W ORLD— P ART 2
YOUR
TURN
C an you think of unary and ternary
relationships in your world?
make a list of the unary and ternary relationships in
the school environment and diagram them with E-R
diagrams. Do any of the many-to-many-many ternary
relationships have intersection data? Explain.
Q UESTION :
How many unary and ternary relationships can you think
of in your school environment? As in Your Turn 2-1,
General Hardware operate? Now that we know something about E-R diagrams, let's
see if we can figure it out from Figure 2.9!
Begin with the SALESPERSON entity box in the middle on the left.
SALESPERSON has four attributes with one of them, Salesperson Number, serving
as the unique identifier of the salespersons. Looking upwards from SALESPERSON,
a salesperson works in exactly one office (indicated by the double ones or bars
encountered on the way to the OFFICE entity). OFFICE has three attributes;
Office Number is the unique identifier. Looking back downwards from the OFFICE
entity box, an office has either no salespersons working in it (the zero modality
symbol) or one salesperson (the one or bar cardinality symbol). Starting again
at the SALESPERSON entity box and moving to the right, a salesperson has no
customers or many customers. (Remember that the customers are hardware or
home improvement stores.) The CUSTOMER entity has three attributes; Customer
Number is the unique identifier. In the reverse direction, a customer must have
exactly one General Hardware salesperson.
Below the CUSTOMER entity is the CUSTOMER EMPLOYEE entity.
According to the figure, a customer must have at least one but can have many
employees. An employee works for exactly one customer. This is actually a special
situation. General Hardware only has an interest in maintaining data about the people
who are its customers' employees as long as their employer remains a customer of
General Hardware. If a particular hardware store or home improvement chain stops
buying goods from General Hardware, then General Hardware no longer cares about
that store's or chain's employees. Furthermore, while General Hardware assumes
that each of its customers assigns their employees unique employee numbers, those
numbers can be assumed to be unique only within that customer store or chain .
Thus, the unique identifier for a customer employee must be the combination
of the Customer Number and the Employee Number attributes. In this situation,
CUSTOMER EMPLOYEE is called a dependent or weak entity.
Returning to the SALESPERSON entity box and looking downward, there
is a one-to-many relationship between salespersons and sales. But, below that,
there is also a one-to-many relationship from products to sales. Also note that the
unique identifier of SALES is the combination of Salesperson Number and Product
Number. This is the signal that there is a many-to-many relationship between
salespersons and products! A salesperson is authorized to sell at least one and
generally many products. A product is sold by at least one and generally many
salespersons. The PRODUCT entity has three attributes, with Product Number being
Search WWH ::




Custom Search