<<

Context Design:

6 The Relational : e

s - developing a relational

a

Requirements analysis b database schema

Algebraic operations on tabular data a

t Design:

a

d - formal theory

6.1 Basic idea of relational languages Conceptual Design g n i Data handling in a rela-

s

6.2 Relational operations u tional database

Schema design d 6.3 Relational Algebra: Syntax and Semantics n - Algebra,-calculus -SQL -logical a

(“create tables”)

g Extensions

6.4. More Operators n

i

n

g Using

6.5 Special Topics of RA i s from application progs 6.5.1 Relational algebra operators in SQL e

D

: Special topics,

6.5.2 Relational completeness 1

Schema design t Physical Schema, 6.5.3 What is missing in RA? r

a

-physical P 6.5.4 RA operator trees Part 2: (“create access path”) Implementation of DBS Loading, administration, Transaction, Kemper / Eickler: 3.4, Elmasri /Navathe: chap. 74-7.6, tuning, maintenance, Garcia-Molina, Ullman, Widom: chap. 5 reorganization Recovery

6.1 Basic idea of relational languages Relational Languages • Data Model: Important concepts Goal of language design Language for definition and Given a like the Video shop DB handling (manipulation ) of data Design a language, which allows to express queries – Languages for handling data: like: • Relational Algebra (RA) as a semantically well defined - Customers who rented videos for more than 100 $ last month applicative language - List of all movies no copy of which have been on loan since 2 month - List the total sales volume of each movie within the last year • Relational calculus (domain calculus): predicate logic - Is there anybody whose rented movies all have category "horror"? interpretation of data and queries y? ……. ac riv • SQL / DML (or simply SQL) Language should be declarative ("descriptive") P – Kernel of SQL built upon RA as well as calculus, Historically: “Make query formulation ‘as easy as in natural language’ “ extended by operations like arithmetic expressions not available in RA or calculus HS / DBS05-08-RDML1 3 HS / DBS05-08-RDML1 4

Relational Algebra Basic Operations informally (repeated from chapter 4) • Idea of Relational Algebra: – Given relations R(a1,...,an), S(b1,...,bm) Selection – Define operators which transform one or more tables into a result . Example ∪ Tape ( id movieId ) Movie ( m_Id title ) 1 'B' Difference 'A' "Frenzy" - 5 'A' Join tables! 'B' "Matrix" 6 'B' A I Cartesian Project A A II B B I How could we find the number of tapes of "Matrix?" C B II C I I C II HS / DBS05-08-RDML1 5 (Renaming) II HS / DBS05-08-RDML1 6

1 Relational Algebra Basics 6.2 Relational Algebra operations • Why “algebra”? Terminological update – Mathematically, algebraic structures basically defined Let A be a universal of attributes by a base set S of values and operations which map one or more elements of S to S and obey certain laws –A Schema is a named n-tuple of attributes (e.g. groups, lattices, …) RS = R (a1,...,an), {a1,…an} ⊆ A – The base set of Relational Algebra is the set of all –RA is the set {a1,...,an} of attributes (columns) of RS relations (tables) with attributes from a given set A of called the type signature of R attributes. – The operation Σ applied to a relation R results in the – Operations on tables type signature of R: Σ ( R ) = RA projection, , , .... as introduced intuitively above –A Relational Database Schema is a set of relation schemas –A Database Relation R (conforming to Relation – Note: Result of an operation is time dependent Schema RS) is a subset of D(a1) X ...X D(an), the HS / DBS05-08-RDML1 7 cross product of the domains of the HSattributes / DBS05-08-RDML1 of 8R

Set operations Relational Algebra Basic Operations

Tape ( id movieId ) Movie ( movieId title ) • Cartesian (Cross) Product 1 'B' ∪ 'A' "Frenzy" ? – Cross product of two sets R and S: 5 'A' 'B' "Matrix" a set of pairs with type signature Σ(R) ⊆ A and Σ(S) ⊆ A 6 'B' – Result relation T should be a relation over R, S relations, Σ(R) ∪Σ(S) = A' ⊆ A ( assumed Σ(R) ∩Σ(S) = ∅)

