Professional Documents
Culture Documents
04 Ch4 HighLevelDatabaseModels
04 Ch4 HighLevelDatabaseModels
TO
DATABASE
L E A R N B Y E X A M P L E S
HIGH LEVEL
DATABASE MODEL
Objectives
Relational
Getting
High-Level Database Relational
User
Design Schema DBMS
Requirement
Design
of the business
Logical design is process of constructing a model of
information used in an enterprise based on a specific data
model, but independent of a particular DBMS or other
physical considerations
Physical design is process translating the logical
description of the data into technical specifications for
storing and retrieving data
Database Design Process
Model
A more recent trend is Unified Modeling Language
4.1 The Entity Relationship Model
Attributes
Relationships
8
The Entity Relationship Diagrams
I2DB: Design Theory for Relational Databases
name address
title year
Stars Stars-in
name Movies
address
Figure 4.2: An entity relationship diagram for the movie database
Multiplicity of Binary E/R
Relationships
A binary relationship can connect any member of one of its entity sets to any
I2DB: Design Theory for Relational Databases
relationships
Studios
Roles in Relationships
Original
Sequel-of Movies
Sequel
Roles in Relationships
Studio Producing
of star studio
Studios
Attributes on Relationships
length genre
Studios
name address
Attributes on Relationships
Salary
I2DB: Design Theory for Relational Databases
length genre
Studios
name address
Converting Multi-way
Relationships to Binary
Studio Producing
of star studio
Studios
Converting Multi-way
Relationships to Binary
Consider the Contracts relationship involves two studios, a star, a movie
I2DB: Design Theory for Relational Databases
Stars Movies
Studio Producing
of star studio
Studios
Subclasses in E/R Model
Voices Movies
Murder
Cartoons
Mysteries
Summary 4.1
Entity Sets
I2DB: Design Theory for Relational Databases
Attributes
Relationships
E/R Diagrams
Roles in Relationships
Subclasses in the E/R Model
I2DB: Design Theory for Relational Databases
DESIGN PRINCIPLES
Faithfulness
of the application
Entity sets and their attributes should reflect
reality
Faithfulness
should be
▪ a many-one relationship? When? Why?
What is redundancy?
I2DB: Design Theory for Relational Databases
and studios
Let studioName is an attribute of entity set
Movies
Is it good?
name studioName
Is it good?
Simplicity Counts
relationships
Do we use all possible relationships in our
model?
Choosing the Right Relationships
I2DB: Design Theory for Relational Databases
Salary
title year name addr
name addr
Picking the Right Kind of Element
following conditions:
It is more than the name of something; it has at least
Faithfulness
I2DB: Design Theory for Relational Databases
Avoiding redundancy
Simplicity counts
Choosing the right relationship
Picking the right kind of element
I2DB: Design Theory for Relational Databases
key attributes
Every entity set has key(s), one of them is
primary key
Representing Keys in the E/R
Model
I2DB: Design Theory for Relational Databases
name address
title year
Stars Stars-in
name Movies
address
Referential Integrity
and President
We say
Movies refers to Studios
another
Degree Constraints
stars?
>=10
Stars Stars-in Movies
length genre
Summary 4.3
Referential Integrity
Degree Constraints
I2DB: Design Theory for Relational Databases
R is a relationship from E to F
I2DB: Design Theory for Relational Databases
key attributes of F
Weak Entity Sets
Contracts salary
Studio-of Movie-of
Star-of
genre
year
length
name addr title
name addr
I2DB: Design Theory for Relational Databases
Stars Studios
Stars(name,address) Studios(name,address)
From E/R Relationships to
Relations
Stars-in(title,year,starName)
I2DB: Design Theory for Relational Databases
name Movies
Studio Producing
of star studio
Studios
Owns(title,year,studioName)
name Movies
Movies(title,year,length,genre,studioName)
address
Studios(name,address)
Crews(number,crewChief,studioName)
If W is a weak entity set, construct for W a relation whose schema consists of:
• All attributes of W
• For each supporting relationship for W, say a many-one relationship from W to entity set
E, all the key attributes of E
Rename attributes, if necessary, to avoid name conflicts
Do not construct a relation for any supporting relationship for W
I2DB: Design Theory for Relational Databases
SUBCLASS STRUCTURES TO
RELATIONS
Converting Subclass Structures
to Relations
Voices Movies
Murder
Cartoons
Mysteries
Converting Subclass Structures
to Relations
Voices Movies
Murder
Cartoons
Mysteries
Movies(title,year,length,genre)
MurderMysteries(title,year,weapon)
Cartoons(title,year) remove
Voices(title,year,starName)
An Object-Oriented Approach
I2DB: Design Theory for Relational Databases
Voices Movies
Murder
Cartoons
Mysteries
Movies(title,year,length,genre)
MoviesC(title,year,length,genre)
MoviesMM(title,year,length,genre,weapon)
MoviesCMM(title,year,length,genre,weapon)
Using Null Values
I2DB: Design Theory for Relational Databases
Voices Movies
Murder
Cartoons
Mysteries
Movie(title,year,length,genre,weapon)
Unified Modeling Language
Introduction
I2DB: Design Theory for Relational Databases
init()
modify()
Behavior
Associations
E/R UML
0..* 0..*
0..* 0..1
0..* 1..1
Self-Associations
Movies
Stars Stars-in title PK
0..* 0..*
name PK year PK
address length
genre
Compensation
salary
residuals
Subclasses in UML
Movies
title PK
year PK
length
genre
cert# PK
name
address
networth
Movies
title PK Studios Presidents
year PK 1..* name PK 0..1
0..1 address 1..1
length
genre
Classes to Relations
I2DB: Design Theory for Relational Databases
Associations to Relations
For each association, create a relation
▪ name is the name of that association
▪ attributes are the key attributes of the two connected classes
UML-to-Relations Basics
I2DB: Design Theory for Relational Databases
Studios
0..1
name PK
address Owns Movies
0..* title PK
year PK
Stars 0..* length
name PK 0..* Stars-in genre
address
Movies(title,year,length,genre) Stars-In(movieTitle,movieYear,starName)
Stars(name,address) Owns(movieTitle,movieYear,studioName)
Studios(name,address)
From UML Subclasses to
Relations
super-classes
Nulls: One relation, with NULL’s as needed
From Aggregations and
Composition to Relation
cert# PK
name
address
networth
Movies
title PK Studios President
year PK 1..* name PK 0..1
0..1 address 1..1
length
genre
MovieExecs(cert#,name,address,netWorth)
Presidents(cert#,studioName)
Movies(title,year,length,genre,studioName)
Studios(name,address)
The UML Analog of Weak Entity
Sets
Studios(name,address)
Crews(number,crewChief,studioName)
University DB
The coursework program lasts for 4 years, with 8 semesters. The subjects are
I2DB: Design Theory for Relational Databases
Student has grade report for each subject that he/she has joined. There are two
evaluation modes: grade theory and practicle grade in rating 50%-50%. One student
passes the course if grade theory is greater than 4.0 and total score is greater than 5.0.
Otherwise, student must take part in a retake exam for grade theory. Finally, he/she
must rejoin the course in the next chances.