You are on page 1of 12

18CS440 / Database Management Systems 2020

DATABASE DESIGN

 Conceptual database design gives us a set of relation schemas and integrity


constraints (ICs) that can be regarded as a good starting point for the final
database design.
 Example 1 : Combining smaller relation

 Example 2 : Combining smaller relation

Bor_loan has repetition of information (L-100 )

 Redundant storage of information is the root cause of many problems.

 Decomposition can eliminate redundancy.


Dr. A.M. Rajeswari, CSE, TCE Page 1 of 12
18CS440 / Database Management Systems 2020

 Example 1 :

 Although decomposition can eliminate redundancy, it can lead to problems of its


own and should be used with caution.
 Example 2 : ( Lossy Decomposition )

Dr. A.M. Rajeswari, CSE, TCE Page 2 of 12


18CS440 / Database Management Systems 2020

 Problems Caused by Redundancy


o Redundant storage: Some information is stored repeatedly.
- Can be avoided using PRIMARY / UNIQUE constraints
o Insertion anomalies: If a tuple is inserted in referencing (child) relation
and referencing attribute value is not present in referenced (parent)
attribute, it will not allow inserting in the referencing relation.
- Can be overcome using Integrity constraints.
o Update or Deletion anomalies: If a tuple is deleted or updated from
referenced (parent) relation and referenced attribute (parent) value is used
by referencing (child) attribute in referencing relation, it will not allow
deleting the tuple from referenced (parent) relation.
- Can be avoided using ON DELETE/UPDATE CASCADE option in
the referencing (child) table.
 The initial database design must be refined by taking the following ICs into
account
- Functional dependencies.
- Multivalued dependencies.
- Join dependencies,

 Keys and, more generally, functional dependencies, are constraints on the database
that require relations to satisfy certain properties. Relations that satisfy all such
constraints are legal relations.

 These constraints will help in obtaining lossless decomposition

Dr. A.M. Rajeswari, CSE, TCE Page 3 of 12


18CS440 / Database Management Systems 2020

FUNCTIONAL DEPENDANCY
 Constraints on the set of legal relations.
 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 relation schema and   R and   R
 The functional dependency

holds on R if and only if for any legal relations 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 [ ]
 Example :
A B
A  B holds on ‘R’
1 4
2 5 ‘r’ satisfies ‘F’
3 7
1 4
 K is a superkey for relation schema R if and only if K  R
 Functional dependencies allow us to express constraints that cannot be
expressed using superkeys. Consider the schema:
bor_loan = (customer_id, loan_number, amount ).
 The functional dependency loan_number  amount hold , but loan_number is
not a superkey.

Dr. A.M. Rajeswari, CSE, TCE Page 4 of 12


18CS440 / Database Management Systems 2020

Use of Functional Dependencies


 We use functional dependencies to:
1. Test relations to see if they are legal under a given set of functional
dependencies.
- If a relation r is legal under a set F of functional
dependencies, we say that r satisfies F.
2. Specify constraints on the set of legal relations
- We say that F holds on R if all legal relations on R satisfy
the set of functional dependencies F.

Note: A specific instance of a relation 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 may, by chance, satisfy
amount  customer_name.

 A functional dependency is trivial if it is satisfied by all instances of a relation.


( they are also satisfied by all relation )
 In general,    is trivial if    ( Reflexitivity Rule )
 Example:
customer_name, loan_number  customer_name
customer_name  customer_name

Dr. A.M. Rajeswari, CSE, TCE Page 5 of 12


18CS440 / Database Management Systems 2020

Armstrong’s Axioms:
( Inference Rules for reasoning functional dependencies )
 if   , then    holds (reflexivity)

 if   , then      holds (augmentation)

 if   , and   , then    holds (transitivity)

 If    holds and    holds, then     holds (union)

 If     holds, then    holds and    holds (decomposition)

 If    holds and     holds, then     holds (pseudotransitivity)

 These rules are


- Sound ( generate only functional dependencies that actually hold)
- Complete ( generate all functional dependencies that hold ).
Dr. A.M. Rajeswari, CSE, TCE Page 6 of 12
18CS440 / Database Management Systems 2020

Closure of a Set of Functional Dependencies ( F+ )


 Given a set F of functional dependencies, there are certain other functional
dependencies that are logically implied by F.
 For example: If A  B and B  C, then we can infer that A  C
 The set of all functional dependencies ‘F’ which are inferred ie logically implied
by F is the closure of F and is denote by F+.
 F+ is a superset of F.

 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 ( by transitivity from A  B and B  H )
