Tutorial 2
Practice Exercise
1. Match the following terms and definitions.
Term Definition
1. composite attribute -i a. uniquely identifies entity instances
2. associative entity-e b. relates instances of a single entity type
3. unary relationship-b c. specifies maximum and minimum number of instances
4. weak entity-j d. relationship modeled as an entity type
5. Attribute-h e. association between entity types
6. entity -l f. collection of similar entities
7. Relationship type-e g. number of participating entity types in relationship
8. cardinality constraint- h. property of an entity
c i. can be broken into component parts
9. Degree-g j. depends on the existence of another entity type
10. Identifier-a k. relationship of degree 3
11. entity type-f l. person, place, object, concept, event
12. Ternary-k
2. Make comparison and contrast
a. stored attribute:
derived attribute:
b. simple attribute:
composite attribute:
c. entity type; relationship type
d. strong entity type; weak entity type
e. degree; cardinality
f. required attribute; optional attribute
g. composite attribute; multivalued attribute
h. ternary relationship; three binary relationships
a. Stored attributes are those attributes that are stored permanently in the
database, while derived attributes are those attributes that are calculated or
derived from other attributes. Stored attributes are usually simple attributes,
while derived attributes may be simple or composite.
b. Simple attributes are attributes that cannot be divided any further, while
composite attributes are attributes that can be divided into multiple sub-
attributes. Simple attributes are usually stored attributes, while composite
attributes are usually derived attributes.
c. Entity type and relationship type are both data modeling concepts used to
represent entities and their relationships in a database. Entity type represents a
collection of similar entities, while relationship type represents the association
between multiple entities.
d. A strong entity type has a primary key that uniquely identifies each entity
instance, while a weak entity type does not have a primary key without being
linked to a strong entity type. Strong entities do not depend on other entities to
exist, while weak entities rely on strong entities for their existence.
e. Degree refers to the number of entities involved in a relationship, while
cardinality refers to the number of instances of one entity that can be linked to
another entity in a relationship.
f. Required attributes are attributes that must have a value for an entity
instance, while optional attributes are attributes that may or may not have a
value for an entity instance.
g. A composite attribute can be divided into multiple sub-attributes, while a
multivalued attribute can have multiple values for the same entity instance.
h. A ternary relationship involves three entities, while three binary
relationships involve only two entities at a time and must be combined to
express the same relationship as a ternary relationship.
3. Give an example for Unary, Binary and Ternary relationship.
3. Draw an ERD diagram for the following case (3pt)
Consider the following information about a university database:
• Each student has an id (sid), a name (sname), a major study direction (major) and
an date of birth(dob).
• Each course has a name (cname) and description (cdesc).
• Each faculty has an id (fid) and a name (fname).
• Students can be enrolled in several courses and for each course there exists at
least one student who is enrolled in that course.
• Each course belongs to one faculty and for each faculty exists at least one course
which belongs to this faculty.
Draw an ERD diagram which captures the information above. Be sure to indicate
every key and participation constraint.
4. An Electricity Company wishes to create a database with the following entities and
attributes:
• Customer, with attributes Customer ID, Name, and Telephone
• Location, with attributes Location ID, Address (Street, City, State, Zip
Code), and Type (values of Business or Residential)
• Rate, with attributes Rate Class and RatePerKWH
After interviews you have come up with the following business rules:
• Customers have one or more locations.
• Each location has one or more rates, depending on the time of day.
Draw an ERD for this situation and place minimum and maximum cardinalities on
the diagram. State any assumptions that you have made.
5. A company has a number of employees. The attributes of EMPLOYEE include
Employee ID (identifier), Name, Address, and Birthdate. The company also has
several projects. Attributes of PROJECT include Project ID (identifier), Project
Name, and Start Date. Each employee may be assigned to one or more projects, or
may not be assigned to a project. A project must have at least one employee
assigned and may have any number of employees assigned. An employee’s billing
rate may vary by project, and the company wishes to record the applicable billing
rate (Billing Rate) for each employee when assigned to a particular project.
Draw an ERD for this case. Do the attribute names in this description follow
the guidelines for naming attributes? If not, suggest better names.
Homework
1. Define the following terms:
a. entity type g. multi-valued attribute
b. entity-relationship model h. associative entity
c. entity instance i. cardinality constraint
d. attribute j. weak entity
e. relationship type k. identifying relationship
f. identifier l. derived attribute
2. Give an example (other than those described in the slide) for each of the following,
and justify your answer:
a. derived attribute
b. multi-valued attribute
c. atomic attribute
d. composite attribute
e. required attribute
f. optional attribute
3. What is the degree of a relationship? List the three types of relationship degrees
described in the chapter and give an example of each.
5. A hospital has a large number of registered physicians. Attributes of PHYSICIAN
include Physician ID (the identifier) and Specialty. Patients are admitted to the
hospital by physicians. Attributes of PATIENT include Patient ID (the identifier) and
Patient Name. Any patient who is admitted must have exactly one admitting physician.
A physician may optionally admit any number of patients. A particular physician may
treat any number of patients, or may not treat any patients. Whenever a patient is
treated by a physician, the hospital wishes to record the details of the treatment
(Treatment Detail). Components of Treatment Detail include Date, Time, and Results.
Draw ERD for the above scenario.
Did you draw more than one relationship between physician and patient? Why or why
not? Did you include hospital as an entity type? Why or why not? Does your ERD
allow for the same patient to be admitted by different physicians over time? How
would you include on the ERD the need to represent the date on which a patient is
admitted for each time they are admitted.