Database Reference
In-Depth Information
way, write it down. Later you will use this information to build your logi-
cal, and ultimately your physical, model.
Cardinality
As we discussed in Chapter 2, cardinality further defines a relationship.
When looking at the requirements you have gathered, you should keep a
keen eye out for anything that indicates cardinality. When talking with the
CEO, we were told the following:
Customers log on to our Web site and place an order, or call an employee
who places the order on the customers' behalf.
You will recall that this helped us to define a 1:M relationship between
Customer and Order and a 0:M relationship between Order and
Employee. We didn't talk about it in much detail at the time, but these re-
lationships also contain the implied cardinality from the CEO's statement.
We can see that each Order must be owned by a customer; either the cus-
tomer placed the order, or an employee did. Therefore, each Order must
have one customer, no more and no less, but a customer can have many or-
ders. Now let's look at the 0:M cardinality of Employee to Order. An order
does not have to be placed by an employee, but an employee can place
multiple orders. The cardinality helps to further refine the relationship.
Implementing cardinality in our model can be simple or complex. In
the example, the order table will contain a mandatory foreign key that
points to the PK in the customer table. Each time an order is entered, it
must be tied to a customer. Additionally, an optional foreign key will be
created in the order table pointing to the employee PK. Each order can
have an employee, but it is not required that there be one. You can imple-
ment more-complex cardinality, such as limiting an order to no more than
five detail items, by using constraints and triggers.
Data Requirements
Although not technically a modeling concern, data storage and data reten-
tion requirements are crucial to your physical implementation. Where fea-
sible, try to pull this information from the requirements you gather. These
pieces of information will aid you in determining the initial database size
and future growth trends. Without such information, you will be at best
taking a wild guess. Whenever you are given a number, such as orders
Search WWH ::




Custom Search