0% found this document useful (0 votes)
170 views

5.1. Data Modeling Part 4.1 - Practical

This document provides an overview and instructions for exercises related to data modeling and entity-relationship diagrams (ERDs). It includes examples of business scenarios and asks students to identify relationships between entities, complete ERDs, identify incorrect subtypes, and construct ERDs with subtypes based on given scenarios. The exercises are meant to help students practice key concepts related to data modeling using ERDs.

Uploaded by

BOCIL GAMING
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
170 views

5.1. Data Modeling Part 4.1 - Practical

This document provides an overview and instructions for exercises related to data modeling and entity-relationship diagrams (ERDs). It includes examples of business scenarios and asks students to identify relationships between entities, complete ERDs, identify incorrect subtypes, and construct ERDs with subtypes based on given scenarios. The exercises are meant to help students practice key concepts related to data modeling using ERDs.

Uploaded by

BOCIL GAMING
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

Topic 05.

1
Data Modeling Part 4.1- practical

Ivana Štrumberger, MSc


[email protected]
Faculty of Technical Sciences, Singidunum University
Database Systems
2019/20
Notation used in presentations

▪ Each assignment follows topics from lecture presentations.

▪ Assignments within each topic are divided into Exercises (Exercise 1,2,3
etc.) and Solutions (Solution 1,2,3 etc.).

▪ Important terms are given in this type of textbox.

▪ SQL code is given in this type of textbox.

Note
▪ Notes and remarks are given in callouts like this

2
3

Exercise 1
1. Read the given business scenario. Name the relationships between
EMPLOYEE and JOB. Include appropriate optionality and cardinality.

“We have a lot of employees who handle one or more different jobs. We’d
like to keep track of who is working on which job. Although employees can
help each other, a job is assigned to one employee and is the ultimate
responsibility of that employee. All of our employees have at least one job.
However, jobs exist that are not yet assigned to anyone.”
4

Exercise 1
1. Read the given business scenario. Name the relationships between
EMPLOYEE and JOB. Include appropriate optionality and cardinality.

“We have a lot of employees who handle one or more different jobs. We’d
like to keep track of who is working on which job. Although employees can
help each other, a job is assigned to one employee and is the ultimate
responsibility of that employee. All of our employees have at least one job.
However, jobs exist that are not yet assigned to anyone.”

Solution: Each EMPLOYEE must have (or handle, or be responsible for) one or
more jobs. Each JOB may be the responsibility of (or assigned to) one and
only one EMPLOYEE.
5

Exercise 1
2. Read the given business scenario. Name the relationships between ORDER
and WAITER. Include the appropriate optionality and cardinality.

“We assign our waiters to certain areas, except for our trainees who just
observe and are not responsible for taking any orders yet. A waiter takes the
orders for the tables in his area. All areas have one assigned waiter. A
customer places an order with a waiter. If the customer has a question or
wants to make a change to the order, he needs to request this with the
assigned waiter.”
6

Exercise 1
2. Read the given business scenario. Name the relationships between ORDER
and WAITER. Include the appropriate optionality and cardinality.

“We assign our waiters to certain areas, except for our trainees who just
observe and are not responsible for taking any orders yet. A waiter takes the
orders for the tables in his area. All areas have one assigned waiter. A
customer places an order with a waiter. If the customer has a question or
wants to make a change to the order, he needs to request this with the
assigned waiter.”

Solution:
Each WAITER may be assigned to (or handle, or take) one or more ORDERs.
Each ORDER must be assigned to (or handled by, or taken by) one and only
one WAITER.
7

Exercise 1
3. Read the given business scenario. Name the relationships between PARENT
and CHILD. Include the appropriate optionality and cardinality.

“At the end of each day, parents need to pick up their children at our day-
care center. All children must be picked up by 6 p.m. A child may have two
parents, but we need only one of them to come and pick up the child. We
cannot release a child to anyone but that child’s parent.”
8

Exercise 1
3. Read the given business scenario. Name the relationships between PARENT
and CHILD. Include the appropriate optionality and cardinality.

“At the end of each day, parents need to pick up their children at our day-
care center. All children must be picked up by 6 p.m. A child may have two
parents, but we need only one of them to come and pick up the child. We
cannot release a child to anyone but that child’s parent.”

Solution:
Each PARENT may pick up one or more CHILDren.
Each CHILD must be picked up by one or more PARENTs.
9

Exercise 2
1. Read the business scenario and review the ERD. Using the matrix diagram,
make up two or more possible relationships between PHOTOGRAPH and the
other entities that make sense for the business.

Scenario:

“I’m an amateur photographer. I own several cameras and am always taking


pictures of different subjects. I’m trying to keep track of which camera and
type of film perform best under certain conditions—indoor light, outdoor
light, etc.—so when I have my films developed, I note down which camera I
used. When the pictures come back, I note the subject and conditions. Each
picture always features one subject. A subject could be a view, a person or
group of persons, or an object or group of objects.”
10

