Chapter 2
Data Model
Database Systems:
Design, Implementation, and Management, Sixth
Edition, Rob and CoronelIn this chapter, you will learn:
Why data models are important
About the basic data-modeling building blocks
What business rules are and how they affect database
design
How the major data models evolved, and their
advantages and disadvantages
How data models can be classified by level of
abstractionThe Importance of Data Models
Data model
— Relatively simple representation, usually graphical,
of complex real-world data structures
— Communications tool to facilitate interaction among
the designer, the applications programmer, and the
end user
Good database design uses an appropriate data model
as its foundation
End-users have different views and needs for data
Data model organizes data for various usersData Model Basic Building Blocks
Entity -
is anything about which data are to be collected and
stored
Attribute —
is a characteristic of an entity
Relationship —
describes an association among (two or more) entities
— One-to-many (1:M) relationship
— Many-to-many (M:N or M:M) relationship
— One-to-one (1:1) relationship
Constraint - a restriction placed on the data+ How do database designers go about determining
the entities, attributes, and relationships that will
build a data model?
Business Rules
+ Business Rules —
Brief, precise, and unambiguous description of a
policy, procedure, or principle within a specific
organization’s environmentBusiness Rules (continued)
Must be rendered in writing
Must be kept up to date
Sometimes are external to the organization
Must be easy to understand and widely disseminated
Describe characteristics of the data as viewed by the
companyExamples of Business Rules
« Acustomer may generate many invoices.
+ Each invoice is generated by only one customer.
ER model
1 M
CUSTOMER et INVOICE.
.
Sources of Business Rules
Company managers
Policy makers
Department managers
Written documentation
— Procedures
— Standards
— Operations manuals
Direct interviews with end usersImportance of Business Rules
Standardize company’s view of data
Constitute a communications tool between users
and designers
Allow designer to understand the nature, role, and
scope of data
Allow designer to understand business processes
Allow designer to develop appropriate
relationship participation rules and constraintsTranslating Business Rules into —
Model Components
* Generally, nouns translate into entities
* Verbs translate into relationships among entities
* Relationships are bi-directional
ER model
1 M
CUSTOMER << INVOICE
+ Acustomer may generate many invoices.
+ Each invoice is generated by only one customer. 10The Evolution of Data Models
ee eet ese et een Ty
Tt
id
Rr
Borers
Demers
a Spence toe 1 Compt erator persia Pe ae
oct erro nem meeps c sparen
Didar mn peneed ee 9 RS.
iio Getwelaccte
3 am Tae RR STR RETREAT —| pio compet i cea TT
a 2 Negus ean teat opener sees
2 Rhriasmin ndatraipapecuth nian mamaipnre | anche set ape
} Onemcoemretath Gartierdiotedtemare” | 3 Severn Gugnretrchgs nasser mer.
1am au poe
5. Mc ernment
2S SISEAEES ewer ct ed st mn
[= Lagat 9A aN a
Tas =e TV Srasnal nkpenkees Bora Ree
Eee thape sunin cur ache er
pease page 2: Cevepal rey hn ny wri pd
2 reer atest imraceconans eye teen |” Sguciyanmpeet nd dune to posuere
Femarccontdsanun mparoricenragree | tasanrw agnor
mo 1 Rey poe Woe ci pt eh ad
2: Al gan candy hand Site conch doc dc ont ppt
1 ad tt ar ont i a oo
Sereniepteeneseced be
Ta = Titet net ptcrasyhear tay Ties Siebarreasalaprien
een J walqrectonmantmcantncrmctionmd — | > thertinednsmmpmprersan
J Vrcuad ne denmt aead a 3 Noro das wpe rouse
2 [Suis meet anc end ee
‘acs atnded gan Pe bron
Inubonpensttn rae
an = T eacaner saat Tas act grrte reat aaah Boome
Ot 2 Setimpecetaon vin otc tamale hss man annpacnda
1 Mint nie eso 2 ER
2 Gfenerees Sor ese
te asin sume ar sro ent te ie, he, tn a oe Ban emda tv pon tnd,The Evolution of Data Models
Hierarchical
Network
Relational
Entity relationship
Object orientedThe Hierarchical Model
* Developed in the 1960s
to manage large amounts of data for
complex manufacturing projects
* Basic logical structure is represented by
an upside-down “tree”Hierarchical Database Model
+ Logically represented by an upside down tree
— Each parent can have many children
— Each child has only one parent
FIGURE __ A hierarchical structure
21
niirt <>
Level 1 Segments
(Root Children) * al Eo
Level 2 Segments
(Level 1 Children)
en ke
Level 3 Segments
(Level 2 Children) —_ Part A } Part B Part C | Part D Part E |Hierarchical Database Model 7
+ Advantages
— Conceptual simplicity (The relationship between the
various layers of the model is logically simple)
— Database security and integrity
— Data independence
— Efficiency
+ Disadvantages
— Complex implementation
— Difficult to manage and lack of standards
— Lacks structural independence
— Applications programming and use complexity
— Implementation limitations iThe Network Model
* Created to
— Represent complex data relationships
more effectively
— Improve database performance
— Impose a database standardThe Network Model (continued)
+ Schema
— Conceptual organization of entire
database as viewed by the database
administrator
+ Subschema
— Defines database portion “seen” by the
application programs that actually
produce the desired information from
data contained within the databaseThe Network Model (continued)
* Schema Data Definition Language (DDL)
— Enables database administrator to define schema
components
* Subschema DDL
— Allows application programs to define database
components that will be used
+« Data Management Language (DML)
— Defines the environment in which data can be
managed
— Works with the data in the databaseThe Network Model (continued)
+ Resembles hierarchical model
+ Collection of records in 1:M relationships
+ Set
— Relationship
— Composed of at least two record types
+ Owner
— Equivalent to the hierarchical model’s parent
+ Member
— Equivalent to the hierarchical model's childNetwork Database Model
+ Each record can have multiple parents
— Composed of sets
— Each set has owner record and member record
— Member may have several owners
FIGURE A network data model
2.2 ® Collection of records in 1:M relationships
Commission set Sales set Payment set
Inventory set Line setNetwork Database Model =a
+ Advantages
— Conceptual simplicity
— Handles more relationship types
— Data access flexibility
— Promotes database integrity
— Data independence
— Conformance to standards
« Disadvantages
— System complexity
— Lack of structural independenceRelational Database Model
Developed by Codd (IBM) in 1970
Perceived by user as a collection of tables for data
storage
Tables are a series of row/column intersections
Tables related by sharing common entity characteristic(s)
(Figure 2.4)
Relational table is purely logical structure
— How data are physically stored in the database is of no
concern to the user or the designerLinking Relational Tables
FIGURE
2.3
_INAME [AGENT_FNAME | AGENT INTIAL | AGENT_AREACODE | AGENT PHONE
Alex 8 713 28-1249
502 Hahn Leah F 615 882-4244
503, Okon John T 615 123-5589
y 10010 Ramas 844-2573, 05-Apr-2006
10011 Dunne Leona K 713 894.1238 18-Jun-2008, 501
[] 10012! smth Kathy we 615 834-2285 29-Jan-2007 502
10013 Olowski Paul F 615 834-2180 14-Oct-2006 502
10014 Orlando | Myron 615 222-1672 28-Dec-2006 501
10015 Ofrian Amy 8 713 442.3081, 22-Sep-2006 503
10016 Brown James 6 615 297-1228 25-Mar-2006 502
10017 Willams | George 615 290-2556 47-Jul-2008 503
10018 Farris Anne 3 113 362-7185 03-Dec-2006) 501
10019 Smth Olette K 615 297-3603 14-Mar-2006 503The Relational Model (continued) Ala
Relational diagram
Representation of relational database’s entities,
attributes within those entities, and relationships
between those entities
FIGURE
ae * _The Relational Model (continued)
* Rise to dominance due in part to its powerful
°
and flexible query language
Structured Query Language (SQL)
allows the user to specify what must be done
without specifying how it must be done
SQL-based relational database application
involves:
— User interface
—A set of tables stored in the database
— SQL engineRelational Database Model
+ Advantages
— Structural independence
— Improved conceptual simplicity
— Easier database design, implementation,
management, and use
— Ad hoc query capability with SQL
— Powerful database management systemRelational Database Model
* Disadvantages
— Substantial hardware and system software
overhead
— Poor design and implementation is made easyEntity Relationship Model
* Widely accepted and adapted graphical tool
for data modeling
* Introduced by Chen in 1976
* Graphical representation of entities and their
relationships in a database structureThe ER Model — Basic structural
Entity relationship diagram (ERD)
— Uses graphic representations to model database components
— Entity is mapped to a relational table
Entity instance (or occurrence)
is row in the relational table
Connectivity labels types of relationships
— Diamond connected to related entities through a relationship
line
Entity set is collection of like entities
Unfortunately, ERD designers use “entity” as a substitute for “entity set” and
we ‘ll conform to that established practice.FIGURE
2.5
A One-to-Many (1:M) Relationship: a PAINTER can paint many PAINTINGs;
each PAINTING is painted by one PAINTER.
1 M.
PAINTER pains > PAINTING
A Many-to-Many (M:N) Relationship: an EMPLOYEE can learn many SKILLs;
each SKILL can be learned by many EMPLOYEEs.
M N
EMPLOYEE <> SKILL
A One-to-One (1:1) Relationship: an EMPLOYEE manages one STORE;
each STORE is managed by one EMPLOYEE.
1 1
EMPLOYEE <>The Entity Relationship Model
FIGURE
2.6
A One-to-Many (1:M) Relationship: a PAINTER can paint many PAINTINGs;
each PAINTING is painted by one PAINTER.
PAINTER |
paints
He --2-- 4
A Many-to-Many (M:N) Relationship: an EMPLOYEE can learn many SKILLs;
each SKILL can be learned by many EMPLOYEEs.
EMPLOYEE SKILL
Lb pee a tet
A One-to-One (1:1) Relationship: an EMPLOYEE manages one STORE;
each STORE is managed by one EMPLOYEE.
EMPLOYEE STORE
mana
He -S=2- +41Relationships: The Basic Chen ERD v4
A One-to-Many (1:M) Relationship: a PAINTER can paint many PAINTINGs;
each PAINTING is painted by one PAINTER
1 M
} paneer pan
in EMPLOYEE can learn many SKILLs;
each SKILL can be learned by many EMPLOYEEs
A Many-to-Many (M:N) Relations!
M N
EMPLOYEE <<
A One-to-One (1:1) Relationship: an EMPLOYEE manages one STORE;
each STORE is managed by one EMPLOYEE
1 1
EMPLOYEE <> STORERelationships: The Basic Crow’s Foot ERD
FIGURE 2.7 RELATIONSHIPS: THE Basic CRow’s Foot ERD
‘A One-to-Many (1:M) Relationshi
PAINTER can paint many PAINTINGS;
‘each PAINTING is painted by one PAINTER
paints
PAINTER G PAINTING
‘A Many-to-Many (M:N) Relationship: an EMPLOYEE can learn many SKILLS;
‘each SKILL can be learned by many EMPLOYEES
earns
EMPLOYEE < SKILL
‘A One-to-One (1:1) Relationship: an EMPLOYEE manages one STORE;
‘each STORE is managed by one EMPLOYEE
manai
EMPLOYEE be STOREEntity Relationship Database Model
* Complements the relational data model concepts
* Represented in an entity relationship diagram
(ERD)
+ Based on entities, attributes, and relationships
1 M
PAINTER.
Semantic data model (SDM) developed by
Hammer and McLeod in 1981
The Object Oriented Model
Modeled both data and their relationships in
a single structure known as an object
Object-oriented data model OODM is the
basis for the object oriented database
management system (OODBMS)
OODM is said to be a semantic data model* An object is an abstraction of a real-world
entity
— Attributes describe properties of an object
Object-Oriented Database Model
— Objects that share similar characteristics are
grouped in class
— Classes are organized in a class hierarchy
— Inheritance is ability of object
to inherit attributes and methods of classes
above itThe Object Oriented Model (contin
FIGURE — A comparison of the OO model and the ER model
2.7
OO data model Soe!
INV_DATE
INV_NUMBER
generates
Na oes
INV_TOTAL
CUSTOMER
ails+ Extended Relational Data Model (ERDM)
— Semantic data model developed in response to
increasing complexity of applications
Other Models
— DBMS based on the ERDM often described as an
object/relational database management system
(O/RDBMS)
— Primarily geared to business applicationsDatabase Models and the Internet
+ Internet drastically changed role and scope of
database market
* OODM and ERDM-O/RDM
have taken a backseat to development of
databases that interface with Internet
* Dominance of Web has resulted in growing
need to manage unstructured informationData Models: A Summary
* Each new data model capitalized on the
shortcomings of previous models
* Common characteristics:
— Conceptual simplicity
without compromising the semantic
completeness of the database
— Represent the real world as closely as possibleFIGURE The development of data models
Data Models: A Summary
Semantics in
Data Model
Comments
least * Difficult to represent M:N relationships
(hierarchical only)
* Structural level dependency
* No ad hoc queries (record-at-a-time access)
* Access path predefined (navigational access)
+ Conceptual simplicity (structual independence)
* Provides ad hoc queries (SQU)
* Set-oriented access
* Easy to understand (more semantics)
ETS + Limited to conceptual modeling
(no implementation component)
*+ More semantics in data model
* Support for complex objects
+ Inheritance (class hierarchy)
a RL Cn ys benavion
bee era Teak) | * Unstructured data XML)
mostDegrees of Data Abstraction a
+ Way of classifying data models
« American National Standards Institute/Standards
Planning and Requirements Committee
(ANSI/SPARC)
— Classified data models according to their degree of
abstraction (1970s):
+ Conceptual
+ External
+ InternalDegrees of Data Abstraction
FIGURE
2.9)
End-User View End-User View
Degree of
Abstraction Characteristics
High > oR | Afardware-independent
KC software-independent
Hardware-independent
Software-dependent
Logical independence
Hardware-dependent
Software-dependent
Physical independence+ End users’ view of the data environment
The External Model
+ Requires that the modeler subdivide set of
requirements and constraints into
functional modules that can be examined
within the framework of their external
modelsThe External Model (continued
FIGURE
2.10
Student Registration
‘A student may take up to six
classes per registration.
Thi
isin
bide
LTE
‘A.class is limited to
35 students,
‘Class Scheduling
‘Aroom may be used to | ROOM
teach many classes,
Each class is taught in only one room,
Each class is taught by one professor.
‘A professor may teach
upto three classes..
.
The Conceptual Model
Represents global view of the entire
database
Representation of data as viewed by the
entire organization
Basis for identification and high-level
description of main data objects, avoiding
details
Most widely used conceptual model is the
entity relationship (ER) modelo
so
°
=
i)
=
2
a
®
o
c
3°
oO
®
=
Fe
FIGURE
2.11The Conceptual Model (continued)
+ Provides a relatively easily understood macro
level view of data environment
- Independent of both software and hardware
— Does not depend on the DBMS software used
to implement the model
— Does not depend on the hardware used in the
implementation of the model
— Changes in either hardware or DBMS software
have no effect on the database design at the
conceptual level
48The Internal Model
Representation of the database as
“seen” by the DBMS
Maps the conceptual model to the DBMS
Internal schema depicts a specific representation
of an internal model
Hardware Independent
Software Dependent (DBMS Dependent)
49The Internal Model
FIGURE
2.12
CONCEPTUAL MODEL _ || INTERNAL MODEL |
‘Create Table PROFESSOR(
PROF_ID NUMBER PRIMARY KEY,
PROF_LNAME CHAR(15),
PROF_INITIAL CHAR(1),
PROF_FNAME CHAR(15),
mp Create Table CLASS(
CLASS_ID NUMBER PRIMARY KEY,
6 for CRS_ID CHAR(8) REFERENCES COURSE,
PROF_ID NUMBER REFERENCES PROFESSOR,
ROOM_ID ‘CHAR(8) REFERENCES ROOM,
‘ger ‘Create Table ROOM(
ROOM_ID CHAR(8) PRIMARY KEY,
ROOM_TYPE CHAR(3),
d;
[eoonaa] se} Create Table COURSE,
CRS_ID CHAR(8) PRIMARY KEY,
CRS_NAME — CHAR(25),
CRS_CREDITS NUMBER,The Physical Model
+ Operates at lowest level of abstraction,
describing the way data are saved on storage
media such as disks or tapes
+ Software and hardware dependent
+ Requires that database designers have a detailed
knowledge of the hardware and software used to
implement database designLevels of Data Abstraction
Levels of Data Abstraction
OVE vt vat) Ae
aU
eT Tl Ender views Hardvare and software
C-
at gad aces mtd | Neier dren taeSummary
+ A good DBMS will perform poorly with a poorly
designed database
+ A data model is a (relatively) simple abstraction
of a complex real-world data-gathering
environment
* Basic data modeling components are:
— Entities
— Attributes
— RelationshipsSummary (continued)
« Hierarchical model
— Based on a tree structure composed of a root
segment, parent segments, and child segments
— Depicts a set of one-to-many (I:M) relationships
between a parent and its children
— Does not include ad hoc querying capabilitySummary (continued)
Network model attempts to deal with many of the
hierarchical model’s limitations
Relational model:
- Current database implementation standard
— Much simpler than hierarchical or network design
Object is basic modeling structure of object
oriented model
Data modeling requirements are a function of
different data views (global vs. local) and level of
data abstractionEntity Relationship Database Model
* Complements the relational data model concepts
« Represented in an entity relationship diagram (ERD)
+ Based on entities, attributes, and relationships
1 MEntity Relationship Database Model
Advantages
— Exceptional conceptual simplicity
— Visual representation
— Effective communication tool
— Integrated with the relational database model
Disadvantages
— Limited constraint representation
— Limited relationship representation
(relationships between attributes within entities cannot be
represented)
— No data manipulation language (DML)
— Loss of information contentOO Data Model
» Advantages
— Adds semantic content
— Visual presentation includes semantic content
— Database integrity
— Both structural and data independence
+ Disadvantages
— Lack of OODM standards
— Complex navigational data access
— Steep learning curve
— High system overhead slows transactionsDatabase Models and the Internet
* Characteristics of “Internet age” databases
— Flexible, efficient, and secure Internet access
— Easily used, developed, and supported
— Supports complex data types and relationships
— Seamless interfaces with multiple data sources and
structures
— Relative conceptual simplicity to make database design
and implementation less cumbersome
— Many database design, implementation, and application
development tools
— Powerful DBMS GUI make DBA job easierThe conceptual model represents a global view of the
data.
The Conceptual Model
It is an enterprise-wide representation of data as viewed
by
high-level managers.
¢ Entity-Relationship (E-R) model is the most widely used
conceptual model.
The conceptual model is_ software independence
hardware independence
602
A Conceptual Model for Tiny College =
PROFESSORAdvantages of Conceptual Model
+ Provides a relatively easily understood macro level view
of data environment
* Independent of both software and hardware
— Does not depend on the DBMS software used to implement
the model
— Does not depend on the hardware used in the
implementation of the model
— Changes in either the hardware or the DBMS software have
no effect on the database design at the conceptual levelRepresentation of the database as “seen” by the
DBMS
The Internal Model
¢ Once a specific DBMS has been selected,
the internal model adapts
the conceptual model to the DBMS.
The internal model is software-dependent
hardware-independence.
63y)
The External Model a
@ End users’ views of data environment
¢ Each external model is then represented by its own
external schema.
@ Provides subsets of internal view
@ Makes application program development easier
@ The external model is DBMS-dependent
hardware-independence.
* CREATE VIEW CLASS VIEW AS
SELECT (ctass_1p, CLASS_NAME, PROF_NAME, CLASS TIME, ROOM ID)
FROM CLASS, PROFESSOR, ROOM
WHERE CLASS.PROF_ID = PROFESSOR.PROF_ID AND
CLASS .ROOM_ID = ROOM.ROOM_ID;
64A Division of an Internal Model into External Models
Internal
External
Programmer Jim
eeThe External Models for Tiny College
Daten uneeeoeaen A student may take up to six classes
per registration.
A class Is limited to 35 students.
Class Scheduling
A room may be used to teach many classes.
Each class is taug!
Each class is taug!
in only one room.
by one professor.
A professor may teach up to three classes.The Physical Model
¢ The physical model operates at the lowest level of
abstraction, describing the way data is saved on storage
media such as disks or tapes.
@ Requires that database designers have a detailed knowledge
of the hardware and software used to implement database
design
@ The physical model is_ software-dependent
hardware-dependent.
67nw
Database Models
* Collection of logical constructs used to represent data
structure and data relationships within the database
— Conceptual models: logical nature of data representation
* focus on the logical nature of the data representation. They
are concerned with whatis represented
rather than howit is represented.
+ E.g. E-R model
— Implementation models: emphasis on how the data are
represented in the database
* place the emphasis on
how the data are represented in the database or on
how the data structures are implemented.
¢ E.g. relational database model