Академический Документы
Профессиональный Документы
Культура Документы
2
What is a Database (DB) ?
Collection of related data
Represents some aspects of the real world
Data is logically coherent
Is provided for
Relational
Database Systems 1
Wolf-Tilo Balke
Joachim Selke Christoph Lofi
Institut fr Informationssysteme
Technische Universitt Braunschweig
www.ifis.cs.tu-bs.de
Exercise 1.2
Exercise 1.3
Example scenarios?
Selling tickets, managing a course of study,
Relational Database Systems 1 Wolf-Tilo Balke Institut fr Informationssysteme TU Braunschweig
Exercise 1.4
Exercise 1.5
1. What is redundancy?
Database administrators
Database designers
Application programmers
DBMS designers and implementers
Tool developers
Operators and maintenance personnel
End users (nave, sophisticated, casual)
Exercise 1.6
Exercise 1.6
Briefly define the following terms:
Data Model:
Declarative Querying
Specify what you want, not how and from where to get it
No need to know position of files etc.
No need to know implementation details
Integrity
Structure
Manipulation
View
Logical Schema
Conceptual Schema
Physical Schema
Data Modeling
1. Database Applications
Introduction
Basic ER Modeling
Chen notation
Alternative notations
App1
DBMS
Example
App2
App3
1. Database Applications
Requirements Engineering
Conceptional Design
Application Design
10
Miniworld
Information
Dependencies
Data modeling
Database design
Relational Database Systems 1 Wolf-Tilo Balke Institut fr Informationssysteme TU Braunschweig
DB2
1. Universe of Discourse
EN 3
EN 3
DB1
Things
11
Properties
Database
Operations
Facts
Relationships
12
1. Phases of DB Design
1. Phases of DB Design
Miniworld
Functional Requirements
Requirements
Analysis
Requirements Analysis
Database designers interview prospective users and
stakeholders
Data requirements describe what kind of data is
needed
Functional requirements describe the operations
performed on the data
this lecture
Data Requirements
Functional
Analysis
Conceptual
Design
High Level Transaction
Specification
DBMS independent
Conceptual Schema
Logical Design
DBMS dependent
Application
Program Design
Functional Analysis
Logical Schema
Physical Design
Transaction
Implementation
Internal Schema
Application Programs
EN 3
13
EN 3
1. Phases of DB Design
1. Phases of DB Design
Conceptual Design
The result of one phases serves as input for the next phase
Often, automatic transition is possible with some additional
designer feedback
Logical Design
Maps the conceptual data model to the logical data model used by
the DBMS
conceptual
design
Physical Design
ERdiagram
UML,
14
15
logical
design
physical
design
tables,
columns,
tablespaces,
Indexes,
2. ER Modeling
16
2. ER - Entities
Entities
17
EN 3.3
18
2. ER - Attributes
2. ER Entity Types
Attributes
simple or composite
single-valued or multi-valued
stored or derived
Example: name of a cat is simple, single-valued, and stored
EN 3.3
19
EN 3.3
2. ER Entity Sets
2. ER Diagrams
Cat may refer to the entity type as well as to the set of all
Cat entities (sometimes also plural for the set: Cats)
EntityType name
attribute n
21
EN 3.3
Simple Attribute:
Attribute composed of a single component with an independent
existence
Example: name of a cat, salary of an employee,
Entity Types
Written as: EntityName (attribute1, attribute2, )
Entity
Composite Attribute:
Example
Entity Set Cats
22
2. ER Composite Attributes
Textual Representation
2. ER Diagrams
Attributes
attribute 1
EN 3.3
20
name
Cat
color
(Fluffy, black-white)
(Snowflake, white)
(Captain Hook, red)
houseNo
Cat
name
Simple
Relational Database Systems 1 Wolf-Tilo Balke Institut fr Informationssysteme TU Braunschweig
street
23
EN 3.3
Company
address
Composite
ZIP
city
24
2. ER Derived Attributes
2. ER Multi-Valued Attributes
Stored Attribute
Single-Valued Attribute
Attribute holding a single value for each occurrence of an
entity type
Example: name of a cat, registrationNo. of a student
Derived Attribute
The attribute is (usually) not stored in the DB but derived
from an other, stored attribute
birth date
Cat
name
Student
phoneNo
Cat
name
Student
age
Single Valued
EN 3.3
Multi-Valued
Stored
25
EN 3.3
2. ER - Keys
Derived
26
2. ER - Keys
registration
Number
Student
name
year
Relational Database Systems 1 Wolf-Tilo Balke Institut fr Informationssysteme TU Braunschweig
27
2. ER Modeling
2. ER - Domains
firstName
isbn
author
lastName
Book
title
revision
no
year
EN 3.3
28
name
publisher
city
country
29
EN 3.3
30
2. ER - Domains
2. ER - Domains
Using data types for modeling domains is actually
a crutch
Syntax
description
integer
integer
double
double
numeric
numeric(p, s)
character
char(x)
varying character
varchar(x)
date
date
time
time
31
2. ER NULL Values
2. ER NULL Values
What does it mean when you encounter a NULLvalue?
So called NULL-value
EN 3.3
33
ER Relationships
name
Relationship set
34
ER Relationships
EN 3.4
32
EN 3.4
36
ER Relationships
ER Relationships
Example:
There is an ownership relation between
cats and persons
Person
Relationship Instance R1
Entity A1
Relationship Set R
A
A2
A1
A3
R2
B3
A5
A6
B2
A4
B4
R3
37
EN 3.4
ER Relationship Cardinality
38
ER Relationship Cardinality
Cardinality annotations
One cardinality annotation per entity type / relationship end
Minimum and maximum constrains
possible
cardinality
Person
married
to
EN 3.4
40
ER Relationships
ER Relationship Cardinality
Cat
Entity Set B
B1
R1
owns
(1, 2)
r
(0, 1)
A
(1, 2)
r
A2
A1
B1
R1
A3
B2
A4
A6
R2
A5
R3
B3
R4
Relational Database Systems 1 Wolf-Tilo Balke Institut fr Informationssysteme TU Braunschweig
41
42
ER Relationships
ER Relationship Cardinality
Example:
Person
married
to
Person
married
to
Person
P2
P1
P6
43
P5
R2
ER Relationship Cardinality
44
ER Relationship Cardinality
Example:
Example:
R1
P4
married
to
P3
(1, 4)
owns
Cat
super
vises
supervises
(0, 1)
EN 3.4
45
46
ER Relationship Roles
ER Relationship Cardinality
Cardinalities for binary relationship types can be
classified into common, more general cardinality
types
EN 3.4
47
Person
(0, 1)
(0, *)
super
vises
(0, *) supervisor
supervisee
super
vises
48
ER Relationship Degree
ER Relationship Attributes
works
for
Person
owns
Cat
Customer
supplies
Company
Part
Relational Database Systems 1 Wolf-Tilo Balke Institut fr Informationssysteme TU Braunschweig
49
ER Total Participation
ER Weak Entities
owns
Drivers
License
50
51
EN 3.5
52
ER Weak Entities
ER Weak Entities
Weak entity types and identifying relationship types
are depicted by double-lined rectangles
Example:
(0,*)
orderNo
Order
is part
of
(1,1)
OrderItem
itemLine
53
EN 3.5
54
ER Overview
Entity Type
Weak Entity Type
Attribute
Key Attribute
Multi-valued Attribute
Composite Attribute
Derived Attribute
Relationship Type
Identifying Rel. Type
ER Overview
Total participation of E2 in R
Name
Name
E1
name
name
E1
name
name
name
55
EN 3.5
E2
56
57
EN 3.5
58
Entity Types
EN 3.5
E2
name
ER Alternative Notations
Book
name
EN 3.5
E2
name
E1
EN 3.5
Cardinality
name
lastName
title
Book
* isbn
author
firstName
lastName
title
59
EN 3.5
60
(1, *)
Person
owns
owns
Person
Problem
Cat
Cat
Workaround solution:
What happens to n-ary relationships or
relationship attributes?
number
Supplier
supplies
Costumer
*
Part
EN 3.5
Ra
B
61
RB
Rc
62
number
Supplier
supplies
Customer
*
Part
Supplier
provides
Supplies
number
Customer
contains
Part
EN 3.5
63
64
Barkers notation
ternary
65
1
1
66
2. ER Mathematical Model
2. ER Mathematical Model
R E1 E2 , En
EN 3.3
67
An example
68
An example
70
An example
An example
EN 3.3
71
Student
Lecture
Professor
72
An example
registration
number
title
registration
number
credits
id
Student
An example
Professor
Lecture
title
credits
id
id
Lecture
Student
Professor
prereq.
course of
study
name
course of
study
prerequisite
lecture
part of
name
name
Course of
Study
curriculum
semester
name
First try
Each year, some lectures of the pool of all lectures are offered by a
professor at a certain day at a fixed time in a specific room.
Students may attend that lecture.
An example
room
day of
week
time
registration
number
semester
attends
Student
Professor
Lecture
Not really
intuitive
Use an intermediate
entity instead?
curriculum
semester
Course of
Study
name
An example
day of
week
room
Lecture
instance
attends
curriculum
semester
Course of
Study
Better?
Add cardinalities
Add total and
identifying annotations
name
76
Professor
teaches
instantiates
title
prereq.
id
1
name
Lecture
An example
semester
department
part of
75
time
name
credits
id
enrolls
part of
Professor
teaches
instantiates
title
prereq.
id
department
credits
id
enrolls
semester
name
name
room
Lecture
instance
attends
instanciates
title
day of
week
time
registration
number
id
teaches
instanciate
name
74
An example
Student
name
registration
number
department
Second try
Student
name
curriculum
semester
enrolls
department
name
department
credits
N
id
enrolls
Lecture
N
Student
+registrationNumber
name
prereq.
part of
curriculum
semester
Course of
Study
Better?
Add cardinalities
attends
Lecture Instance
teaches
time
dayOfWeek
room
semester
Professor
+id
name
department
enrolls
instanciates
CourseOfStudy has
name
+name
PartOf
curriculumSemester
has
Lecture
+id
title
credits
hasPrerequisite
77
78
An example
Modeling is not that simple
Many possible (and also correct) ways of
modeling the same miniworld
Some are more elegant, some are less elegant
79