- AG  I ( by augmenting A  C with G, to get AG  CG
and then transitivity with CG  I )
- CG  HI ( by augmenting CG  I to infer CG  CGI,
and augmenting of CG  H to infer CGI  HI, and then
transitivity )

Dr. A.M. Rajeswari, CSE, TCE Page 7 of 12


18CS440 / Database Management Systems 2020

Procedure for Computing F+


F+=F
repeat
for each functional dependency f in F+
apply reflexivity and augmentation rules on f
add the resulting functional dependencies to F +
for each pair of functional dependencies f1and f2 in F +
if f1 and f2 can be combined using transitivity
then add the resulting functional dependency to F +
until F + does not change any further

Closure of Attribute Sets ( A+ )


Given a set of attributes a, define the closure of a under F (denoted by a+) as the set
of attributes that are functionally determined by a under F
 Algorithm to compute a+, the closure of a under F
result := a;
while (changes to result) do
for each    in F do
begin
if   result then result := result  
end

Dr. A.M. Rajeswari, CSE, TCE Page 8 of 12


18CS440 / Database Management Systems 2020

Example : Attribute Set Closure

Let R be a relational schema R (A, B, C, D)


Simple set of F= { AB -> C, C -> D, D -> A }
 Singletons
A+ -> A B+ -> B
C+ -> CDA D+ -> AD
 Pairs (note commutative)
AB+ -> ABCD AC+ -> ACD
AD+ -> AD BC+ -> ABCD
BD+ -> ABCD CD+ -> ACD
 Triples
ABC+ -> ABCD ABD+ -> ABCD
BCD+ -> ABCD
 Quadruples
ABCD+ -> ABCD

Superkeys:
AB, BC, BD, ABC, ABD, BCD, ABCD

Minimal superkeys (keys)


AB, BC, BD

Dr. A.M. Rajeswari, CSE, TCE Page 9 of 12


18CS440 / Database Management Systems 2020

Uses of Attribute Closure


 Testing for superkey:
- To test if  is a superkey we compute +, and check if + contains all
attributes of R.
 Testing functional dependencies
- To check if a functional dependency    holds (or, in other
words, is in F+), just check if   +.
- That is, we compute + by using attribute closure, and then check
if it contains .
- Is a simple and cheap test, and very useful
 Computing closure of F
- For each   R, we find the closure +, and for each S  +, we
output a functional dependency   S.

Multivalued Dependencies (MVDs)


 Let R be a relation schema and let   R and   R. The multivalued
dependency
  
holds on R if in any legal relation r(R), for all pairs for tuples t1 and t2 in r such
that t1[] = t2 [], there exist tuples t3 and t4 in r such that:
t1[] = t2 [] = t3 [] = t4 []
t3[] = t1 []
t3[R –  – ] = t2[R –  – ]

Dr. A.M. Rajeswari, CSE, TCE Page 10 of 12


18CS440 / Database Management Systems 2020

t4 [] = t2[]
t4[R –  – ] = t1[R –  – ]
 Tabular representation of   

 Example Multivalued Dependencies

Teaching database
Course Book Lecturer
AHA Silberschatz John D
AHA Nederpelt William M
AHA Silberschatz William M
AHA Nederpelt John D
AHA Silberschatz Christian G
AHA Nederpelt Christian G
OSO Silberschatz John D
OSO Silberschatz William M

Course  Book & Course  Lecturer


 Databases with multivalued dependencies, thus exhibit redundancy.
Dr. A.M. Rajeswari, CSE, TCE Page 11 of 12
18CS440 / Database Management Systems 2020

Use of Multivalued Dependencies


 We use multivalued dependencies in two ways:
1. To test relations to determine whether they are legal under a given set of
functional and multivalued dependencies
2. To specify constraints on the set of legal relations. We shall thus concern
ourselves only with the relations that satisfy a given set of functional and
multivalued dependencies.

Join Dependencies
A join dependency is a further generalization of MVDs. A join dependency
(JD) { R1,…., Rn } is said to hold over a relation R if R1,…., Rn is a lossless-join
decomposition of R.

An MVD X  Y over a relation R can be expressed as the join dependency


{ XY, X(R−Y) }. As an example, in the CTB relation, the MVD C T can be
expressed as the join dependency { CT, CB }.
Unlike FDs and MVDs, there is no set of sound and complete inference rules for JDs.

**********************

Dr. A.M. Rajeswari, CSE, TCE Page 12 of 12

You might also like