CIT 365 Chapter 2. Data Models Without Exercise Solution
CIT 365 Chapter 2. Data Models Without Exercise Solution
Data Models
Course Instructor:
Dr. Ikbal Taleb
©2017 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part, except for use as permitted in a license distributed with a
certain product or service or otherwise on a password-protected website or school-approved learning management system for classroom use.
2
2
2
3
2
Modeling
• A model is an abstraction (representation) of
a more complex real-world object or event.
• Types of Models
– Physical
– Narrative
– Graphical
– Mathematical
4
2
Data Models
5
2
https://youtu.be/Vn9BUfUCL4I
• End-users have different views and needs for
data
• Data model organizes data for various users
• Facilitate interaction among the designer, the
applications programmer, and the end users
6
2
Real-life Real-World
Oriented Object-Oriented Entity-Relationship
(End Users)
Models
1
SQL Schema
3
Computer
Oriented Network Hierarchical Relational
Models
7
2
First Step!
10
2
Business Rules
• A business rule is
– a brief, precise, and unambiguous description of a
policy, procedure, or principle within a specific
organization
11
2
12
2
Exercise # 1
• Write business rules based on the data stored
in the following tables:
14
14
Sources of Business Rules
Company Department
Policy makers
managers managers
Direct
Written
interviews
documentation
with end users
©2017 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part, except for use as permitted in a license distributed with a
certain product or service or otherwise on a password-protected website or school-approved learning management system for classroom use.
15
2
Translating Business rules into Data
model components
• Generally, nouns translate into entities
• Verbs translate into relationships among
entities
• Relationships are bi-directional
• Example:
– A customer may generate many invoices.
– An invoice is generated by only one customer.
17
2
• Example:
– A customer may generate many invoices.
– An invoice is generated by only one customer.
0, M
1,1
CUSTOMER generate INVOICE
18
2
1. Hierarchical
2. Network
3. Relational
4. Object oriented (OO)
5. XML
20
2
21
2
• Table (relations)
– Matrix consisting of a series of row/column
intersections
– Related to each other through sharing a
common entity characteristic
22
2
The Relational Model (continued)
23
2
• Relational Table
– Stores a collection of related entities
• Resembles a file
• Relational table is purely logical structure
– How data are physically stored in the
database is of no concern to the user or the
designer
– This property became the source of a real
database revolution
24
2
The Relational Model (continued)
Relational diagram
Representation of relational database’s entities, attributes within
those entities, and relationships between those entities
25
2
27
2
28
2
29
Figure 2.3 - The ER Model Notations
©2017 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part, except for use as permitted in a license distributed with a
certain product or service or otherwise on a password-protected website or school-approved learning management system for classroom use.
30
Exercise # 2
Draw an ER Diagram for the following scenario:
Scenario 1: (Chen’s notation)
“A customer can make many payments, but each
payment is made by only one customer”.
©2017 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part, except for use as permitted in a license distributed with a
certain product or service or otherwise on a password-protected website or school-approved learning management system for classroom use.
31
Exercise # 3
Based on the data stored in the following tables draw
ER Diagram using Crow’s Foot Notation:
©2017 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part, except for use as permitted in a license distributed with a
certain product or service or otherwise on a password-protected website or school-approved learning management system for classroom use.
33
Exercise # 4
©2017 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part, except for use as permitted in a license distributed with a
certain product or service or otherwise on a password-protected website or school-approved learning management system for classroom use.
34
Exercise # 5
The DealCo relational diagram (above) shows the initial entities and
attributes for the DealCo stores, located in two regions of the country. Base
on the diagram:
a. Identify each relationship type and write all of the business rules.
b. Create the basic Crow’s Foot ERD for DealCo.
©2017 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part, except for use as permitted in a license distributed with a
certain product or service or otherwise on a password-protected website or school-approved learning management system for classroom use.
36
Exercise # 5 Solution
Identify each relationship type and write all of the business rules.
©2017 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part, except for use as permitted in a license distributed with a
certain product or service or otherwise on a password-protected website or school-approved learning management system for classroom use.
37
Exercise # 5 Solution (continue)
The Crow’s Foot ERD for DealCo
is location for
REGION STORE
employs
is assigned to
JOB EMPLOYEE
1 M
REGION is location for STORE
employs
M
1 M
JOB is assigned to EMPLOYEE
39
Exercise # 6
Typically, a patient staying in a hospital receives medications that have been
ordered by a particular doctor. Because the patient often receives several
medications per day, there is a 1:M relationship between PATIENT and
ORDER. Similarly, each order can include several medications, creating a
1:M relationship between ORDER and MEDICATION.
©2017 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part, except for use as permitted in a license distributed with a
certain product or service or otherwise on a password-protected website or school-approved learning management system for classroom use.
40
2
42
2
43
43
2
44
2
45
45
2
Figure 2.8 - External Models For Tiny
College
46
46
2
48
48
2
The Internal Model
• Representing database as seen by the DBMS
mapping conceptual model to the DBMS
• Internal schema: Specific representation of
an internal model
– Uses the database constructs supported by
the chosen database
• Is software dependent and hardware
independent
• Logical independence: Changing internal
model without affecting the conceptual model
49
49
2
Figure 2.10 - Internal Model for Tiny
College
50
50
2
The Physical Model
52
52
2
53