Exercise 2
1. Read the business scenario and review the ERD. Using the matrix diagram,
make up two or more possible relationships between PHOTOGRAPH and the
other entities that make sense for the business.

ERD:
11

Exercise 2
1. Read the business scenario and review the ERD. Using the matrix diagram,
make up two or more possible relationships between PHOTOGRAPH and the
other entities that make sense for the business.

Two possible relationships are:


12

Solution Exercise 2
1. Possible Solution—Answers May Vary:

The extra relationships could be Camera to Photograph:

A CAMERA may record one or more PHOTOGRAPHS.


A PHOTOGRAPH must be recorded by a CAMERA.

The extra relationships could be Photograph to Subject:

A SUBJECT may be captured in a PHOTOGRAPH.


A PHOTOGRAPH may capture a SUBJECT.
13

Exercise 2
2. Complete the matrix diagram below, and construct an ERD from it.
14

Solution Exercise 2
2. Possible Solution—Answers May Vary:
15

Solution Exercise 2
2. Possible Solution—Answers May Vary:
16

Exercise 3
1. Find the incorrect subtypes in the illustration. Explain why you think the
subtype is incorrect. Adjust the model to improve it.
17

Solution Exercise 3
1. Find the incorrect subtypes in the illustration. Explain why you think the
subtype is incorrect. Adjust the model to improve it.
Solution: The subtypes for AUTOMOBILE are
not mutually exclusive. A 4-DOOR VEHICLE
could also be a SEDAN and/or a SPORT UTILITY
VEHICLE. Suggestion for improvement: remove
4-door vehicle subtype. Consider making
“number of doors” an attribute of the
supertype. Add other non-overlapping
subtypes or an “OTHER” subtype.

The subtypes of BUILDING are not exhaustive.


Surely there are other BUILDINGs that are not
a HOUSE. Add more subtypes or add an OTHER
subtype. Some possible subtypes of building
are OFFICE, SCHOOL, and FACTORY.
18

Exercise 3
2. Read the following scenario and construct an ERD that contains at least
two subtypes of the entity PRODUCT. Show clearly which attributes belong to
the entity supertype, and which belong to the subtypes. Identify a UID for the
entity.

“Our shops sell several kinds of women’s clothing, including dresses, skirts
and blouses. Of course each product has a name, a description, and a price.
Oh, and sizes too: all products have a waist size. Dresses and skirts have a
hem length but blouses don’t. Dresses and blouses have a chest size, but
skirts don’t.”
19

Solution Exercise 3
2. Read the following scenario and construct an ERD that contains at least
two subtypes of the entity PRODUCT. Show clearly which attributes belong to
the entity supertype, and which belong to the subtypes. Identify a UID for the
entity.

“Our shops sell several kinds of women’s clothing, including dresses, skirts
and blouses. Of course each product has a name, a description, and a price.
Oh, and sizes too: all products have a waist size. Dresses and skirts have a
hem length but blouses don’t. Dresses and blouses have a chest size, but
skirts don’t.”

Solution: This is tricky because the subtype attributes overlap. For example,
hem length is an attribute of two of the three subtypes (two of four if you
include an OTHER subtype). Either the hem length can be an attribute of both
subtypes DRESS and SKIRT, or hem length can be an attribute of the
supertype, with a null value for instances of BLOUSE.
20

Exercise 4
1. Members of your design team have been working with the local hospital to
develop a data model for their need to store information about patients, the
patient's room number, the patient's doctor, drug prescriptions given, and
specific drug information.

However, they all went on vacation and left you to figure out the model. They
also failed to give you any of their documentation other than the entities and
attributes illustrated here. Instead of going back to the hospital, which could
reflect poorly on your company, you’re going to have to think about
everything you know about hospitals!

Your task is to generate a list of business rules you think were used to arrive
at the information shown here. Use your imagination. List 10 structural rules,
5 procedural rules, and 2 programmatic rules (rules to be addressed by
computer applications in the future). State each rule as a single sentence.
21

Exercise 4
1. Based on your set of business rules, draw the ERD.
22

Solution Exercise 4
1. Solution—Answers May Vary:
• Structural Rules:
-A patient is someone who is admitted to the hospital.
-Each room assignment must include the building number and room number.
-Each room may be occupied by one or more patients.
-A physician must have a valid license number.
-Each drug must be prescribed by a physician.
-Each drug prescribed must have a label showing label number, dosage,
treatment duration, and expiration date.
-The drug code, name, and cost must be recorded for all drugs.
-Each prescription must have a number and date. Each physician may be
assigned to more than one patient. Each patient must have an assigned
physician.
23