R and S are called union-compatible R ( a1 a2 ) S ( b1 a2 ) if the domains of Σ ( R ) and Σ ( S ) are pair wise the same or: two tables are union-compatible if they have 1 'A' X 3 'A' the same number of columns and have the same 5 'Z' 1 'B' domains in corresponding colums T ((a1 , a2) (b1 a2) ) R and S union-compatible, then set union and set difference Not a relation = (1 'A') (3 'A') R ∪ S and R \ S are defined as usual on mathematical sets schema in 1NF. (5 'Z') (3 'A') Therefore NOT Other set operations may be easily defined using ∪ and \ (1 'A' ) (1 'B') an operation of Relational Algebra HS / DBS05-08-RDML1 9 (5 'Z') (1 'B') HS / DBS05-08-RDML1 10

Relational Algebra Basic Operations Projection π Extended cross product X Let Σ(R) = B’, B ⊆ B’

Projection πB (R ) of R on B: Let R and S be relations, Σ(R) ={a1,...,an} ⊆ A , Set of rows from R with the columns not in B eliminated B' Σ(S) = {b1,...,bm} ⊆ A, Σ(R) ∩Σ(S) = ∅ then B

– Schema Σ(R X S): project {R.a1,...R.an, S.b1, …,S.bm} = {R.a | a ∈ A} ∪ {S.b | b ∈ A} Omit relation qualifiers “R.” and “S.” - no naming conflict.

– Extended cross product R X S : R X S = – No duplicates in πB (R ) (in theory!) {(a1,...an,b1,...,bm) | (a1,...,an) ∈ R, (b1,...,bm) ∈ S}

πB (R ) = {r restricted to B | r ∈ R} Renaming, if Σ(R) ∩Σ(S) != ∅ : = {r’ | there is a tuple r ∈ R such that ρ () r’ is the restriction of r to the attributes in B} HS / DBS05-08-RDML1 11 HS / DBS05-08-RDML1 12

2 Relational Algebra Basic Operations Selection σ

"Find movies directed by Billy Wilder made 1960 or later" Parent (id, mother, father) πmother (Parent) = Mary 25 Mary, Paul 47 Mary, John 55 Mary, Paul A relation with only one and one (no duplicates) Selection of from a table R according to a predicate defined on R • Property of projection:

B contains a key of R fl πB (R ) contains as many Predicate P :: R -> {TRUE, FLASE} tuples as R: | πB (R ) | = |R| defined on tuples of R. For each r ∈ R : P(r) = TRUE | FALSE • Useful for estimating the size of query results • Important for optimization

HS / DBS05-08-RDML1 13 HS / DBS05-08-RDML1 14

Primitive predicates Row predicates Boolean row predicates Primitive (simple) predicates: Row predicates combine primitive (simple) predicates by and, or, not and parenthesis '(', ')' Let a, b be attributes, w value from dom (a) a θ b and a θ w are primitive predicates Inductive definition of syntax for (row) predicates where θ∈{ =, !=, <, <=, >, >=} ....as usual: - Primitive predicates are predicates Primitive predicates compare either an attribute and a - If Q, Q’ are predicates, then Q ∧ Q’ , Q ∨ Q’ and ¬Q value or two attributes are predicates - Operator preference and brackets as usual - There are no other predicates e.g. Movie.director = ‘Wilder, Billy' Movies directed by Spielberg before 1999 or an entertainment movie : or Rental.until > Rental.from + 1 month movie.director='Spielberg' ∧ (year <= TO_DATE('1999', 'yyyy') ∨ cat = 'entertainment ) HS / DBS05-08-RDML1 15 HS / DBS05-08-RDML1 16

Propositional semantics Selection of rows Semantics of predicates: Selection σ Let σ (R) = {r | r ∈ R and P(r) = TRUE } a, b be attributes of table R, r ∈ R, P P the predicate a θ v , Q is the predicate a θ b where P is a row predicate r(a) : value for attribute a of tuple r Then Note: P(r) := r(a) θ v - Selection operator selects the row with all attributes: Q(r) := r(a) θ r(b) Σ(R) = Σ (σ P (R) ) - size of result depends on selectivity of P S ≡ P ∧ Q : S(r,t) := P(r) ∧ Q(r) according to ∧ semantics selectivity := | σ P (R) | / | R | important for optimization ¬, ∨ and preference as usual in propositional logic Frequently, θ is equality predicate (=)

HS / DBS05-08-RDML1 17 HS / DBS05-08-RDML1 18

3 Relational Algebra Basic Operations Relational Algebra: combining operators Example π title (σ P ( Movie) ) "Movies directed by Spielberg produced 1997 or later ! " where P = "director = 'Spielberg' and year >= 1997" Movie(mId,title,...,director, year) Find the actors performing in movie directed by σ ( Movie) P Spielberg where P = "director = 'Spielberg' and year >= 1997"

