Database Fundamentals
TheData Model: More About Relationships
1
Microsoft Enterprise Consortium:http://enterprise.waltoncollege.uark.eduMicrosoft Faculty Connection/Faculty Resource Centerhttp://www.facultyresourcecenter.com
Things you should know …
This presentation assumes you are already familiar with these terms:Entity and entity typeEntity instanceAttributeIdentifierMultivaluedCardinality
2
Relationships and cardinality
What do the relationships symbols really mean to us? Here are a few examples of how to read theminimumandmaximumsymbols.A customer can have a minimum of zero orders.A customer can have a maximum of many orders.An order is for a minimum of one customer.An order is for a maximum of one customer.
3
LOCATION
EMPLOYEE
CUSTOMER
ORDER
Relationships
Based onmaximumcardinality, a relationship falls into one of three types:one-to-manymany-to-manyone-to-one
4
LOCATION
EMPLOYEE
CUSTOMER
INVENTORY
ORDER
one-to-many
many-to-many
one-to-one
Maximum Cardinality
Keep in mind that the 3 relationship types (1-to-1, 1-to-many, and many-to-many) describe the maximum cardinality at both ends of a relationship.It’s incorrect to read the minimum and maximum cardinality as “one-to-many”, for instance.
5
INVENTORY
ORDER
CUSTOMER
ORDER
This is many-to-many.
This is one-to-many.
Degree of the relationship - Unary
Thedegree of the relationshiprefers to the number of entities in a single relationship.The options are:unary,binary,ternary.Aunaryrelationship means a entity is related to itself. There is onlyone entity.
6
EMPLOYEE
Any one employee—Casey Wilson, for example—may besupervisedby a minimum ofzeroemployees.Any one employee—Casey Wilson, for example—may besupervisedby a maximum ofoneemployee.Any one employee—Carla Stevens, for example—maysupervisea minimum ofzeroemployees.Any one employee—Carla Stevens, for example—maysupervisea maximum ofmanyemployees.
Supervised by
Supervises
Degree of the relationship - Binary
Abinaryrelationship means two entities are directly related. This is by far the most common one you see in a data model.
7
sold in
has
INVENTORY
ORDER
Any oneorder—order ID # 4528, for example—may have aminimumof oneinventoryitems in the order.Any oneorder—order ID # 4528, for example—may have amaximumof manyinventoryitems in the order.Any oneinventoryitem—Day-Glow Toothpaste, for example—may be sold ina minimumof zeroorders.Any oneinventoryitem—Day-Glow Toothpaste, for example—may be sold in amaximumof manyorders.
Degree of the relationship - Ternary
Aternaryrelationship means three entities are directly related. However, this three-way relationship between three entities can be decomposed into binary relationships. Therefore, we won’t spend more time on this term.
8
In this presentation we’ve seen that a relationship is one-to-one or one-to-many or many-to-many. This information has important implications for how the database is actually built.We’ve also seen what the “degree of the relationship” means. How many entities are involved in a direct relationship: unary (1 entity), binary (2 entity), or ternary (3 entity)?
We’ve learned more about relationships
Resources
Microsoft Enterprise Consortium:http://enterprise.waltoncollege.uark.edu/mec.aspThe consortium provides teaching material and large databases donated by some major corporations.Microsoft Faculty Connection—Faculty Resource Centerhttp://www.facultyresourcecenter.com/A wide range of teaching resources are available.
10
0
Embed
Upload