DBMS Session 3 Notes
DBMS Session 3 Notes
Session 3 Agenda
Entity
Attribute
Keys
Keys (Con’t)
Alternate key is the candidate key which are not selected as the
primary key. Ex: if social security number is stored on table.
Relationships
Number of entity instances to which another entity instance can map under the
relationship
One-to-one: X:Y is 1:1 is each entity in X is associated with at most one entity
in Y and each entity in Y with at most one entity in X. Example: Each student
has only one student ID, and each student ID is assigned to only one person.
Partial Participation
Represented by single line from entity rectangle to relationship diamond
Not every entity instance must participate
Using University example:
Some students may not be enrolled in any class
Some classes may have no students enrolled
Some faculty may not be teaching any class
Total Participation
Represented by double line from entity rectangle to relationship diamond
Every member of entity set must participate in the relationship
Using University example:
Every class must have a faculty teaching it
Chapter 3: The Entity Relationship Model
a. Show how the entity set and its attributes would be represented on
an E-R diagram.
b. Identify a superkey for the Book entity set.
c. Identify all candidate keys for the entity set.
d. Identify a primary key for the entity set and underline it on the E-R
diagram.
Chapter 3: The Entity Relationship Model
a. Show how the entity set and its attributes would be represented
on an E-R diagram.
a. Show how the entity set and its attributes would be represented
on an E-R diagram.
Chapter 3: The Entity Relationship Model
If the assumptions about title are not valid, some combination such as
{title, author}, or {title, author, datePurchased} may be needed as a
superkey.
Chapter 3: The Entity Relationship Model
Under our initial assumptions in part (b), the candidate key is: title
Chapter 3: The Entity Relationship Model
d. Identify a primary key for the entity set and underline it on the
E-R diagram.
d. Identify a primary key for the entity set and underline it on the
E-R diagram.
a. Show how this entity set Purchase and its relationship to Book
would be represented on the E-R diagram.
a. Show how this entity set Purchase and its relationship to Book
would be represented on the E-R diagram.
Chapter 3: The Entity Relationship Model
a. Show how this entity set Purchase and its relationship to Book
would be represented on the E-R diagram.
author title purchase Total
publisher
Date Amount
pubDate
number Book
Pages
condition cost
M 1 Purchase
Order
Number
Chapter 3: The Entity Relationship Model
We assume that each purchase must include at least one book, and may
include several.
We also assume that not all books are the result of a purchase, since the
collector can acquire books through gifts, inheritance, barter, or other
means.
The 1 and M symbols and the single line and double line express these
constraints.
Chapter 3: The Entity Relationship Model
number Book
Pages
condition cost
M 1 Purchase
Order
Number
Chapter 3: The Entity Relationship Model
The book collector makes purchases from many sellers, but each
purchase is made from one seller.
Step 3.1- Make a list of all entities and their associated attributes.
Examine the data dictionary and cross-reference table and group the
appropriate attributes into entities.
Step 3.1.a - Show how the Employee entity set and its attributes would be
represented on an E-R diagram.
Draw the entity Employee and include the attributes associated with the entity.
Step 3.1.b - Identify all candidate keys for the Employee entity set.
Write out the candidate keys.
Step 3.2.c - Identify the primary key for the Employee entity set and
underline it on the E-R diagram.
Write out the primary key and underline it on the E-R Diagram.
Chapter 3: The Entity Relationship Model
Step 3.1.a - Show how the Employee entity set and its attributes would be
represented on an E-R diagram.
Draw the entity Employee and include the attributes associated with the entity.
Step 3.1.b - Identify all candidate keys for the Employee entity set.
Write out the candidate keys.
Step 3.2.c - Identify the primary key for the Employee entity set and
underline it on the E-R diagram.
Write out the primary key and underline it on the E-R Diagram.
Chapter 3: The Entity Relationship Model
Step 3.2 - Assume in the same enterprise, that there is a second entity set
called Project with attributes projName, startDate, endDate, and budget.
Step 3.2.a - Show how the Project entity set and its attributes and its
relationship to Employee would be represented on the E-R diagram.
Also, underline the primary keys for all entities on the E-R diagram.
Step 3.2.c - Stating any necessary assumptions, make a decision about the
cardinality and participation constraints of the relationship between
Employee and Project, and add the appropriate symbols to the E-R
diagram.
CS 623 – Database Management Systems
Step 3.3 - Assume in the same enterprise, that there is a third entity set
called Department with attributes deptNo, deptName and mrgName.
Step 3.3.a - Show how the Department entity set and its attributes and its
relationship to Employee would be represented on the E-R diagram.
Also, underline the primary keys for all entities on the E-R diagram.
Step 3.3.b - Assume that each employee works for only one department.
Projects are not directly sponsored by a department. Show how this
would be represented on E-R diagram.