Database Reference
In-Depth Information
that the order numbers for these orders are 1234, 3456, 4567, and 5678. What does
this relationship between CUSTOMER and ORDER mean for this example? The
explicit association is between customer Techchoice, Inc., an instance of the object
CUSTOMER, and orders 1234, 3456, 4567, and 5678, instances of the object
ORDER. So far, this is clear enough.
Now, the question arises: If instances of the objects CUSTOMER and ORDER
are related, how many instances of the object ORDER can be associated with one
instance of the object CUSTOMER? The answer to this question depends on the
business rules of the real-world situation. In our example, one customer may
place just one order or may place many orders. There is no restriction. That
means one instance of the object CUSTOMER is related to many instances of the
object ORDER. These numbers, referring to how many instances of one object
may be related to how many of the other object, express the cardinality of the
relationship.
Cardinality of relationships between two objects as shown in a data model indi-
cates how many instances of the first object may be related to how many instances
of the second—whether the number of instances is one or many . So three possibil-
ities exist for the expression of the cardinality of a relationship: one-to-one, one-to-
many, and many-to-many. We will explore these three types further.
One-to-One Relationship Take an example of the objects INVOICE and
PAYMENT. Although not practical, suppose a business rule in the organization
states that each invoice must be paid in full by a single payment because of account-
ing restrictions. In this case, the relationship between the objects INVOICE and
PAYMENT is a one-to-one relationship. The cardinality is 1 : 1. Figure 6-8 illustrates
this one-to-one relationship.
Note the associations indicated between instances of one object with instances
of the other object. Observe how only one instance of INVOICE may be connected
to a particular instance of PAYMENT. Similarly, only one instance of PAYMENT
may be linked to a specific instance of INVOICE. This is a one-to-one relation-
ship—one instance to one instance from either side of the relationship in the model
diagram.
One-to-Many Relationship Refer back to the example of the relationship
between CUSTOMER and ORDER. Here the relationship is a one-to-many
relationship. The cardinality is 1:* (asterisk indicating many ). Figure 6-9 shows this
one-to-many relationship.
Let us go over the associations between the objects instances, one by one. From
the side where the object CUSTOMER is shown, select customer instance A. This
customer A placed orders numbers 2, 5, and 7. So the relationship observed from
CUSTOMER side is: one customer instance related to many order instances. Note
the * (asterisk) placed closer to the ORDER object on the relationship line.
Now look at the relationship associations from the ORDER side. Note that
order number 1 from this side is linked to only one customer, namely B, on the
CUSTOMER side. So the relationship observed from ORDER side is: one order
instance is related to one customer instance. Notice the number 1 placed closer to
the CUSTOMER object on the relationship line.
Search WWH ::




Custom Search