M_ID TITLE CAT YEAR DIRECTOR PRICE_DAY LENGTH ------Select Q Select P +Proj. 2 Amistat Drama 01.04.97 Spielberg 1 120 4 Minority Report Drama 01.04.02 Spielberg 2 145

2 Zeilen ausgewählt. π stage_name (σ P (σ Q ( Movie) X Starring ) where P = "Movie.id = Starring.movieId " Q = "director = 'Spielberg' Wrong result…? "Truth" defined relative to contents of DB Closed world assumption: for all predicates P r ∉R ⇒ P(r) = False HS / DBS05-08-RDML1 19 HS / DBS05-08-RDML1 20

Renaming Renaming

Renaming of relations ρ () Relation is renamed to in the Example: Employee( id, name, boss, …) context of expression

Find subordinates of 'Miller' ρ () Attribute of relation is renamed to in the context of expression π name (σ P (σ Q ( Employee) X Employee ))) where P = "Employee.name = 'Miller' " Q = "Employee.boss = Employee.id " π Sub.name (σ Q (σ P ( Employee X ( ρSub (Employee))))) where P = "Employee.name = 'Miller' " Q = "Sub.boss = Employee.id "

HS / DBS05-08-RDML1 21 HS / DBS05-08-RDML1 22

Evalution example: one table – two roles 6.3 Relational Algebra: Syntax and Semantics Employee EmployeeSub Syntax of (simple) Relational Algebra defined id name boss id name boss NULL ρ 001 Abel NULL 001 Abel Sub (Employee) inductively : 002 Bebel 005 002 Bebel 005 004 Cebel 005 004 Cebel 005 005 Miller 001 005 Miller 001 (1) Each table identifier is a RA expression 006 Debel 001 006 Debel 001 ...... (2) ρ A (B), ρ s ← y (A) are RA expressions where A,B table identifiers, s, v attribute identifiers Employee EmployeeSub

id name boss id name boss (3) If E and F are RA expressions then 001 Abel NULL 001 Abel NULL Abel NULL 002 Bebel 004 π name 001 π D (E), σ P (E), E X F, E ∪ F, E \ F are RA … … … 002 Bebel 005 001 Abel NULL expressions ( if union-compatible etc.) 002 Bebel 005 002 Bebel 005 … … … … …l … 005 Miller 001 001 Abel Null where D ⊆ Σ(E) Miller 001 002 Bebel 005 005 Bebel σP 005 Miller 001 004 Cebel 005 σ (4) These are all RA expressions 005 Miller 001 005 Miller 001 Q 005 Miller 001 006 Debel 001 .. … … … … … 006 Debel 001 005 Miller 001 006 Debel 001 006 Debel 001 HS / DBS05-08-RDML1 23 HS / DBS05-08-RDML1 24

4 Semantics of Relational Algebra 6.4 Relational Algebra : More Operators

val is a function which assigns to each relational algebra Some sequences of operations occur frequently expression a result table: like cartesian product followed by a select val ('R') = R Ö Define compound operators "The value of a relation name is the relation (table)" Join (θ-join) val ('τ (E)' ) = τ (val (E)) R, S relations, R S Important concept where τ is some unary . Operation like π P "The value of an unary applied to an relational algebra expression E is the result of applying the = {(a1, ...an, b1,...bm) | P(a1,...an,b1,...bm ) is true } operator to the value of E " = σP ( R X S) val ('E ω F' ) = val (E) ω val (F) where ω is some binary operator like X where P is a (boolean) predicate composed of primitive "The value of an unary relational operator applied to a predicates of the form relational algebra expression E is the result of applying the a θ b , a ∈Σ(R), b ∈ R Σ(S), θ∈{ =, ≠, <, <=, > >=} operator to the value of E" HS / DBS05-08-RDML1 25 (Join predicate) HS / DBS05-08-RDML1 26

Relational Algebra Join Relational Algebra : more operators R S = 1 A 2 1 3A Equijoin: equality comparison R.a < S.c ∧ R.b=S.d 2 A 2 1 3A The result usually P R(a b c) S(a c d) does not have a name 1A 2 1 3A Important type of join: all primitive predicates in P 2 A 2 2 2 B compare equality of column values of two rows at a 3 C 1 1 2 C time : P ≡ ∧ R.xi = S.yi , {xi} ⊆Σ(R), {yi} ⊆Σ(S), Note: exactly the same as Implements the "values as pointers" concept of RDB taking the set of all pairs of for foreign keys, but is more general. R X S 1 A 2 1 3A R and S rows and checking the predicate subsequently 1 A 2 2 2 B Example using : Find movie title on tape 27 1 A 2 1 2 C 2 A 2 1 3A π title (Movie σ id=27 (Tape)) 2 A 2 2 2 B id=Tape.mid 2 A 2 1 2 C 3 C 1 1 3 A 3 C 1 2 2 B 3 C 1 1 2 C HS / DBS05-08-RDML1 27 HS / DBS05-08-RDML1 28

