Chapter 4. Database System Architecture & Modeling
Chapter 4. Database System Architecture & Modeling
1 of 42
Objectives
• Identify and describe important entities and
relationships to model data
• Develop data models to represent, organize,
and store data
• Design and use relational databases to organize,
store, and manipulate data
2 of 42
Data Models
A collection of tools for describing
data
data relationships
data semantics
data constraints
Entity-Relationship model
Relational model
Other models:
object-oriented model
semi-structured data models
Older models: network model and hierarchical
model
Entity-Relationship Model
Example of schema in the entity-relationship model
Entity Relationship Model (Cont.)
E-R model of real world
Entities (objects)
Mappings
Conceptual Schema
Mapping
Physical Schema
Database
Database Independence
New data
Database New storage techniques
user’s view
College
Department Infrastructure
Store
Order Items
Advantage & Disadvantage
Advantage
• Its concept is as simple as the hierarchical model.
• There is more than one parent/child relationship
• Data can be accessed easily in it
• It provides data integrity
• It contains data definition language (DDL) and data
manipulation language (DML)
Disadvantage
• Its database structure is very complex (difficult) b/c all the
records in it are maintained using pointers
• Changes in its structure require changes in all programs
Relational Database Model
Student
Roll no Name Mobile no
1 Abel +251925251…
2 Robel +25191825…
3 Jemal +25191025…
Customer
ID Balance
Customer
Number Balance
Name
Customer
Street City Date
Customer Customer
Account Account
Database Modeling
Data Modeling Terms
• Entity – a class of real world objects having
common attributes (e.g., sites, variables, methods).
• Attribute – A characteristic or property of an entity
(site name, latitude, longitude)
• Relationship – an association between two or
more entities
• Cardinality – the number of entities on either end
of a relationship (one-to-one, one-to-many, many-
to-many, etc.)
28 of 42
Data Modeling Exercise
• Consider:
– What is the “entity”?
– What are the “attributes”
of the entity?
29 of 42
Data Modeling Exercise
• What is the entity?
• What are the attributes?
30 of 42
Data Modeling Exercise
• What is the entity?
• What are the attributes?
31 of 42
Data Modeling Exercise
• What are the relationships?
Grows In
Grows On
32 of 42
What about the business rules?
Data Model Requirements
• What is the information/data domain that you
are modeling?
• What are the 20 queries that you want to do?
– e.g., “Give me simultaneous observations of
turbidity and TSS collected during the spring
snowmelt period so I can develop a regression in R.”
• What software do you want (have) to use?
• How do you want to share the data?
33 of 42
Data Model Design
• Our focus – relational data model
design
• Three stages:
– Conceptual data model
– Logical data model
– Physical data model
34 of 42
Conceptual Data Model
(The Information Model)
• High-level description of the data domain
• Does not constrain how that description is
mapped to an actual implementation in
software
• There may be many mappings
– Relational database
– Object model
– XML schema, etc.
35 of 42
Apple/Tree/Orchard Conceptual Model
Grows In
Grows On
36 of 42
Defining Entities and Relationships
• Instead of beginning with this:
Site
1
*
TimeSeries
1
Observations
*
38 of 42
Example: ODM Logical Data Model ER Diagram
39 of 42
Entity Relationship Diagram
• Documentation of the structure of the data
• Used to communicate the design
• Serve as the basis for data model
implementation
40 of 42
Entity Relationship Diagram
(Relation Database Context)
41 of 42
ER Diagram Entity Notation
Entity Name
42 of 42
Entity
ER Diagram Relationship Notation
• Multiple notation systems are used
• Each software program is a little different
• Most common is “Crows Foot”
Crows Foot Alternative
0 .. *
1 .. *
1 .. 1
0 .. 1
43 of 42
Relationship Cardinality and Participation
44 of 42
Cardinality
• Maximum number of times an instance of an entity can
be associated with instances of a related entity
• Can ONLY have values of 1 or many
• Located closest to the entity in Crows Foot notation
45 of 42
Participation
• Minimum number of times an instance in one entity can be
associated with instances in the related entity
• Indicates whether an instance of an entity MUST participate in
the relationship
• Can ONLY have the values of 0 or 1
46 of 42
Mapping Cardinality and Participation
A3 R3 T2
A4 R4
T3
A5 R5
A6 R6
47 of 42
Reading Cardinality and Participation
48 of 42
Relationship Examples
49 of 42
Relationship Examples
50 of 42
Primary and Foreign Keys
• Each row in a table should have an attribute that is a
persistent, unique identifier – the “Primary Key”
• Primary key in “parent” table
• Foreign key in “child” table
51 of 42
Primary and Foreign Key Example
OrchardID OwnerName Area_acres
1 John Appleseed 5.5 Orchards
2 Daryl Appleseed 15
3 Honeycrisp 3 4/15/2010 1
AppleID Color Weight AppleTreeID
1 Green 200 2
2 Green 180 2 Apples
3 Green 195 2
52 of 42
Primary and Foreign Keys
• Usually consist of integer values
• MUST be the same data type in parent and child
tables
53 of 42
Creating an ER Diagram Using
MySQL Workbench
54 of 42
Summary
• Data model design is a 3 step process –
conceptual, logical, physical
• Conceptual and logical data models can be
expressed using Entity Relationship (ER)
diagrams
• ER diagrams capture the entities, attributes, and
relationships to model your information domain
• ER diagrams are a powerful way to document the
design of your data model
55 of 42
Steps in Data Model Design
1. Identify entities
2. Identify relationships among entities
3. Determine the cardinality and participation of
relationships
4. Designate keys / identifiers for entities
5. List attributes of entities
6. Identify constraints and business rules
56 of 42
Exercise
• Work alone or in groups of 2-3
• Use MySQL Workbench to begin creating an
Entity Relationship diagram
– Identify entities
– Specify attributes
– Create relationships
57 of 42