Solution Exercise 4
1. Solution—Answers May Vary:
• Procedural Rules:
-Changes to prescriptions can be made only by licensed physicians.
-Patients cannot refill prescriptions without a physician's signature.
-Physicians cannot remove drug labels.
-Patients cannot change hospital rooms without a physician’s
recommendation.
-Nurses cannot reassign patients without physician approval.

• Programming Rules:
-Drugs costs are billed at current cost at the time of patient discharge.
-Physician fees may reflect additional costs associated with patient
complications, additional patient requests, etc.
24

Solution Exercise 4
25

Exercise 5
1. Draw ERDs for each of the following. Draw softboxes, relationship lines, and
labels for each relationship in both directions. Indicate non-transferability
when appropriate.

a. Each town may be the birthplace of many people. Each person must be born
in one and only one town.
b. Each room may house one or more guests. Each guest may stay in one and
only one room.
c. Each employee must work for one and only one department. Each
department may have one or more employees.
d. Each hotel may be the host of one or more guests. Each guest may be
hosted in one or more hotels.
e. Each message must be addressed to one or more persons. Each person may
be the addressee of one or more messages.
26

Exercise 5
1. Draw ERDs for each of the following. Draw softboxes, relationship lines, and
labels for each relationship in both directions. Indicate non-transferability
when appropriate.

f. Each garment must have one and only one price. Each price may be for one
or more garments.
g. Each airline coupon must be used for one and only one destination. Each
destination may be visited with one or more coupons.
h. Each automobile must use one and only one tire size. Each tire size may be
used by one or more automobiles.
i. Each child must have one and only one biological mother. Each mother must
be the parent of one or more children.
j. Each person must be of one and only one blood type. Each blood type may
classify one or more persons.
27

Exercise 5
1. Draw ERDs for each of the following. Draw softboxes, relationship lines, and
labels for each relationship in both directions. Indicate non-transferability
when appropriate.

k. A person may be on one or more junk-mail lists. Each junk list may contain
one or more persons.
l. Each student may learn from one or more teachers. Each teacher may
educate one or more students.
m. Each school may be attended by one or more honor students. Each honor
student must attend one and only one school.
n. Each fingerprint must belong to one and only one person. Each person must
have one and only one fingerprint.
28

Solution Exercise 5
a. Each town may be the birthplace of many people. Each person must be
born in one and only one town.

b. Each room may house one or more guests. Each guest may stay in one and
only one room.
29

c. Each employee must work for one and only one department. Each
department may have one or more employees.

d. Each hotel may be the host of one or more guests. Each guest may be
hosted in one or more hotels.

e. Each message must be addressed to one or more persons. Each person


may be the addressee of one or more messages.
30

f. Each garment must have one and only one price. Each price may be for one
or more garments.

g. Each airline coupon must be used for one and only one destination. Each
destination may be visited with one or more coupons.

h. Each automobile must use one and only one tire size. Each tire size may be
used by one or more automobiles.
31

i. Each child must have one and only one biological mother. Each mother
must be the parent of one or more children.

j. Each person must be of one and only one blood type. Each blood type may
classify one or more persons.

k. A person may be on one or more junk-mail lists. Each junk list may contain
one or more persons.
32

l. Each student may learn from one or more teachers. Each teacher may
educate one or more students.

m. Each school may be attended by one or more honor students. Each honor
student must attend one and only one school.

n. Each fingerprint must belong to one and only one person. Each person
must have one and only one fingerprint.
QUESTIONS?

33
References
1. Oracle Academy courseware (Database Foundations and Database
Design and Programming with SQL), 2015.
2. Burleson, K. D., Physical Database Design Using Oracle (Foundations of
Database Design), 1st Edition, Auerebach Publications, 2006, p. 247.

34
IMPORTANT NOTICE!
Ova prezentacija je nekomercijalna.
Slajdovi mogu da sadrže materijale preuzete sa Interneta, stručne i naučne
građe, koji su zaštićeni Zakonom o autorskim i srodnim pravima. Ova
prezentacija se može koristiti samo privremeno tokom usmenog izlaganja
nastavnika u cilju informisanja i upućivanja studenata na dalji stručni,
istraživački i naučni rad i u druge svrhe se ne sme koristiti –
Član 44 - Dozvoljeno je bez dozvole autora i bez plaćanja autorske naknade za nekomercijalne svrhe nastave:
(1) javno izvođenje ili predstavljanje objavljenih dela u obliku neposrednog poučavanja na nastavi;
- ZAKON O AUTORSKOM I SRODNIM PRAVIMA ("Sl. glasnik RS", br. 104/2009 i 99/2011)
.................................................................................................................................................................................
Ivana Štrumberger
[email protected]

35
Topic 05.1
Data Modeling Part 4.1- practical

Thank you for attention!


Ivana Štrumberger, MSc
[email protected]
Faculty of Technical Sciences, Singidunum University
Database Systems
2019/20

You might also like