Beruflich Dokumente
Kultur Dokumente
A decomposition of a relation R, on which the dependencies F hold, into relations R1and R2 is dependency preserving if: (FR1 FR2)+ = F+ Where FR1 is the set of dependencies that apply between attributes only in R1 and similarly FR2 is the set of dependencies that apply between attributes only in R2.
Preserving FD's
Consider a relation (Project,Project-Budget,Department,DeptAddress) with following functional dependencies:
Preserving FD's
We decompose the PROJECTS relation into two relations on which two corresponding sets of FDs held: (Project,Project-Budget,Department) (Department, Dept-Address) Is it preserving FDs ?
Relational Calculus
Introduction
Procedural Query language query specification involves giving a step by step process of obtaining the query result e.g., relational algebra usage calls for detailed knowledge of the operators involved difficult for the use of non-experts
Declarative Query language query specification involves giving the logical conditions the results are required to satisfy easy for the use of non-experts
Proposition logic is concerned only with sentential connectives such as and, or, not. Predicate Logic, where a logic is concerned not only with the sentential connectives but also with the
Answer is the set of all tuples T for which the formula p(T) evaluates to true. Formula is recursively defined:
ystart with simple atomic formulas (get tuples from relations or make comparisons of values) ybuild bigger and better formulas using the logical connectives.
TRC Formulas
An Atomic formula is one of the following:
R Rel R.a op S.b R.a op constant constant op R.a
,>,=,, ,
where p and q are formulas
R (p ( R)) R ( p ( R))
in a formula
Boats
Sid 22 22 22 22 31 31 31 64 64 74
Bid 101 102 103 104 102 103 104 101 102 103
Day 10/10/11 10/10/11 10/8/11 10/7/11 11/10/11 11/6/11 11/12/98 9/5/11 9/8/11 9/8/11
age
35.0 33.0 35.5 45.5 45.0 35.0 16.0 45.0 33.5 33.5
Sailors
Reserves
Find names and ages of sailors with rating above 7. {P | S1 Sailors(S1.rating > 7 P.sname = S1.sname P.age = S1.age)}
Note, here P is a tuple variable of 2 fields (i.e. {P} is a projection of sailors), since only 2 fields are ever mentioned and P is never used to range over any relations in the query.
Joins
Find sailors rated > 7 whove reserved boat #103 {S | SSailors S.rating > 7 R(RReserves R.sid = S.sid R.bid = 103)} Note the use of to find a tuple in Reserves that `joins with the Sailors tuple under consideration.
Joins (continued)
a b is the same as a b
b T F
If a is true, b must be true for the implication to be true. If a is true and b is false, the implication evaluates to false.
F
T a