Example Relational Algebra: more operators

– Renaming required, if identical column names – No canonical projection of columns if columns Movie(mId,title,...,director, year) Tape(id, acDate, are redundant 25 Amistad, . . . Spielberg 1997 format, movieId 35 A.I. Spielberg 2001 11 9-3-98 VHS 25 Example above: mId and movieId 47 Matrix Azzopardi 1993 23 4-6-01 DVD 47 Query with subsequent projection: 55 Private Ryan Spielberg 1998 17 1-3-99 DVD 25 "Find title, tapeId and format for all movies" 25 Amistad . . .Spielberg 1997 11 9-3-98 VHS 25 ( Movie R S = 25 Amistad . . .Spielberg 1997 17 1-3-99 DVD 25 π title, id, format Tape ) Movie.mId = Tape.movieId 47 Matrix … Azzopardi 1993 23 4-6-01 DVD 47 Movie.id = Tape.movieId Amistad 11 VHS Result: Amistad 17 DVD Matrix 23 DVD

HS / DBS05-08-RDML1 29 HS / DBS05-08-RDML1 30

5 Relational Algebra: Natural join Realtional algebra: outer join Natural Join R S : Motivation: only tuples of S participate in a join equijoin over all literally identical column names R S, which have a "counterpart" in R. of R and S and projection of redundant columns.

Join predicate omitted . Customer(mem_no,name,f_name, zip, city) R.a, R.b, R.c, S.d Phones (phoneNo, mem_no) R(a b c) S(a c d) 1 A 2 1 3 A 2 A 2 B "Print telephon list of customers" R S= 1 A 2 C 2 A 2 2 2 B π name, phoneNo ( Customer Phones) 3 C 1 1 2 C

Customers without phoneNo will not appear R S = π Σ(R) ∪Σ(S) (σ P (R X S)) where P ≡ ∧ R.x = S.x, x ∈Σ(R) ∩Σ(S)

HS / DBS05-08-RDML1 31 HS / DBS05-08-RDML1 32

Relational Algebra: outer join Relational Algebra: outer join Left outer join R S Right outer join R S P Includes ( NULL,…NULL, s ) – if there is no join partner Includes (r, NULL,…NULL) – if there is no join partner for s ∈ S for r ∈ R a b c a c d a b c a c d 1A 2 1 3A 1A 2 R.a < S.c R.b=S.d = 1 A 2 1 3A 1 3A ∧ R.a < S.c ∧ R.b=S.d = 1 A 2 1 3A 2 A 2 2 A 2 1 3A 2 A 2 2 2 B 2 2 B 2 A 2 1 3A 3 C 1 ---2 2 B 3 C 1 3 C 1 - - - 1 2 C 1 2 C ---1 2 C R S = Full outer join: union of left and right outer join P 1A 2 1 3A R.a < S.c ∧ R.b=S.d = 1 A 2 1 3A R S ∪ { (r ,…r , NULL,,…NULL)| (r ,…r ) ∈ R, and for 2 A 2 1 n 1 n 2 2 B 2 A 2 1 3A P all (s1,..,sm ) ∈ S, (r1,…rn) ∈ R: P (r1,…rn, s1,..sm) =FALSE } 3 C 1 3 C 1 - - - 1 2 C ---2 2 B ---1 2 C Outer join typically extension of equijoin HS / DBS05-08-RDML1 33 HS / DBS05-08-RDML1 34

Relational Algebra More operators Relational Algebra: Base operators Semjoin Base

R S = Π Σ(R) (R S) Set of operators which allow to express all other operators Left Semijoin is the subset of R, each r of which has e.g { ∧, ∨, ¬ } in propositional logic a corresponding tuple s from S in the join. Typically extension of equijoin or natural join Relational operators R(a b c) S(a c d) (a b c) π, σ, X , \ and ∪ form a basis of relational algebra operators 1A 2 Means: every RA expression may be expressed only with 1 3A R.a = S.c ∧ R.b=S.d = 1 A 2 2 A 2 these operators 2 2 B 3 C 1 1 2 C Example: R S = σ P ( R X S) Right Semijoin defined symmetrically : P

RS= Π Σ(S) (R S)

HS / DBS05-08-RDML1 35 HS / DBS05-08-RDML1 36

6 Relational Algebra: table predicates Relational Algebra: Division

F= π format Row predicates: T= π format,movieID Tape(id,format,movieId) Format(format,extra_Ch))

