Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
as
Anwendungssoftware
Introduction to
Database and Information Systems
Anwendersoftware (AS)
as
Anwendungssoftware
IPVS, University of Stuttgart
nicklas@ipvs.uni-stuttgart.de
1
Motivation Anwendersoftware (AS)
HT
Goals
ML
ERM Document Object Model
UML Modelling of
Data and processes L
Rational Rose XM
STE
bjects P/ E
ess O XPR
Busin
Vi
E SS
su
DB
a
Information Systems
lB
Doc O
eb
BPEL Open
as
R3 Workflow Management RB
iW
Visual Age
ic
IX
.Net A
RB E
DCOM CO OL Middleware
Component Ware
Ac OMG Standards
tiv
dio eX
Stu Transaction
OBDC
u al
Vis rise Processing
erp s JDBC Xopen/DCF
Oracle VB Ent aBean TP Monitors
Ja v
ys
Universal Storage Encina wa
CICS edo te
SQL3 Informix Tux Ga
Dynamic Server Java Universal Access
Syb
ase
Ad IBM DataJoiner SQLJ
ab
as DataLinks
DB2 V8
Object-Relational
Database Technology
Information Integrator
Goals
2
Motivation Anwendersoftware (AS)
Goals
new amount :=
new amount := amount-$250
amount-$100 6
3
Motivation Anwendersoftware (AS)
• DBMS Implementation
Data Models
70%
object-oriented models (OODBMS) 60%
30%
since ~2000: RDBMS/ORDBMS 20%
semistructured data OODBMS
10%
and XML CODASYL
Hierarchical DBMS 0%
Flat Files 1990 1995 2000
4
Motivation Anwendersoftware (AS)
5
Motivation Anwendersoftware (AS)
• Constructors
11
• Notion of Model
Given set of language features to describe an universe of
discourse
Æprogramming languages and operating systems have a data
model as well
12
6
Motivation Anwendersoftware (AS)
Databases? (1)
13
Databases? (2)
customer
management
• Openness to New Applications
Symmetric structuring transfers
ATM
Explicit constraints
Single and neutral representation ?
14
7
Motivation Anwendersoftware (AS)
Databases? (3)
• Fault Tolerance
Logging of redundant data during normal operations
Automatic repair (recovery) of data structures after program
failure, system failure, or media failure
- Undo of not finished transactions
- Redo of the effect of completed (committed) transactions
• Multi User Operation
Simultaneous (concurrent) access of different users to the same
data
Synchronization
15
1 http:// www.lesk.com/mlesk/ksg97/ksg.html
21 Gigabyte (GByte) = 1,000 Megabytes = 109 Bytes
1 Terabyte (TByte) = 1,000 Gigabytes
1 Petabyte (PByte) = 1,000 Terabytes
1 Exabyte (EByte) = 1,000 Petabytes
16
8
Motivation Anwendersoftware (AS)
17
Lecture Overview
• URI:
http://www.ipvs.uni-stuttgart.de/abteilungen/as/start/en
Æ Courses Æ Database and Information Systems
• Contents:
Chap. 1: Introduction
Chap. 2: Realization of Information Systems
Chap. 3: Information Models and Data Models (Exercise E.1)
Chap. 4: Relational Model
Chap. 5: Relational Algebra (Exercise E.2)
Chap. 6: SQL (Exercise E.3, E.4)
Chap. 7: SQL Programming
Chap. 8: Logical Database design (Exercise E.5)
18
9
Motivation Anwendersoftware (AS)
Exercises
(Nazario Cipriani / Daniela Nicklas)
• Work can be done in groups of 1-3 students
• Grading of exercises:
you explain your solution and get bonuses for the final exam
• Tutoring:
We are present in the seminar room or computer lab
You can work there and ask questions
• Tutoring/Gradings:
16.5.2007
13.6.2007
20.6.2007
27.6.2007
4.7.2007
18.7.2007
20
10
Anwendersoftware (AS)
as
Anwendungssoftware
Chapter 1: Introduction
1
Introduction Anwendersoftware (AS)
application
database
system
CIS
operating
system
hardware
DBS = DB + DBMS
2
Introduction Anwendersoftware (AS)
3
Introduction Anwendersoftware (AS)
Operational Level:
• Enhancement of processes by usage of query systems,
report systems, reservation systems, production systems and
all their applications (enterprise resource planning, ERP)
• Characteristics:
huge amounts of data
high update probability
Strategic Level:
• Data provision for mostly unpredictable information needs
8
4
Introduction Anwendersoftware (AS)
Typical queries ask for flights leaving about a certain time from one given city to
another, what seats are available, and at what prices.
Typical data modifications include the booking of a flight for a customer, assigning
a seat, or indicating a meal preference.
Many agents will be accessing parts of the data at any given time.
The DBMS must allow such concurrent accesses, prevent problems such as two
agents assigning the same seat simultaneously, and protect against loss of records
if the system suddenly fails.
10
5
Introduction Anwendersoftware (AS)
• Typical queries:
• Access requirements:
11
Data items include names and addresses of customers, accounts, loans, and their
balances, and the connection between customers and their accounts and loans
e.g., who has signature authority over which accounts. Queries for account
balances are common, but far more common are modifications representing a
single payment from or deposit to an account.
As with the airline reservation system, we expect that many tellers and customers
(through ATM machines) will be querying and modifying the bank’s data at once.
It is vital that simultaneous accesses to an account not cause the effect of an
ATM transaction to be lost. Failures cannot be tolerated. For example, once the
money has been ejected from an ATM machine, the bank must record the debit,
even if the power immediately fails. On the other hand it is not permissible for the
bank to record the debit and then not deliver the money because the power fails.
The proper way to handle this operation is far from obvious and can be regarded
as one of the significant achievements of DBMS technology.
12
6
Introduction Anwendersoftware (AS)
13
14
7
Introduction Anwendersoftware (AS)
15
16
8
Introduction Anwendersoftware (AS)
17
• Search Methods
Character or value comparison:
(FUNCTION = ‘ADMINISTRATOR’) AND (AGE > 60)
Exact match query:
find/select exactly all records with the specified property
Search for synonyms, fuzzy search, ...Æ no support
Natural language support, recognition of ambiguities
Æ no support in formatted DBS (see Information Retrieval Systems)
18
9
Introduction Anwendersoftware (AS)
Example
Schema Faculty FNBR FNAME DEAN
Student MATRNR SNAME FNBR BEGIN
Examination PNR MATRNR SUBJECT DATE MARK
Professor PNR NAME FNBR
Schema
FACULTY
Example
FNBR FNAME DEAN
Q1: Find all students, who belong to F5
STUDENT MATRNR SNAME FNBR BEGIN and had started studying before
EXAMINATION PNR MATNR SUBJECT DATUM MARK
1995.
PROFESSOR PNR NAME FBNR SELECT *
Instance (state) FROM STUDENT
FACULTY FNBR FNAME DEAN WHERE FNBR=’F5’ AND BEGIN<’1.1.95’
F9 BUSINESS ADMIN. 4711
F5 COMPUTER SCIENCE 2223
123 766 COY F9 1.10.95 Q2: Find all students, who belong to F5
225 332 MILLER F5 15. 4.87 and passed the examination in
654 711 TAYLOR F5 15.10.94 database and information systems
226 302 CANETTI F9 1.10.95
with 2 or better
196 481 BERNSTEIN F5 23.10.95
20
10
Introduction Anwendersoftware (AS)
21
22
11
Introduction Anwendersoftware (AS)
Information Pyramid
Transactions
• Business Transaction
An interaction in the real world, usually between an enterprise and a
person, where something is exchanged.
• (On-line) Transaction
The execution of a program that performs some functions of a
business transaction by accessing a shared database, usually on
behalf of an online user. (P. Bernstein, E. Newcomer: Transaction Processing, 1997)
A transaction is a collection of operations on the physical and abstract
application state. (J. Gray, A. Reuter: Transaction Processing, 1993)
24
12
Introduction Anwendersoftware (AS)
ACID Properties
• Atomicity
A transaction's changes to the state are atomic; either all happen or none
happen. These changes include database changes, messages, and actions on
transducers.
• Consistency
A transaction is a correct transformation of the state. The actions taken as a
group do not violate any of the integrity constraints associated with the state.
This requires that the transaction be a correct program.
• Isolation
Even though transactions execute concurrently, it appears to each
transaction, T, that others either execute before T of after T, but not both.
• Durability
Once a transaction completes successfully (commits), it’s changes to the state
survive failures.
• Three Aspects:
A transaction executes the activity in our reality or mini world
within a computing system. Such an activity typically represents
a non-trivial step (unit of work) in a business activity.
26
13
Introduction Anwendersoftware (AS)
• Examples:
Money transfer
Seat reservation
Order processing
Processing telephone calls
etc.
27
28
14
Introduction Anwendersoftware (AS)
• Overview
29
30
15
Introduction Anwendersoftware (AS)
31
32
16
Introduction Anwendersoftware (AS)
33
34
17
Introduction Anwendersoftware (AS)
Reports
Enterprise
Data
Warehouse
OLAP
Data
Mining
35
source
• The retail company runs several database systems that capture all the operational
data:
one point-of-sale (POS) database per department store
one supplier database per country
...
• Broad range of data sources:
Database systems (relational, object-relational, hierarchical, …)
External information sources (other companies, surveys, …)
Files of standard applications (Excel, …)
Other documents (Word, WWW, …)
36
18
Introduction Anwendersoftware (AS)
revenue revenue
Clustering
age
age
#children 37
38
19
Introduction Anwendersoftware (AS)
Business Applications
• Each object is represented by exactly one tuple instance that
contains all descriptive attributes
39
CAD Application
• A complex object “product (under design)“ consists (or is
assembled) of simpler (complex) objects, each perhaps
showing a different type.
40
20
Introduction Anwendersoftware (AS)
41
42
21
Introduction Anwendersoftware (AS)
43
44
22
Introduction Anwendersoftware (AS)
• Tasks / Properties
Management of documents, books, abstracts etc.
Efficient search in voluminous datasets
Typically only retrieval in multi-user environments
• Data Structures
Unformatted (perhaps semi-formatted text data)
Ambiguity: synonym and homonym problem
Usage of a so-called thesaurus (complex organized dictionary):
consists of relationships among (technical) terms in the
dictionary used for document indexing
45
• Interface to IRS
No formal data model
Retrieval language only
Æ close to natural language
• Search
Queries are mostly fuzzy
Nearest neighbor, best match, pattern matching, ...
Result assessment via precision and recall
• Usages
Libraries
Literature inquiries (perhaps via Internet)
Information services (chemical sciences, etc.)
Patent information systems
46
23
Introduction Anwendersoftware (AS)
47
Summary
48
24
Anwendersoftware (AS)
as
Anwendungssoftware
Chapter 2
Realization of Information Systems
• DBS Requirements
Operational Data Control
System Enforced Integrity
Ease of Use
High Degree of Data Independence
Efficiency
• DBS Architecture
Historical Evolution
Five-layer Model
Three-Schema Architecture (ANSI/SPARC Architecture)
Dynamic System Behavior
Application Programming Interfaces
1
Chapter 2: Realization of Database Systems Anwendersoftware (AS)
C
I
D
2
Chapter 2: Realization of Database Systems Anwendersoftware (AS)
• Security problems
not everybody should be able to access everything
• Lack of Isolation between Data Structure and Program
Structure
• Need to Solve Same Tasks in All Application Programs
Storage management
Data management
Update service (change service)
Retrieval
Security and access control
• Assumption:
Everything remains stable!
Nothing can go wrong!
6
3
Chapter 2: Realization of Database Systems Anwendersoftware (AS)
Data Independence
data management
application program
system as part of
file structure
operation systems
application program
the „ideal“ DBS, that
database
provides application-
oriented interfaces
4
Chapter 2: Realization of Database Systems Anwendersoftware (AS)
10
5
Chapter 2: Realization of Database Systems Anwendersoftware (AS)
11
12
6
Chapter 2: Realization of Database Systems Anwendersoftware (AS)
Data Abstraction
• View level
parts of database view level
simplier structures view 1 view 2 view 3
application dependent
• Logical level
logical
what data are stored in the database level
relationships between those data
used by database administrator
• Physical level physical
how the data is actually stored level
13
14
7
Chapter 2: Realization of Database Systems Anwendersoftware (AS)
DARMSTADT
FRANKFURT
NEU-ISENBURG
15
ISN
406 3 COY 9 DARMSTADT K55
5561
f3 v . char v . char f3
num char
CHAIN POINTER-ARRAY
8
Chapter 2: Realization of Database Systems Anwendersoftware (AS)
MD2, C127, S1
CHAIN POINTER-ARRAY
• Efficient Access
A DBS problem, no application problem
Query optimization
DBA determines access paths /ideally automatically through DBMS
• Performance Trade-off
Tight coupling Î fast access
But low isolation and stability of programs
Î high maintenance costs on update
Therefore: less tight coupling of programs to data
Î slower access, if not optimized the right way!
18
9
Chapter 2: Realization of Database Systems Anwendersoftware (AS)
• DBS Requirements
Operational Data Control
System Enforced Integrity
Ease of Use
High Degree of Data Independence
Efficiency
• DBS Architecture
Historical Evolution
Five-layer Model
Three-Schema Architecture (ANSI/SPARC Architecture)
Dynamic System Behavior
Application Programming Interfaces
19
DBMS Structure
ORDBS
20
10
Chapter 2: Realization of Database Systems Anwendersoftware (AS)
21
• “Uses”-Relation:
A uses B, if A calls B and the correct and successful execution of B is necessary
to execute A completely.
22
11
Chapter 2: Realization of Database Systems Anwendersoftware (AS)
23
• Abstraction Hierarchy
Hide some properties of an abstract machine from higher-layer
machines
The implementation of higher-level operations extends the
functionality of an abstract machine
12
Chapter 2: Realization of Database Systems Anwendersoftware (AS)
25
26
13
Chapter 2: Realization of Database Systems Anwendersoftware (AS)
tuple-oriented interface:
external FIND NEXT data dictionary transaction logical
records, index <name record> currency concept management access
and STORE sorting paths
set structures <name record> component
device interface:
cylinders, channel hardware
external storage
sectors, programs
media
tracks
28
14
Chapter 2: Realization of Database Systems Anwendersoftware (AS)
Three-Schema Architecture
• ANSI/SPARC Architecture
29
15
Chapter 2: Realization of Database Systems Anwendersoftware (AS)
Reduction of complexity:
only the data of interest is
visible to the application
program 31
ANSI/SPARC-Model
• Description Levels for Database Applications
32
16
Chapter 2: Realization of Database Systems Anwendersoftware (AS)
33
34
17
Chapter 2: Realization of Database Systems Anwendersoftware (AS)
2.) Complete the information using the conceptional and internal schema;
Locate pages# (e.g., with hashing): P789
35
P789 ...
36
18
Chapter 2: Realization of Database Systems Anwendersoftware (AS)
partly in DB
in database
Joining Data language, partly in host language
language
in host language
38
19
Chapter 2: Realization of Database Systems Anwendersoftware (AS)
Summary
• DBS Characteristics
Centralized control of operational data (role of DBA)
Centralized control of data integrity and multi-user capabilities
Support of adequate interfaces (data model and database
language)
High degree of data independence
Efficiency!!!
• Three-schema Architecture
External schema
Conceptional schema
Internal schema
39
Summary
40
20
Anwendersoftware (AS)
as
Anwendungssoftware
• Introduction
• Entity-Relationship Model (ERM)
Concepts, Definitions, Notations
Relationship Set, Entity Set
Diagrammatic Representation, Graphical Notation
Examples
• Extended ERM Features, Enhanced-ER Model Concepts
Mapping Constraints
Abstraction Concepts
- Generalization/Specialization
- Aggregation
- Association
- Integrated View
1
Information Modeling Anwendersoftware (AS)
modeling
A
I modeling I
realization
query
M transaction M'
2
Information Modeling Anwendersoftware (AS)
• A database stores information about some part of the real world („mini
world“/Universe of Discourse (UoD)):
Information Models
• Information Model
3
Information Modeling Anwendersoftware (AS)
• interview • ERM
• hierarchical
• noun analysis • NIAM
• network-like
• brainstorming • EXPRESS-G
• relational • DB2
• document analysis • IDEF1X
• object-oriented • Informix
• STEP
• ... • ORACLE
• ... • UML
• XML • Postgres
• ...
• mySQL
DBMS independent DBMS dependent • ...
conceptional DB logical physical
schema design schema design schema design
4
Information Modeling Anwendersoftware (AS)
• Concepts
Chen, P. P.-S.: The Entity-Relationship Model
Entity sets — Toward a Unified View of Data,
in: ACM TODS 1:1, March 1976, pp. 9-36.
Relationship sets
Attributes
Value sets (domains)
Primary keys
• Classification of Relationship Types
User defined relationships
Mapping type / mapping cardinalities
- 1 : 1 (one-to-one)
- n : 1 (many-to-one)
- n : m (many-to-many)
• GOAL:
Determination of semantic aspects
Explicit definition of structural integrity constraints
5
Information Modeling Anwendersoftware (AS)
• Entity: "A thing that has real or individual existence in reality or in mind“
(Webster)
• An entity set is a set of entities of the same type that share the same
properties.
Example: set of all persons, companies, trees, holidays
6
Information Modeling Anwendersoftware (AS)
• The entity sets that participate in a relationship set Ri do not have to be disjoint
MARRIAGE
• The role name (r n) signifies the role that a participating entity from the entity set
(entity type) plays in each relationship instance (order!)
rn1/e1, rn2/e2
7
Information Modeling Anwendersoftware (AS)
• Attribute Types
Simple and composite attributes:
CNBR ADDRESS
Single-valued and multi-valued attributes:
COLOR_OF_CAR
Null attributes: the value of an attribute is not applicable or it is
unknown
- i.e., it exists but is missing or it is not known whether the attribute value
exists
- e.g., private phone number) A(e) = {}
Derived attributes: in some cases two or more attribute values are
related
AGE and BIRTHDATE
8
Information Modeling Anwendersoftware (AS)
• The values of the primary key attribute(s) can be used to identify each
entity uniquely
(1:1) - one-to-one relationship
Sometimes it has to be created artificially (serial number)
9
Information Modeling Anwendersoftware (AS)
• Let {A1, A2, ..., Am} = A be a set of attributes for the entity set E
• Although several candidate keys may exist, one of the candidate keys is
selected to be primary key
F1 (ENR)
e1 0007
e2 4711
e3 0042
10
Information Modeling Anwendersoftware (AS)
11
Information Modeling Anwendersoftware (AS)
12
Information Modeling Anwendersoftware (AS)
Design Issues
13
Information Modeling Anwendersoftware (AS)
Mapping Cardinalities
• Express the number of entities to which another entity can be associated via a
relationship set.
• Most useful in describing binary relationship sets.
• For a binary relationship set the mapping cardinality must be one of the following
types;
One-to-one
One-to-many
Many-to-one
Many-to-many
• We distinguish among these types by drawing either a directed line (―>),
signifying “one”, or an undirected line (―), signifying “many”, between the
relationship set and the entity set (optional!).
14
Information Modeling Anwendersoftware (AS)
15
Information Modeling Anwendersoftware (AS)
• Introduction
• Entity-Relationship Model (ERM)
Concepts, Definitions, Notations
Relationship Set, Entity Set
Diagrammatic Representation, Graphical Notation
Examples
• Extended ERM Features, Enhanced-ER Model Concepts
Mapping Constraints
Abstraction Concepts
- Generalization/Specialization
- Aggregation
- Association
- Integrated View
mapping cardinality
1 N
one-to-many: E1 R E2
16
Information Modeling Anwendersoftware (AS)
Examples of ER Diagrams
entity sets relationship sets entity sets
staff project
emp works_on project
N M
wife
person 1
1 marriage
husband
M works_on N
emp project
project
1 manager N
Entity-Relationship-Model
Information Modeling Anwendersoftware (AS)
Nested Attributes
Name City
Buch
17
Information Modeling Anwendersoftware (AS)
part
supplier M N
supply project
M M
supply get
N N
part
• Introduction
• Entity-Relationship Model (ERM)
Concepts, Definitions, Notations
Relationship Set, Entity Set
Diagrammatic Representation, Graphical Notation
Examples
• Extended ERM Features, Enhanced-ER Model Concepts
Mapping Constraints
Abstraction Concepts
- Generalization/Specialization
- Aggregation
- Association
- Integrated View
18
Information Modeling Anwendersoftware (AS)
ERM Limitations
• Up to now:
Mapping cardinalities are specified only coarse
- one-to-one, one-to-many, many-to-many
Only the type-level is represented
- no instances/data
Inadequate modeling of overlapping entity sets
- e.g. Car and Taxi
Only relationships between entity sets
- not between entities
Only user-defined relationships
- no standardization of often used relationships
ERM Requirements
CAR TAXI CAR
Is_a
io io
TAXI
CAR
io
instance-of (io):
CAR
19
Information Modeling Anwendersoftware (AS)
the cardinality restriction card(R,Ei) = [min,max] defines that each entity from the
entity set Ei participates in at least min and at most max relationship instances of
relationship set R
cardinality
restructions:
e1 participates in [min1, max1] relationship instances of relationship type R
e2 participates in [min2, max2] relationship instances of relationship type R
• Examples
R E1 E2 card(R, E1) card(R, E2)
head_of_department DEPARTM EMPLOYEE
marriage WOMAN MAN
20
Information Modeling Anwendersoftware (AS)
• Introduction
• Entity-Relationship Model (ERM)
Concepts, Definitions, Notations
Relationship Set, Entity Set
Diagrammatic Representation, Graphical Notation
Examples
• Extended ERM Features, Enhanced-ER Model Concepts
Mapping Constraints
Abstraction Concepts
- Generalization/Specialization
- Aggregation
- Association
- Integrated View
• GOAL:
Modeling of additional semantics of the miniworld with the (enhanced)
ERM
21
Information Modeling Anwendersoftware (AS)
• TASK:
Identification of essential constructs that are applied by a human to
describe his/her universe of discourse.
Î use of abstraction to organize the information
Î abstraction permits someone to suppress specific details of particular objects
emphasizing those pertinent to the actual view
• Consequences
Adequate and accurate modeling: one-to-one mapping between mini
world and object model
All relevant things in our mini world are objects of the ERM (objects
that describe other objects, too)
Î entity sets (classes) and entities (instances) are independent objects in
the model
Î operations cannot distinguish between classes and instances
• Object Properties
Objects are either
simple (i.e., defined completely by itself) or
composite (i.e., described as an “abstraction” of other objects)
22
Information Modeling Anwendersoftware (AS)
Classification
23
Information Modeling Anwendersoftware (AS)
Instantiation
• Instantiation is the inverse operation of classification
• Used to obtain instances/objects that conform to the constraints associated with
the properties specified by the class
Same structure (attributes)
Same operations
Same integrity constraints
• Classification and instantiation are the primary concepts for creating and
structuring objects
• Graphical representation
Generalization (1)
• Task:
The generalization concept supplements the classification concept.
By generalization a more general class that absorbs the common aspects of the
base classes and that suppresses their differences is defined.
• Usage
A bottom-up design process – combine a number of entity sets that
share the same features into a higher-level entity set
It builds the 'subclass-of'-relationship (‘sc’- or 'is-a'-relationship)
It is recursively applicable (n-level relationship) and organizes the
classes in a generalization hierarchy
A superclass is a complex composite object that is built by a collection
of less complex composite objects (subclasses)
24
Information Modeling Anwendersoftware (AS)
Generalization (2)
• Structural Properties of the Generalization
Each instance of a subclass is an instance of the superclass, too
At the same time an object can be an instance of different classes as well as a
subclass of multiple superclasses
(Æ networks, many-to-many!)
The affiliation/membership of an object to a class/superclass is determined
mainly by the structure, the operations, and the integrity constraints of the
class/superclass
25
Information Modeling Anwendersoftware (AS)
Specialization (1)
• Task:
Specialization and generalization are simple inversions of each other,
they are represented in an E-R diagram in the same way.
It supports the 'top-down'-design method:
Initially, the more common objects are described (superclasses), then
the more specific ones (subclasses)
Specialization (2)
• System Controlled Reasoning
makes use of inheritance concept:
Superclass properties are being 'inherited' to all subclasses, because they are
valid for them, too
ADVANTAGES:
- No repetition of descriptive information
- Shortened/condensed description
- Avoiding failures/mistakes
• Kinds of Inheritance
Inheritance of attributes, constants and default values.
Inheritance of methods, predicates and operations
Problems: multiple inheritance
26
Information Modeling Anwendersoftware (AS)
Inheritance
member of name
university birthday
faculty of employee
io
join_in_faculty Æ faculty of student is-a
research hous-per-week
Garfield assistant department
io
Ernie
Specialization: Definitions
• Subclass:
class S, whose entities are a subset of a superclass G: S ⊆ G
(i.e., each element (instance) of S is element of G, too)
• Specialization:
Z = {S1, S2, ... Sn} set of subclasses Si with the same superclass G
27
Information Modeling Anwendersoftware (AS)
type of specialization
Y Z subclass
EMPL EMPL
PO
EMPL EMPL
TO
TD
Generalization Example
28
Information Modeling Anwendersoftware (AS)
Specialization Example
• Task:
The element association groups objects (elements) to describe them
by an object group (set object) as a whole
- i.e., to describe the properties of the group of objects as a whole
On the – one hand details of individual elements are being suppressed
and on the other hand properties that characterize the whole group of
objects are being emphasized
Î grouping of elements
29
Information Modeling Anwendersoftware (AS)
• Usage
An element association (called as well: grouping, partitioning, cover
aggregation) constructs composite (set) objects based on simple
(element) objects.
Embodying 'element-of'-relationship (‘eo’) as one-level abstraction
relationship.
It is possible to combine heterogeneous objects to form a set object.
In case of automatic reasoning all objects have to fulfill the set
predicate. In case of manual construction a user selects the objects
and connects them with the set object.
• Graphical Representation
30
Information Modeling Anwendersoftware (AS)
• Task
The set association concept supplements the element association concept. It
expresses a relationship between composite set objects.
Î grouping of sets
• Usage
Embodying a 'subset-of'-relationship (‘ss’)
It is recursively and organizes the set objects in an association
hierarchy (n-level relationship)
31
Information Modeling Anwendersoftware (AS)
Association Example
• Task:
The element aggregation allows to compose objects from simple objects. It
defines a part-whole-relation with objects that are not further decomposable
Î grouping of components
• Usage
A collection of simple objects (element, part) is treated as a
composite object (component object/aggregate object)
Establishing 'part-element-of'-relationship (‘po’) (one-level
abstraction relationship). Typically, an user creates an aggregation of
parts using connect statements; structural properties have to be
considered (e.g., a soccer team comprises 11 players)
The possibility to aggregate heterogeneous objects adds flexibility to
the application
32
Information Modeling Anwendersoftware (AS)
• Task:
Component-aggregation supplements element-aggregation.
Applying the part-whole-relation to components
• Usage
Establishing a 'component-of'-relationship (‘co’) between the
component elements (e.g., with connect statement)
It is recursively applicable and organizes an aggregation hierarchy (n-
level relationship)
33
Information Modeling Anwendersoftware (AS)
Aggregation (Example)
34
Information Modeling Anwendersoftware (AS)
• Example (continued):
‘Upward implied predicate’: weight > x
‘Downward implied predicate’: price < y
Aggregation: Example
35
Information Modeling Anwendersoftware (AS)
An Example Object
Feijoada
instance-of: main dishes
structural attributes
element-of: brazilian specialities
has-components: black beans, meat, spices
price: 36
possible-values: integer > 0
cardinality: [1,1]
unit: Euro declarative attributes
preparation-time:
possible-values: integer > 0
cardinality: [1,1]
demon: compute-preparation time
suitable-drinks: dry red wine, beer
possible-values: instance-of drinks
cardinality
…
order (no-of-persons)
procedure BEGIN ... END procedural attributes
...
36
Information Modeling Anwendersoftware (AS)
Object-Centered Representation
• Integration of abstraction
concepts:
Each object can built up
to 6 relationships types
Corresponding to the
kinds of roles that
appear in abstraction
concepts
Context/roles of objects
determine semantics of
objects
37
Information Modeling Anwendersoftware (AS)
• UML:
standardized language to support software development
• ERM:
general modeling tool for information models (logical DB design)
38
ER-Modellierung
Information Modeling mit UML Anwendersoftware (AS)
ERM UML
UML-Stereotype
PersonalNr
StaffNr
<<entity>>
Employee
Last name Employee
<<key
+ PersonalNr:
attrbibute>>
Integer+ StaffNr: Integer
Firstname + Last_name
Nachname :: string
string
+ Vorname
First_name : string
: string
ER-Modellierung
Information Modeling mit UML Anwendersoftware (AS)
ERM UML
<<entity>>
Color
Color Car
Car
PlateNr + Color : string [1..*]
<<key attrbibute>> + PlateNr:
AutoNr: Integer
String
39
Information Modeling Anwendersoftware (AS)
ERM UML
<<entity>>
Car
Car
n
*
owned owned
1
1
<<entity>>
Person
Person
ERM UML
<<entity>>
Car
Car
n
*
<<relationship>>
owned
Date owned
+ Date: date
1
1
<<entity>>
Person
Person
40
Information Modeling Anwendersoftware (AS)
ERM UML
<<entity>> <<entity>>
Professor Course
Professor Course
1 n 0..1 *
<<relationship>>
grades
Date grades
+ Date: date
m *
<<entity>>
Student
Student
ERM UML
is-part- is-part-of
of
* 1..*
N M
component subpart - component - subpart
<<entity>>
part
part
41
Information Modeling Anwendersoftware (AS)
ERM UML
Address <<entity>>
House
House
Owner
<<key attribute>> +Address: string
1 + Owner: String
consists-of consists-of
N 1..*
<<weak entity>>
<<entity>>
Room
RoomNr Zimmer
Room
ERM UML
<<entity>>
Person
Person
<<entity>>
Employee
Employee
42
Information Modeling Anwendersoftware (AS)
Short Exercise
Title Address
Signatur StaffNr
is-a is-a
[0..4]
Dissertation grades Professor
substritutes
is substituted [1..5]
by
Substitute
has parts
Abstract Volltext
43
Information Modeling Anwendersoftware (AS)
Summary
Summary
• ERM Characteristics
Entity sets and relationship sets
(attribute, value set, primary key)
Classification of relationship types
ER diagrams
44
Information Modeling Anwendersoftware (AS)
Summary (cont.)
• ER Design Decisions
The use of an attribute or entity set to represent an object.
Whether a real-world concept is best expressed by an entity set or a
relationship set.
The use of a ternary relationship versus a pair of binary relationships.
The use of a strong or weak entity set.
The use of generalization
- Contributes to modularity in the design
The use of association
- Close to aggregation, but allows for empty sets
The use of aggregation
- Can treat the aggregate entity set as a single unit
without concern for the details of its internal structure.
The use of
- methods
- rules
- triggers, ...
45
Anwendersoftware (AS)
as
Anwendungssoftware
• Basic Concepts
• Mapping the Entity-Relationship Model
to the Relational Data Model
Fundamental Concepts
ER-to-Relational Mapping
Mapping of Generalization and Aggregation
Mapping of Relationships
Relational Invariants
• Referential Integrity
Basic Concepts
Referential Actions
1
Relational Model Anwendersoftware (AS)
• interview • ERM
• hierarchical
• noun analysis • NIAM
• network-like
• brainstorming • EXPRESS-G
• relational • DB2
• document analysis • IDEF1X
• object-oriented • Informix
• STEP
• ... • ORACLE
• ... • UML
• XML • Postgres
• ...
• mySQL
DBMS independent DBMS dependent • ...
conceptional DB logical physical
schema design schema design schema design
3
2
Relational Model Anwendersoftware (AS)
• Relationships
are always explicit, binary, and symmetric
are represented by values: role of primary and foreign key
(ensuring referential integrity)
are automatically maintainable in SQL (referential actions)
• Design theory
Normal form approach (desirable and expedient tables)
Synthesis approach
• Restrict/Select (σ)
Returns a relation containing all tuples from a specified
relation that satisfy a specific condition
• Project (π)
Returns a relation containing all (sub)tuples that remain in a
specified relation after specified attributes have been
removed
• Product
Returns a relation containing all possible tuples that are a
combination of two tuples, one from each of two relations
• Union
Returns a relation containing all tuples that appear in either
or both of two specified relations
3
Relational Model Anwendersoftware (AS)
Restrict Project
4
Relational Model Anwendersoftware (AS)
Join A B
Divide
• ER-to-Relational Mapping
Attribute Attribute
Entity Set
Relation (Table)
Relationship Set
10
5
Relational Model Anwendersoftware (AS)
12
6
Relational Model Anwendersoftware (AS)
Table Instance
Customer table
13
Keys
7
Relational Model Anwendersoftware (AS)
Fundamental Rules:
1. Each row (tuple) is unique and it describes one object (entity) of the
miniworld
2. The order of rows is not relevant;
the order of rows does not contain any relevant information for the user
3. The order of columns is not relevant, because they have a unique name
(attribute name)
4. Each data value is an atomic data element in a table
5. The whole meaningful information for the user is represented solely
through data values
6. A primary key exists and sometimes multiple additional candidate keys
15
16
8
Relational Model Anwendersoftware (AS)
• Representation of Information in RM
Solely by values V(Ai) = Di
Order of rows and columns contains no information
17
Definition:
18
9
Relational Model Anwendersoftware (AS)
Remarks:
1. Foreign key and associated primary key (candidate key) bear important
interrelational (sometimes also intrarelational) information. They are defined on
the same domain (comparable and uniteable). They allow to combine tables by
means of relational operations.
2. Foreign keys may have NULL values, if they are not part of a primary key.
3. Candidate keys may have NULL values, if NOT NULL was not specified explicitly.
4. A foreign key is a composite key, if the associated primary key is composite.
(FK value = NULL means that all components are NULL (MATCH FULL) or that
some components are NULL (no MATCH type specified)).
5. A table may have several foreign keys, which reference the same or different
tables.
6. Referenced and referencing table are not necessarily different ("self-
referencing table").
7. Cycles are possible (closed referential path).
19
20
10
Relational Model Anwendersoftware (AS)
• Criteria
Preservation of information
Minimization of redundancy
Minimization of work for combination of tables
Additional:
- A natural mapping
- No mixture of object types
- Understandable
• Detailed Examples: see exercises 21
22
11
Relational Model Anwendersoftware (AS)
23
Example:
PART PNO NAME MATERIAL STOCK
A geering aluminium 10
B casing steel 0
C axle steel 100
1 screw steel 200
D ball bearing steel 50
3 disc lead 0
2 screw chromium 100
24
12
Relational Model Anwendersoftware (AS)
25
SNAME
supplier
SLOCATION
PNO p PRONO
PNAME m n PRONAME
part supply project
WEIGHT PLOCATION
NUMBER DATE
13
Relational Model Anwendersoftware (AS)
• Horizontal Partitioning
Building of tables (classes) using selection constraints
EMP-VIP (ENO, ..., BA) SALARY > 100K
EMP (ENO, ..., BA) SALARY <= 100K
• Vertical Partitioning
To satisfy performance and security constraints more easily:
28
14
Relational Model Anwendersoftware (AS)
• Basic Concepts
• Mapping the Entity-Relationship Model
to the Relational Data Model
Fundamental Concepts
ER-to-Relational Mapping
Mapping of Generalization and Aggregation
Mapping of Relationships
Relational Invariants
• Referential Integrity
Basic Concepts
Referential Actions
29
30
15
Relational Model Anwendersoftware (AS)
∪ EMPLOYEES
32
16
Relational Model Anwendersoftware (AS)
TECHNICIAN ID EXPERIENCE
123 SUN
34
17
Relational Model Anwendersoftware (AS)
same time
RES-EMPL ID MASTER EXPERTISE NAME BAT
333 Computer Sc. RECOVERY DAISY IIA
765 Mathematics ERM GROUCH IIA
35
36
18
Relational Model Anwendersoftware (AS)
• ER Diagram
• Reference Graph
38
19
Relational Model Anwendersoftware (AS)
• Additional Rules:
Each employee (EMPL) has to be employed in one department ([1,1]).
⇒ EMPL.DNO ... NOT NULL
• Remark:
In SQL2 it is not possible to specify that a parent has to have a child (e.g., [1,n]).
In addition the number of children cannot be restricted.
39
• ER Diagram
DNOB
• Reference Graph
DEP EMPL
DNOA
• Remark:
- For each FK relation a separate FK attribute is necessary.
40
- Multiple FK attributes can reference to the same PK/CK attribute.
20
Relational Model Anwendersoftware (AS)
41
• Aditional Rules
Each department has one manager → DEP.MNO ... UNIQUE NOT
NULL
Each manager manages one department → MGR.DNO ... UNIQUE
NOT NULL
• Reference Graph
21
Relational Model Anwendersoftware (AS)
• ER Diagram
43
• The use of candidate keys with option NOT NULL allows to define ([1,1] , [1,1])
22
Relational Model Anwendersoftware (AS)
Reference Graph
46
23
Relational Model Anwendersoftware (AS)
A Sample Miniworld
1 Faculty 1
ER Diagram is
belongs to member
of
N N
Graphical Representation
of the Relational Schema
48
24
Relational Model Anwendersoftware (AS)
• Tables:
CREATE TABLE FC (
FCNO NO_OF_FACULTY PRIMARY KEY,
FCNAME FACULTY_NAME UNIQUE NOT NULL,
DEAN EMPLOYEE_NO UNIQUE NOT NULL)
49
25
Relational Model Anwendersoftware (AS)
51
52
26
Relational Model Anwendersoftware (AS)
PROBLEMS:
• Operations on the Child Table
a) Insert a child tuple
b) Update the FK value in a child tuple
c) Delete a child tuple
⇒ which actions are necessary?
54
27
Relational Model Anwendersoftware (AS)
Prohibit operation
Delete/update tuples with referencing FK values recursively
If the child tuple should be kept (this is not always possible (e.g.,
existence dependency)), set the value of FK to NULL or to the default
value
55
Three-valued logic:
- TRUE
- FALSE
- UNKNOWN (?)
56
28
Relational Model Anwendersoftware (AS)
• Basic Concepts
• Mapping the Entity-Relationship Model
to the Relational Data Model
Fundamental Concepts
ER-to-Relational Mapping
Mapping of Generalization and Aggregation
Mapping of Relationships
Relational Invariants
• Referential Integrity
Basic Concepts
Referential Actions
57
• Referential Integrity:
the DB must not contain any unmatched foreign key values
• SQL2 Standard Introduces “Referential Actions”
• More exact specification of referential actions for each
foreign key (FK)
1. Are “NULLs” forbidden?
NOT NULL
2. Deletion rule on destination table (referenced table)
ON DELETE
{CASCADE | RESTRICT | SET NULL | SET DEFAULT | NO ACTION}
3. Update rule on destination primary key or candidate key
ON UPDATE
{CASCADE | RESTRICT | SET NULL | SET DEFAULT | NO ACTION}
58
29
Relational Model Anwendersoftware (AS)
• RESTRICT:
operation is restricted to the case where no associated records (FK
values) exist
• CASCADE:
operation "cascades" to all associated records
• SET NULL:
FK is set to NULL in all associated records
• SET DEFAULT:
FK is set to an user-defined default value in every associated record
• NO ACTION:
no referential action is executed on the specified reference; the
referential integrity will be checked when the execution of all referential
actions is completed (temporary violation of referential integrety is
possible)
59
Referential Actions:
ON DELETE {CASCADE | RESTRICT | SET NULL | SET DEFAULT | NO ACTION}
ON UPDATE {CASCADE | RESTRICT | SET NULL | SET DEFAULT | NO ACTION}
60
30
Relational Model Anwendersoftware (AS)
• Operations
Delete FC (FCNO=FC5)
Update FC ((FCNO=FC9) Æ (FCNO=FC10))
• Referential actions
DC, DSN, DSD, DR, DNA
UC, USN, USD, UR, UNA
• Unambiguous operations?
61
PNO MATNR
Exam
• Example DB
STUDENT MATNR SNAME
123766 COY
654711 BERNSTEIN
31
Relational Model Anwendersoftware (AS)
• Use of
USN, DSN Î violation of keys
USD, DSD Î sometimes ambiguous
UNA, DNA Î identical effects with UR, DR
Prof Student
PNO MATNR
Exam
63
Î the result is independent from the processing order of the referential actions
Î a definite DB state is reached
32
Relational Model Anwendersoftware (AS)
65
Summary
66
33
Relational Model Anwendersoftware (AS)
• Data Structure
Table (Relation)
⇒ the only data structure (besides atomic values)
⇒ representation of information solely by values
⇒ integrity constraints on and between tables: relational invariants
67
68
34
5. Relational Algebra
• Classic Set of Operations
• Table Operations
• Rewrite Rules
• Algebraic Optimization
• Application
‘stand-alone’ mode (ad-hoc queries)
in a host language (embedded DB statements)
1
Languages of Relational Model (2)
Relational Algebra
A system, which consist of a non-empty set and a family of operations,
is called algebra.
Object:
The obligatory elements to form the sets are the tables.
Operations:
Operations on tables have one or more tables as input and produce a
table as output (closure property)
2
Relational Algebra (cont.)
Union-compatibility:
Same domain - same degree
Attribute sequences:
3
Examples
R ∪ S = { t | t ∈ R ∨ t ∈ S}
R – S = { t | t ∈ R ∧ t ∉S }
R ∩ S = R – (R – S)
={t|t∈R∧t∈S}
RΔS
4. Symmetric Difference (XOR)
R Δ S = (R ∪ S) − (R ∩ S)
= ((R ∪ S) − (R –( R – S )))
= { t| t ∈ R ⊕ t ∈ S}
8
4
Classic Set of Operations (2)
5. (Extended) Cartesian Product
R (degree r) and S (degree s) arbitrary
C =R × S
= {k | ∃ x ∈ R, y ∈ S: (k = x | y)}
L = ( ji | i=1,..,k )
P = πL( R )
= { p |∃ t ∈ R: p = 〈t [ j1] , t [ j2 ], …, t [ jk ] 〉}
• Example:
P = πFORENAME, SURNAME, … , SALARY(EMP)
10
5
Special Table Operations (2)
7. Restriction (Selection)
• Selection of rows of a table by means of predicates, short σP;
P = log. formula (without quantifiers!) composed of:
constant values
operands
column numbers or names
Θ ∈ {< , = , > , ≤ , ≠, ≥}
∨,∧,¬
T = σP ( R ) = { t | t ∈ R ∧ P(t )}
• Examples:
σ DNO = ’K55’ ∧ SALARY > 50000 (EMP)
σ SALARY > COMMISSION (EMP)
11
V = RiΘjS
= σiΘ r+j (R × S)
• Remarks:
(1) Special case Θ = ’=’ : equijoin
(2) Instead of i and j: column names A and B
e.g.: R iΘj S ≡ RAΘBS
(3) An equijoin between R and S is called lossless, if all rows of R
and S participate in the join. The inverse operation, projection,
recreates R and S (lossless join)
12
6
Equijoin (Example)
• Application of:
DEPT EMP
DNO = DNO
13
• Lossy Equijoin
if rows in DEPT or EMP do not have join partners, e.g. (K56, finance, M) in
DEPT or (471, 63, -) in EMP, then π as inverse operation does not yield DEPT or
EMP
14
7
Relational Algebra –Example-DB
DEPT DNO DNAME LOC
K51 PLANNING KAISERSLAUTERN
K53 PURCHASE FRANKFURT
K55 SALES FRANKFURT
• Find all employees (ENO, ENAME) in department K55 earning more than
40000$
15
Rename Operation
• Allows us to name, and therefore to refer to, the results of relational-
algebra expressions.
• Allows us to refer to a table by more than one name.
• If a relational-algebra expression E has arity n, then
ρ x(A1,A2,...,An) ( E)
returns the result of expression E under the name x, and with the
attributes renamed to A1, A2, ..., An.
16
8
Formal Definition
17
Assignment Operation
• The assignment operation (←) provides a convenient way to express
complex queries; write query as a sequential program consisting of a
series of assignments followed by an expression whose value is
displayed as the result of the query.
• Example: Write r ÷ s as
temp1 ← π R - S (r)
temp2 ← π R - S ((temp1 x s) – π R - S,S( r))
Result = temp1 - temp2
18
9
Special Table Operations
9. Natural Join
• Informal description: Equijoin over all corresponding columns and
projection over the different columns
• Given: R(A1, A2, . . . , A r-j+1, . . . , Ar)
S(B1, B2, . . ., Bj, . . . , Bs)
and without limitation of the general case:(otherwise reorder)
B1 = A r-j+1
B2 = A r-j+2
Bj = Ar
Natural join between R and S:
N = R S
= π A1, … ,Ar, B j+1, … ,Bs σ (R.A r–j +1 = S.B1) ∧ … ∧ (R.Ar = S.Bj ) (R × S)
20
10
Natural Join (Example) (cont.)
• Is the join always the inverse operation to the projection (π)?
• Example 1 (1:n): !
• Example 2 (n:m):
ACTOR ( ENO, ROLE, LOC)
P1 Faust MA
P1 Mephisto KL
P2 Wallenstein MA
21
22
11
Outer join (1)
23
outer equijoin
R S := R’ S’
R.A = S.A R’.A = S’.A
24
12
Variants of the Outer Equijoin (1)
• Left Outer Equijoin
In case of this operation the left argument table remains lossless, i.e. if
necessary a row is filled with NULL values “to the right”.
25
26
13
Variants of the Outer Equijoin (3)
• Correspondingly
R S T
yields the following result:
27
• Summary
The application of the outer equijoin
R S T
yields the maximum of information relative to the sequence of
operations. Even isolated rows are expanded to a path
- The left outer equijoin returns only paths, which are defined
at the “left border”.
- The right outer equijoin returns only paths, which are defined
at the “right border”.
28
14
Examples of the Outer Equijoin (1)
• Equijoin
R A B C S C D E RES A B C D E
a1 b1 c1 c1 d1 e1 = a1 b1 c1 d1 e1
a2 b2 c2 c3 d2 e2
29
R A B C S C D E RES A B C D E
a1 b1 c1 c1 d1 e1 = a1 b1 c1 d1 e1
a2 b2 c2 c3 d2 e2 -- -- c3 d2 e2
• Outer equijoin
R A B C S C D E RES A B C D E
a1 b1 c1 c1 d1 e1 = a1 b1 c1 d1 e1
a2 b2 c2 c3 d2 e2 a2 b2 c2 -- --
-- -- c3 d2 e2
30
15
Further Outer Operations (1)
• Outer Union
This operation allows the union of two tables that are not union-compatible.
If two tables are partially compatible, i.e. some of their columns are union-
compatible, then the outer union operation can be applied.
Example:
31
32
16
Division (1)
• Goal:
Answering queries in which a whole table is used to qualify rows.
Simulation of universal quantification ⇒ a row of R is with all rows of S in a
specific relation.
• Def.:
Let R be of degree r and let S be of degree s, r > s and s ≠ 0.
t be a (r-s)-row, u be a s-row.
Furthermore let S-columns ⊂ R-columns
Then the following holds:
R ÷ S = { t | ∀ u ∈ S: ( t|u ∈ R)}
33
Division (2)
• Description of the Division With the Basic Operations
T = π 1 ,2, … , r – s ( R )
W=(T×S)–R
V = π 1, 2, … ,r – s ( W )
R÷S=T–V
= π 1, 2 …, r – s ( R ) –
π 1, 2, … r – s (( π 1, 2, … ,r – s (R) × S ) – R )
34
17
Generalized Projection
Banking Example
branch ( branch-name, branch-city, assets )
customer ( customer-name, customer-street, customer-city )
account ( branch-name, account-number, balance )
loan ( branch-name, loan-number, amount )
depositor ( customer-name, account-number )
borrower ( customer-name, loan-number )
36
18
Example Queries
37
38
19
Example Queries (cont.)
• Find the names of all customers who have a loan at the Perryridge
branch.
Query 1
π customer-name(σ branch-name = “Perryridge”
(σ borrower.loan-number = loan.loan-number( borrower x loan)))
Query 2
π customer-name (σ borrower.loan-number = loan.loan-number(
(σ branch-name = “Perryridge” ( borrower)) x loan))
39
40
20
Aggregate Functions
41
Example:
• Table r
• Sum c(r)
42
21
Aggregate Functions (Example) (cont.)
• Table account grouped by
branch-name:
43
44
22
Modification of the Database - Deletion (cont.)
Examples:
• Delete all account records in the Perryridge branch.
account ← account – σ branch-name = “Perryridge” (account)
account← account - r2
depositor← depositor - r3
45
r←r∪E
46
23
Modification of the Database – Insertion (cont.)
Examples:
47
r←∏ F1 , F2 , ..., Fn ( r )
Each Fi is either the ith attribute of r, if the ith attribute is not updated,
or, if the attribute is to be updated Fi is an expression, involving only
constants and the attributes of r, which gives the new value for the
attribute
48
24
Modification of the Database – Updating (cont.)
Examples:
• Make interest payments by increasing all balances by 5
percent.
account ←∏ BN,AN,BAL← BAL *1.05 ( account)
49
Views (1)
• In some cases, it is not desirable for all users to see the entire logical
model
(i.e., all the actual tables stored in the database.)
• Any table that is not part of the conceptual model but is made visible
to a user as a “virtual table” is called a view.
50
25
Views (2)
View Definition:
• A view is defined using the create view statement which has the form
• Once a view is defined, the view name can be used to refer to the
virtual table that the view generates.
51
Views (3)
Example:
• Consider the view (named all-customer) consisting of branches and
their customers.
52
26
Updates through Views (1)
• Database modifications expressed as views must be translated to
modifications of the actual tables in the database.
• Consider the person who needs to see all loan data in the loan table
except loan-amount. The view given to the person, branch-loan, is
defined as:
create view branch-loan as
∏branch-name, loan-name ( loan)
Since we allow a view name to appear wherever a table name is
allowed, the person may write:
branch-loan ← branch-loan ∪ {( “Perryridge”, L-37)}
53
54
27
Views defined using other Views (1)
55
View Expansion
• A way to define the meaning of views defined in terms of other views.
• Let view v1 be defined by an expression e1 that may itself contain
uses of view tables.
• View expansion of an expression repeats the following replacement
step:
repeat
Find any view table vi in e1
Replace the view table vi by the expression defining vi
until no more view tables are present in e1
• As long as the view definitions are not recursive, this loop will
terminate.
56
28
Summary – Relational Model (1)
• Algebra has the same expressive power as first order predicate
calculus
• Closed with regard to algebraic operations
• Classic set operations
• Table operations
57
58
29
Relational Algebra – Optimization (1)
59
Query:
Find the names and jobs of employees whose department is located in
KL and who are assigned to a project in KL
60
30
Rewrite-Rules of the Relational Algebra (1)
Equivalence of Expressions
Transformation of expressions for more efficient evaluation
List of important rules
Ri: tables (or expressions in relational algebra)
61
4. Sequences of Selections
σ F1 (σ F2 ( R )) = σ F1 ∧ F2( R )
( F1 ∧ F2 = F2 ∧ F1):
σ F1 ( σF2 ( R )) = σ F2 ( σF1 ( R ))
62
31
Rewrite-Rules of the Relational Algebra (3)
6. Exchange of Selection and Cartesian Product
F contains only attributes from R1
σF ( R1 × R2 ) = σF ( R1 ) × R2
More general:
F = F1 ∧ F2 ∧ F3
F1: only attributes from R1
F2: only attributes from R2
F3: both
σF ( R1 × R2 ) = σF1( R1 ) F3 σF2 ( R2 )
63
64
32
Rewrite-Rules of the Relational Algebra (5)
⇒ Determine the join order in such a way that number and size of
intermediate objects are minimized
65
Expectation:
Heuristic Rule:
⇒ In case of set operations combine the smallest tables always first
66
33
Summary: Algebraic Optimization
Heuristic Rules:
67
34
SQL Anwendersoftware (AS)
Chapter 6. SQL
• Introduction
• Basic SQL Queries
• SQL Query Evaluation
• Advanced Retrieval
• Data Manipulation and Data Definition
• New Features in SQL:1999
Outline
• Introduction
• Basic SQL Queries
• SQL Query Evaluation
• Advanced Retrieval
• Data Manipulation and Data Definition
• New Features in SQL:1999
1
SQL Anwendersoftware (AS)
Overview of Commands
• Data Manipulation (DML): • Data Control:
SELECT constraints definitions with
INSERT - CREATE TABLE
UPDATE - CREATE ASSERTION
- DROP ASSERTION
DELETE
GRANT
built-in functions: COUNT, SUM, AVG,
MAX, MIN REVOKE
• Data Definition (DDL): COMMIT
CREATE SCHEMA ROLLBACK
CREATE DOMAIN • Embedded SQL:
CREATE TABLE DECLARE CURSOR
CREATE VIEW FETCH
ALTER TABLE CLOSE CURSOR
DROP SCHEMA SET CONSTRAINTS
DROP DOMAIN SET TRANSACTION
DROP TABLE CREATE TEMPORARY TABLE
DROP VIEW
2
SQL Anwendersoftware (AS)
SQL History
SQL Standards (1 of 2)
3
SQL Anwendersoftware (AS)
SQL Standards (2 of 2)
• SQL3, SQL:1999
ISO/IEC 9075-x:1999 1999
- Part 1: Framework (SQL/Framework)
- Part 2: Foundation (SQL/Foundation)
- Part 3: Call-Level Interface (SQL/CLI)
- Part 4: Persistent Stored Modules (SQL/PSM)
- Part 5: Host Language Bindings (SQL/Bindings)
ISO/IEC 9075-x:2000 2000
- Part 9: Management of External Data (SQL/MED)
- Part 10: Object Language Bindings (SQL/OLB)
- Part 13: SQL Routines and Types Using the Java TM
Programming Language (SQL/JRT)
Outline
• Introduction
• Basic SQL Queries
• SQL Query Evaluation
• Advanced Retrieval
• Data Manipulation and Data Definition
• New Features in SQL:1999
4
SQL Anwendersoftware (AS)
Examples of Tables
parts usage
partno version projectno part_description partno version uses_ uses_ quantity
partno version
P050 1.0 PJ23 bodywork
P050 1.0 P101 1.0 1
P050 2.0 PJ23 bodywork
P050 1.0 P102 1.2 2
P101 1.0 PJ23 front body section
P050 1.0 P103 1.2 2
P101 1.1 PJ23 front body section
P050 1.0 P104 1.2 2
P101 2.0 PJ23 front body section
P050 1.0 P111 1.0 2
P102 1.2 PJ23 a column
P050 2.0 P101 1.1 1
P103 1.2 PJ23 b column
P050 2.0 P102 1.2 2
P104 1.2 PJ23 c column
P050 2.0 P103 1.2 2
P111 1.0 PJ15 rear wing
P050 2.0 P104 1.2 2
P111 1.2 PJ15 rear wing
P050 2.0 P111 1.2 2
P112 1.0 PJ15 front wing
P050 2.0 P112 1.0 2
projects
projectno manager description budget
PJ23 Miller main bodywork team 1 000 000
PJ15 Maynard specialized wings 100 000
PJ47 Morris electronics 500 000
Where:
Ai represent attributes
ri represent tables
P is a predicate.
• The result of a SQL query is a table.
10
5
SQL Anwendersoftware (AS)
SELECT Clause (1 of 3)
11
SELECT Clause (2 of 3)
6
SQL Anwendersoftware (AS)
SELECT Clause (3 of 3)
13
WHERE Clause (1 of 2)
7
SQL Anwendersoftware (AS)
WHERE Clause (2 of 2)
15
FROM Clause
16
8
SQL Anwendersoftware (AS)
Join Operation (1 of 2)
• Example:
List all parts of version 1.0 and the manager that is
responsible for the corresponding project.
SELECT partno, version, manager join condition
FROM parts, projects
WHERE parts.projectno = projects.projectno
AND version = '1.0'
Join Operation (2 of 2)
9
SQL Anwendersoftware (AS)
Tuple Variables
projectno budget
PJ23 1000000
PJ47 500000
19
String Operations
10
SQL Anwendersoftware (AS)
Aggregate Functions (1 of 2)
22
11
SQL Anwendersoftware (AS)
Aggregate Functions (2 of 2)
• Example:
How many rows are in table parts?
SELECT COUNT(*) AS number_of_rows number_of_rows
FROM parts 11
• Example:
How many different parts are stored in table parts?
SELECT COUNT(DISTINCT partno) AS number_of_parts
FROM parts
number_of_parts
7
23
GROUP BY Clause (1 of 2)
24
12
SQL Anwendersoftware (AS)
GROUP BY clause (2 of 2)
P050
partno version projectno description P050
P050 1.0 PJ23 bodywork
P101 partno number_of
P050 2.0 PJ23 bodywork _versions
P101
P101 1.0 PJ23 front body section P050 2
P101
P101 1.1 PJ23 front body section P101 3
P101 2.0 PJ23 front body section P102 P102 1
P102 1.2 PJ23 a column P103 1
P103
P103 1.2 PJ23 b column P104 1
P104
P104 1.2 PJ23 c column P111 2
P111 1.0 PJ15 rear wing P112 1
P111
P111 1.2 PJ15 rear wing
P111
P112 1.0 PJ15 front wing
P112
25
HAVING Clause
26
13
SQL Anwendersoftware (AS)
Outline
• Introduction
• Basic SQL Queries
• SQL Query Evaluation
• Advanced Retrieval
• Data Manipulation and Data Definition
• New Features in SQL:1999
27
• Step 1:
The table(s) that should be evaluated are determined by the
FROM clause. The multiple occurrence of a single table is
possible by using aliases, i.e., tuple variables.
X
A B Y
1 9 C D
SELECT X.A, COUNT(*)
1 6 1 7
FROM X, Y
2 7 2 5
WHERE X.B > 5
2 6 3 5
AND X.A = Y.C
3 5 4 11
GROUP BY X.A
HAVING SUM(Y.D) > 10 4 6
ORDER BY X.A DESC
28
14
SQL Anwendersoftware (AS)
29
30
15
SQL Anwendersoftware (AS)
• Step 4:
The selected rows are divided into groups as specified in the
GROUP BY clause.
Each group contains all rows with the same values of the
columns specified in the GROUP BY clause.
A B C D
SELECT X.A, COUNT(*) 1 9 1 7
FROM X, Y A B C D 1 6 1 7
WHERE X.B > 5 1 9 1 7
A B C D
AND X.A = Y.C 1 6 1 7
2 7 2 5
GROUP BY X.A 2 7 2 5
2 6 2 5
HAVING SUM(Y.D) > 10 2 6 2 5
ORDER BY X.A DESC 4 6 4 11 A B C D
4 6 4 11
31
• Step 5:
Groups that satisfy the condition specified in the HAVING
clause are selected.
The predicate of the HAVING clause must evaluate to "true".
The HAVING condition must only be related to group
properties, i.e. columns specified in the GROUP BY clause and
the application of aggregate functions. A B C D
SELECT X.A, COUNT(*) 1 9 1 7
FROM X, Y 1 6 1 7
WHERE X.B > 5
A B C D
AND X.A = Y.C
2 7 2 5
GROUP BY X.A
2 6 2 5
HAVING SUM(Y.D) > 10
ORDER BY X.A DESC A B C D
4 6 4 11
32
16
SQL Anwendersoftware (AS)
• Step 6:
The output is derived by evaluating the SELECT clause.
If a GROUP BY clause is specified only expressions that
calculate a single value for each group are allowed as select
items, i.e., columns specified in the GROUP BY clause or the
application of aggregate functions.
33
• Step 7:
Order the tuples in the result by the values of one or more
attributes according to the ORDER BY clause.
• Remark: Step 1-7 show how the result of a given query
could be derived. The database system may choose an
alternative, more efficient way of evaluating an SQL query.
34
17
SQL Anwendersoftware (AS)
Outline
• Introduction
• Basic SQL Queries
• SQL Query Evaluation
• Advanced Retrieval
• Data Manipulation and Data Definition
• New Features in SQL:1999
35
Null Values
36
18
SQL Anwendersoftware (AS)
Nested Subqueries
37
Set Membership
0
implicit set definition : (5 IN 4 ) = false
Ai IN (SELECT …) 6
0
SELECT projectno
FROM projects
WHERE projectno NOT IN ( projectno
SELECT projectno PJ47
FROM parts)
38
19
SQL Anwendersoftware (AS)
39
Derived Tables
20
SQL Anwendersoftware (AS)
Views (1 of 2)
Views (2 of 2)
• Example:
Create a view that holds all parts of version 1.0
CREATE VIEW V1_parts (PNO, PROJNO)
AS
SELECT partno, projectno
FROM parts
WHERE version ='1.0'
• Advantages
More user friendly
Higher degree of data independence
• Properties of views
A view can be handled like a table
Views on views are possible
Semantic of views: dynamic window on the base tables
Limited updates: updatable and non-updatable views
42
21
SQL Anwendersoftware (AS)
Updatable Views
Set Operations
22
SQL Anwendersoftware (AS)
Outline
• Introduction
• Basic SQL Queries
• SQL Query Evaluation
• Advanced Retrieval
• Data Manipulation and Data Definition
• New Features in SQL:1999
45
Deleting Rows
• Example: DELETE
Delete part P101 from table parts. FROM parts
WHERE partno = 'P101'
46
23
SQL Anwendersoftware (AS)
Inserting Rows
Updating Rows
48
24
SQL Anwendersoftware (AS)
Data Types
25
SQL Anwendersoftware (AS)
Defining Domains
51
26
SQL Anwendersoftware (AS)
53
27
SQL Anwendersoftware (AS)
55
Outline
• Introduction
• Basic SQL Queries
• SQL Query Evaluation
• Advanced Retrieval
• Data Manipulation and Data Definition
• New Features in SQL:1999
56
28
SQL Anwendersoftware (AS)
Trigger Concept (1 of 2)
58
29
SQL Anwendersoftware (AS)
Trigger Concept (2 of 2)
59
60
30
SQL Anwendersoftware (AS)
Typed Tables
62
31
SQL Anwendersoftware (AS)
er
om
st
cu
partno date sales Sum(sales)
partno
P050 2003-09-15 500 800
P050 2003-09-16 200 850
P050
P050 2003-09-17 100 1050
P050 2003-09-18 550 950
P101
P050 2003-09-19 400
P101 2003-09-15 600
2003-09-15
2003-09-16
2003-09-17
2003-09-18
2003-09-19
date
63
Defined Interfaces
Server API
Foreign
Foreign Foreign
Data
Server Tables
Wrapper
64
32
SQL Anwendersoftware (AS)
Upcoming Features
65
Literature
66
33
Database Programming Anwendersoftware (AS)
7. Database Programming
• Introduction
• Direct Invocation
• Embedded SQL and SQLJ
• Module Language
• Dynamic SQL
• Call-Level APIs
SQL/CLI
ODBC
JDBC
1
Database Programming Anwendersoftware (AS)
Outline
• Introduction
• Direct Invocation
• Embedded SQL and SQLJ
• Module Language
• Dynamic SQL
• Call-Level APIs
SQL/CLI
ODBC
JDBC
Direct invocation
2
Database Programming Anwendersoftware (AS)
Outline
• Introduction
• Direct Invocation
• Embedded SQL and SQLJ
• Module Language
• Dynamic SQL
• Call-Level APIs
SQL/CLI
ODBC
JDBC
Embedded SQL
(H. Garcia-Molina, J. Ullman, J. Widom: Database Systems: The Complete Book, 2002) 6
3
Database Programming Anwendersoftware (AS)
Impedance Mismatch
SQL
7
Shared Variables
4
Database Programming Anwendersoftware (AS)
Examples of Tables
parts usage
partno version projectno part_description partno version uses_ uses_ quantity
partno version
P050 1.0 PJ23 bodywork
P050 1.0 P101 1.0 1
P050 2.0 PJ23 bodywork
P050 1.0 P102 1.2 2
P101 1.0 PJ23 front body section
P050 1.0 P103 1.2 2
P101 1.1 PJ23 front body section
P050 1.0 P104 1.2 2
P101 2.0 PJ23 front body section
P050 1.0 P111 1.0 2
P102 1.2 PJ23 a column
P050 2.0 P101 1.1 1
P103 1.2 PJ23 b column
P050 2.0 P102 1.2 2
P104 1.2 PJ23 c column
P050 2.0 P103 1.2 2
P111 1.0 PJ15 rear wing
P050 2.0 P104 1.2 2
P111 1.2 PJ15 rear wing
P050 2.0 P111 1.2 2
P112 1.0 PJ15 front wing
P050 2.0 P112 1.0 2
projects
projectno manager description budget
PJ23 Miller main bodywork team 1 000 000
PJ15 Maynard specialized wings 100 000
PJ47 Morris electronics 500 000
10
5
Database Programming Anwendersoftware (AS)
/* request budget */
11
Cursors (1 of 2)
12
6
Database Programming Anwendersoftware (AS)
Cursors (2 of 2)
Fetch tuples:
EXEC SQL FETCH FROM <cursor> INTO <variables>
- Get the next tuple of the relation over which the cursor ranges.
- Repeated calls to fetch/get successive tuples in the query result.
- If the tuples have been exhausted, then the value of SQLSTATE is
set to '02000'.
Close cursor:
EXEC SQL CLOSE <cursor>
- Close cursor, i.e., the cursor no longer ranges over tuples of the
relation.
• Cursors may also be used to update the current tuple.
13
Example: Cursor
void getAllProjects() {
EXEC SQL BEGIN DECLARE SECTION;
char project[4], description[50];
char SQLSTATE[6];
EXEC SQL END DECLARE SECTION;
EXEC SQL DECLARE execCursor CURSOR FOR
SELECT projectno, description
FROM projects;
7
Database Programming Anwendersoftware (AS)
SQLJ
(ISI/IEC 9075:1999, Information Technology - Database languages - SQL - Part 10: Object Language Bindings (SQL/OLB))
15
Outline
• Introduction
• Direct Invocation
• Embedded SQL and SQLJ
• Module Language
• Dynamic SQL
• Call-Level APIs
SQL/CLI
ODBC
JDBC
16
8
Database Programming Anwendersoftware (AS)
Module Language
PROCEDURE num_projects
( :budget INTEGER,
:num INTEGER, SQLSTATE )
SELECT COUNT(*)
INTO :num
FROM projects
WHERE budget >= :budget;
…
(J. Melton, A. R. Simon: SQL:1999 Understanding Relational Language Components, 2002) 17
Outline
• Introduction
• Direct Invocation
• Embedded SQL and SQLJ
• Module Language
• Dynamic SQL
• Call-Level APIs
SQL/CLI
ODBC
JDBC
18
9
Database Programming Anwendersoftware (AS)
Dynamic SQL
prjno = "PJ47";
EXEC SQL EXECUTE :dynstmt USING :prjno;
20
10
Database Programming Anwendersoftware (AS)
Outline
• Introduction
• Direct Invocation
• Embedded SQL and SQLJ
• Module Language
• Dynamic SQL
• Call-Level APIs
SQL/CLI
ODBC
JDBC
21
Call-Level APIs
11
Database Programming Anwendersoftware (AS)
(ISI/IEC 9075-3:1999, Information Technology - Database languages - SQL - Part 3: Call-Level Interface (SQL/CLI), 1999.) 23
JDBC
12
Database Programming Anwendersoftware (AS)
Summary
25
13
8. Logical Database Design
• Logical Database Design
• Normalization of Tables
• Design Theory - Synthesis Approach
• Goal
Theoretical foundation for the design of a
‘good’ (relational database) schema
Î design theory
• Goodness/Quality:
Easy to handle, clarity …
Design theory specifies ‘quality’ to measure formally why a
particular set of groupings of attributes in tables is better than
another one
1
Logical Design
• Normalization of Tables
to optimize a given design
• Creating Tables by the Synthesis of Attributes
to construct an “optimal” DB schema
process of synthesis
normalization algorithm
2
Functional Dependencies (1)
• Constraints on the set of legal tables.
• Require that the value for a certain set of attributes determines
uniquely the value for another set of attributes.
• A functional dependency is a generalization of the notion of a key.
• Let R be a table schema
α ⊆ R, β ⊆ R
• The functional dependency
α→β
holds on R if and only if for any legal tables r(R), whenever any two
tuples t1 and t2 of r agree on the attributes α, they also agree on the
attributes β.
That is, t1[α] = t2 [α] ⇒ t1 [β] = t2 [β]
loan-info-schema=(branch-name,loan-number,customer-name, amount).
3
Use of Functional Dependencies
• Note:
A specific instance of a table schema may satisfy a functional
dependency even if the functional dependency does not hold on all
legal instances. For example, a specific instance of loan-schema may,
by chance, satisfy loannumber Æ customer-name.
Closure (1)
if β ⊆ α, then α → β (reflexivity)
if α → β, then γα → γβ (augmentation)
if α → β and β → γ, then α → γ (transitivity)
These rules are sound and complete:
- complete: these axioms find all of F+ of F
- sound: no FD of F will be found that is not in F+
4
Closure (2)
Example
• R = ( A, B, C, G, H, I )
• F = { A → B, A → C, CG → H, CG → I, B → H }
• Some members of F+ : A → H, AG → I, CG → HI
10
5
Closure of Attribute Set: Example
• R = ( A, B, C, G, H, I )
F={A→B
A→C
CG → H
CG → I
B→H}
• (AG+)
0. result = AG
1. result = ABG (A → B and A ⊆ ΑG)
2. result = ABCG (A → C and A ⊆ ΑGB)
3. result = ABCGH (CG → H and CG ⊆ AGBC)
4. result = ABCGHI (CG → I and CG ⊆ AGBCH)
• Is AG a candidate key?
1. AG → R
2. does A → R?
3. does G → R?
11
Normalization of Tables
12
6
Normalization of Tables (1)
Example:
A → B is a partial dependency, if there exist an
attribute Ai in A so that ( A - {Ai} ) → B is valid.
13
14
7
Normalization of Tables (3)
• Normalization:
Unnesting the table: “copying down” the values leads to a high
degree of redundancy
→ decomposition of tables
But: keep informational content!
• Normalized Table:
Each tuple contains exactly one value for each attribute
A table that satisfies this property is said to be normalized (i.e., be
in the 1NF)
15
16
8
Normalization of Tables (5)
RULES:
• Composite attributes, multivalued attributes and combinations of
them (e.g., composite attributes that are themselves multivalued)
built up new tables
• Copy down the key
17
18
9
Converting into 2NF (2)
Definition:
An attribute of a relation schema is called a prime attribute (key
attribute) of the relation schema if it is a member of at least one
candidate key of the schema.
A relation schema R is in 2NF if it is in 1NF and if every nonprime
attribute A in R is fully functionally dependent on every candidate key
of R (i.e., every nonprime attribute of R is not partially dependent on any
candidate key of R)
Transformation into 2NF:
1.Determine functional dependencies between nonprime attributes and
candidate keys
2. Cut out partially dependent attributes and combine them into an own
table (and add the corresponding prime attributes)
19
20
10
Transformation into 3NF (1)
• Because of transitive dependencies update anomalies are still possible
in 2NF.
Example: mixture of faculty data and student data within student
Definition:
A set of attributes Z of relation schema R is transitive dependent from
a set of attributes X in R if:
X and Z are disjoint
if exists a set of attributes Y in R with:
21
22
11
Functional Dependencies in STUDENT
23
• Example:
EXAM (ENO, MATNR, SUBJECT, MARK)
PRIMARY KEY (ENO, MATNR), UNIQUE (SUBJECT, MATNR)
It exists a one-to-one relationship between ENO and SUBJECT
The only nonprime attribute is MARK ⇒ EXAM is in 3NF
12
Boyce-Codd Normal Form (BCNF) (2)
Definition: An attribute (or a set of attributes) from which others are
fully functionally dependent is called determinant.
Formal Definition:
A relation schema is in BCNF if the following is true:
If a set of attributes Y is (fully functionally) dependent from another
disjoint set of attributes X, then every other set of attributes Z is also
(fully functionally) dependent from X.
I.e. for all X, Y, Z with X and Y are disjoint the following is valid:
X → Y implies X → Z
25
26
13
Boyce-Codd Normal Form (BCNF) (4)
• Are BCNF decompositions always a good idea?
27
• New problems
Now, STUDENT, SUBJECT → EXAMINER is "external"
Æ consistency check?
28
14
Normal Forms: Overview
Normal Form Focus / Eliminated
1NF repetition of attribute groups
29
30
15
Design Theory of Relational Databases – An
Overview
31
• Algorithm MEMBER:
Input: X → Y, F
Output: TRUE, if F├ X → Y, else FALSE
MEMBER (F, X → Y)
begin
if Y ⊆ CLOSURE(X,F) then
return (TRUE)
else return (FALSE)
end
32
16
Cover over Functional Dependencies
If F ≡ G, then is F a cover over G
Alternative:
X → Y in F is redundant, if F - {X → Y} ├ X → Y
Remark:
In case of X → Y
Y can be composite and X cannot be minimal
(i.e., X’ → Y with X’ ⊂ X).
33
34
17
Canonical Cover (2)
Algorithm MINCOVER:
Input: set G of functional dependencies
MINCOVER (G)
begin
F := G;
F := REDUCE_RHS (F)
F := REDUCE_LHS (F)
F := REMOVE_REDUNDANT_FDs (F)
return {F};
end
36
18
Synthesis Approach – Prerequisites
1. Assumption of Unambiguous Functional Dependencies
f : X → Y and g : X → Y imply f ≡ g
Example:
f1 : ENO → PHONE_NBR (employee uses phone)
f2 : PHONE_NBR→ DNO (phone costs are handled departmentwise)
37
Synthesis Algorithm
Input: A; F
Output: RS in 3NF with a minimal number of tables
38
19
Application of the Synthesis Algorithm (1)
Example 1:
Step 1: H=
Step 2: g1
g2
g3
Step 5: R1
R2
R3
39
20
One Possible Solution
R1 (ENO, NAME, AGE, SALARY, MNO)
R2 (MNO, DNO, DNAME, TOWN, STR, HNO)
R3 (TOWN, STR, ZIP_CODE)
R4 (ZIP_CODE, COUNTRY)
1. Is the decomposition of
TOWN, STR → ZIP_CODE→ COUNTRY
into R3 and R4 a good idea?
Update frequency?
Select addresses (join operation)!
Does TOWN, STR or ZIP_CODE represents an entity in this context?
(to build an own table in 3NF)
⇒ better solution: R2 in 2NF!
• Normalization of Tables
Local approach on existent data structures
Stepwise elimination of update anomalies
Comprehensive approach for DB schema integration
42
21
Design Theory – Summary (2)
43
22