p defined over rows (or pairs of rows) 1 VHS 7 VHS 0.0 Result: 1 7 2 DVD 7 DVD 1.0 2 7 VHS 55 4 HQ 1.5 8 7 Table predicates 5 VHS 1 Example: find all movies which are available in all formats 8 HQ 7 Find movies which are available in all formats Cannot be answered by comparing individual rows 11 VHS 25 17 DVD 25

Predicates with universal quantifier are table predicates Relational Division e.g. P(x) ≡ ∀x ∃ y (Q(x,y,m) Informally T . /. F is the set of all tuples r of T "for all formats (in the database) x there exists a tape y with movie m" projected on attributes not belonging to F Express table predicates with base operators? such that {(r )} X F ⊆ T

HS / DBS05-08-RDML1 37 HS / DBS05-08-RDML1 38

Relational Algebra: an operator based on table predicates Relational Algebra Division

Relational Division T . /. F T ./. F may be defined in terms of other relational operators – Simulates universal quantifier for finite sets – In order to divide T by F, the attributes of F must be a T ./. F = π D (T) \ (π D (π D (T) X F) \ T) subset of the attributes of T: Σ(F) ⊂Σ(T) – Signature of T ./. F is D = Σ(T) \ Σ(F) The "missing" tuples of T T ./. F = { t’ | t’ ∈πD (T) ∧ ( ∀ s ∈ F) (∃ t ∈ T) π’ (t) = s ∧π’ (t) = t' } Σ(F) D Building the D = Σ(T) \ Σ(F) π’ denotes the projection of a row as opposed to π, which is defined Proof: Assignment on tables. Property of relational division: π D (T) = {(7), (55), (1), (25)} Let D = Σ(T) \ Σ(F) , F = {VHS,DVD, HQ} if D contains the key of T and |F| > 1 then T ./. F = ∅ let t' be (55), for s = (DVD) there is no tuple (DVD, 55) in T. t' = (7) is the only one which qualifies

HS / DBS05-08-RDML1 39 HS / DBS05-08-RDML1 40

Relational Algebra RA expression examples 6.5 Special Topics of RA Examples find algebraic expressions 6.5.1 RA operators in SQL/DML C(mem_No,name,..,) T(id, m_Id, f) R(tape_Id,from, mem_No,..) – Transformation rule: for every relational algebra expression M(id,title,...) with join, project, cartesian product and select operations 0. Movies (m_Id) and its formats there is an equivalent expression of the form: π m_id, format (T) π …. ( σ P (R1 X R2 X … X R n ) ) 1. Tapes loaned by 'Abel' π tape_Id (R σ name='Abel' (C)) Simple SQL (Sequel ) block: 2. List of films that are currently available (i.e. not rented by anyone) SELECT DISTINCT a,b,….. π (M) \ π (R T M)) title title ' projection tape_Id=id m_Id=M.id FROM R1 ,…, R n WHERE < predicate P > cartesian product 3. First name, last name of customers who rented “To be or not to predicate be” …. 4. List of customers and the films they have currently rented … DISTINCT : Elimination of duplicates 5. Has 'Bebel' loaned a tape? Cannot be formluated, why? 6. Find the films which a available in all formats.HS / DBS05-08-RDML1…. 41 HS / DBS05-08-RDML1 42

7 Relational Algebra and SQL 6.5.2 Relational completeness "Find title, tapeId and format for all movies" • Completeness … SELECT DISTINCT m.title, t.id, – A DB language L is called relational complete, if t.format every RA expression can be expressed in L FROM Movie m, Tape t Old Notation – Are there any operations on relations, which cannot WHERE m.mId(+) = t.movieId for left outer join, ORDER BY title; be expressed by a finite RA expression (select, project, product or join; SPJ) ? SELECT DISTINCT m.title, t.id, tt.format New notation FROM Movie m LEFT OUTER JOIN Tape t –Yes: of a relation cannot be ON m.mID = t.movieID ORDER BY title; expressed in this way

Pred Descend Movies TapeNO FORMA ------Paul Mary No RA expression to find all decendents of 'Paul'. Amistad 11 VHS Mary Peter A.I. 17 DVD Matrix 23 DVD John Bill Recursion is missing! Private Ryan HS / DBS05-08-RDML1 43 Peter George HS / DBS05-08-RDML1 44

6.5.3 What is missing in RA 6.5.4 Relational Algebra operator trees

– Arithmetic operators, Algebraic Optimization – many practically important operators like grouping of – Evaluation of RA expressions in canonical form results π …. ( σ P (R1 X R2 X … X R n ) ) "find movies together and their number of copies" is very inefficient

Title copyCount – How to speed up evaluation of RA (and SQL) Amistad 2 expressions? To be or .. 3 – Example: Two tables R and S with n and m tuples Private Ryan 1 Marnie 1 Worst case complexity of : The Kid 2 σ P (R S) – More Predicates on tables (not rows) is O(m*n) Anyway relational algebra important conceptual basis for – Interchange of select and join may result in O(n+m) query languages and query evaluation time σP (R ) S depending on the join algorithm

HS / DBS05-08-RDML1 45 HS / DBS05-08-RDML1 46

Some rewrite rules for RA Relational Algebra Using RA for opitmization

– An relational algebra operator is the data structure Properties of selection and projection representing a RA expression σ P (σ Q (R) ) = σ Q (σ P (R) ) Compare with operator trees for arithmetic expressions σ P (σ P (R) ) = σ P (R) – Algebraic optimization: systematic interchange of operation according to the laws of RA σ Q ∧ P (R) = σ Q (σ P (R) ) = σ Q (R) ∩σ P (R) – Does not change time complexity in general, σ Q ∨ P (R) = σ Q (R) ∪σ P (R) but “makes n small”. σ ¬ P (R) = R \ σ P (R) – Implementation of Algebraic Optimization by transformation of the operator tree if X ⊆ Y ⊆Σ(R) then π (π (R) ) = π (R) X Y X – Evaluation by recursive evaluation of the tree if X, Y ⊆Σ(R) then πX(πY(R) ) = πX ∩Y(R) = πY(πX(R) ) attr(P) ⊆ X ⊆Σ(R) then π (σ (R) ) = σ (π (R) ) X P P x – Systematic treatment of different optimization techniques where attr(P) denotes the set of attributes used in P Æ Part II (Implementation) HS / DBS05-08-RDML1 47 HS / DBS05-08-RDML1 48

8 RA Operator tree transformation: example 6.5.5 Multivalued dependencies and 4NF Operator tree: example "Last name of customers who Multiple values: example (left over from ch. 5: Normal Forms) rented “To be or not to be” ) Person (name, affiliation, hobbies) Π name Redundancy introduced Π Meier FUB skiing by multiple values name Müller TUB trekking Meier FUB trekking 'hobbies' is multivalued σ title = ‘ To be or.. ’ dependent on name Π mem_No Schulze HU skating Π name,mem_No M Definition for single attribute multi valued (MV) C dependencies: C Π tape_Id,mem_No Let R = (a, y, b), T R R Π mId b is multivalued dependent on a (a ->>b) if for each value v of a {v} X (π (σ R)) X (π (σ R)) ⊆ R Π id,movieId y a=v b a=v σ title = ‘ To be or.. ’ Example: {'Meier'} X {'FU'} X {'skiing', 'trekking'} ⊆ Person T {'Müller'} X {'TU'} X {'trekking'} ⊆ Person {'Schulze'} X {'HU'} X {'skating'} ⊆ Person HS / DBS05-08-RDML1 49 M HS / DBS05-08-RDML1 50

Fourth Normal Form Summary A relation R is in Fourth Normal Form • Relational algebra: algebra on tables if for every MVD A ->> B •B ⊆ A or • Operators: project, select, cartesian product, •B = Σ(R) \ A or union, set difference, (rename) • A contains a key • Several compound operators : join, outer join, semi-join, division May be easily calculated by splitting up a relation R with a MVD A->> B into R1 and R2 such that • Serves as a basis for relational DB languages Σ(R1) = A ∪ B, Σ(R2) = Σ(R) \ Σ(R1) ∪ A • No recursion Ö not computationally complete Müller TUB Müller trekking • Base of SQL Meier FUB Meier trekking Schulze HU Meier skiing • Used for optimization by operator tree Schulze skating transformation

Better to have multi valued attributes? HS / DBS05-08-RDML1 51 HS / DBS05-08-RDML1 52

9