•   Introduction•   Characteristics Of “BAD” Schema•   What Is Functional Dependency?•   Armstrong’s Reference Rules•   Eq...
• The main aim for Database Design is coming up with “GOOD” schema.• Problem-      1.How do we characterize the “GOODNESS”...
• Redundant storage of DATA     - Office Phone & HOD info – stored redundantly-wastage of disk space• A program that updat...
• Functional dependencies (FDs) are used to specify formal measures of the"goodness" of relational designs• FDs and keys a...
•Armstrong shows that Rules 1,2,3 aresound & Complete.•These are calledArmstrong’sAxioms(AA)SOUNDNESS-•Every new FD X → Y ...
COMPLETENESS-• Any FD X→Y logically implied by F (i.e. F╞ {X→Y} ) can be derived from F  using AACLOSURE OF A SET OF FDs-•...
• EQUIVALENCE of sets of FDs:   Two sets of FDs F & G are equivalent if F =G i.e. Every FD in F can be   inferred from G &...
Functional                            dependency No transitive                            of nonkey dependency            ...
• Un-normalized relations:   First step in normalization is to convert the data into 2D table.   Data can be repeated with...
•   Full Functional Dependency:A FD X → Y is said to be a FULL FD if after removal of any attribute fromX, the FD doesn’t ...
DESIRABLE PROPERTIES OF DECOMPOSITION:•   Not all Decomposition of a schema are useful.•   We require two properties to be...
• EID → Name, Address, Birthdate• EID, Pname → StartDate• Candidate key is {EID, PName}.• The nonprime attributes are Name...
• 2NF, plus no transitive functional dependencies.• Given three attributes in a relation A, B, C, if A  B and B  C, this...
Solution:
• Most 3NF relations are also BCNF relations.• A 3NF relation is NOT in BCNF if:     Candidate keys in the relation are c...
Fourth Normal Form ( 4 NF)• Any relation is in Fourth Normal Form if it is BCNF and any multi-valued dependencies are   tr...
• De-normalization is the process of modifying aperfectly normalized database design for performancereasons.• It is a natu...
Customer        After:    CustomerBefore:            ID                        ID            Address                   Add...
• The foreign key(or referential integrity)constraint can not be specified asa functional or multi-valued dependency becau...
• After we have the ER diagrams each relation in the schema must beindependently reviewed and normalized when needed.• Fun...
• Fundamentals of Database systems,5th edition by Ramez Elmasari,Shamkant B. Navathe• Database system concepts by A. Seilb...
Theory of dependencies in relational database
Theory of dependencies in relational database
Theory of dependencies in relational database
Theory of dependencies in relational database
Theory of dependencies in relational database
Theory of dependencies in relational database
Upcoming SlideShare
Loading in...5
×

Theory of dependencies in relational database

1,472

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,472
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
78
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Theory of dependencies in relational database

  1. 1. • Introduction• Characteristics Of “BAD” Schema• What Is Functional Dependency?• Armstrong’s Reference Rules• Equivalence & Minimal Cover• Normalization• Normalization Types And Details• BCNF• Higher Normal Forms• De-Normalization• Multi-valued Dependencies(MVD)• Join Dependencies• Inclusion Dependencies• Conclusion• References
  2. 2. • The main aim for Database Design is coming up with “GOOD” schema.• Problem- 1.How do we characterize the “GOODNESS” of a schema? 2.If two or more alternative schemas are available , how do we compare them? 3.What are the problems with “BAD” schema?• An example-
  3. 3. • Redundant storage of DATA - Office Phone & HOD info – stored redundantly-wastage of disk space• A program that updates Office Phone of a department must change it atseveral places - more running time & error proneANOMALIES- a. Insertion anomaly - No way of inserting info about a new departmentunless we also enter details of a (dummy) student in department. b. Deletion anomaly – If all students of a certain department leave and wedelete their tuples , information about department itself is lost . c. Update anomaly – Updating office phone of a department 1. value in several tuples need to be changed 2.if a tuple is missed-inconsistency in data
  4. 4. • Functional dependencies (FDs) are used to specify formal measures of the"goodness" of relational designs• FDs and keys are used to define normal forms for relations.NORMAL FORMS - 1. Each NF specifies certain conditions. 2. If the conditions are satisfied by the schema certain kind of problems are avoided Consider the schema Student(s.name,rollno.,gender,dept, h.name,roomno.} Since rollno. Is a key, Rollno. →{s.name,gender,dept, h.name,roomno.} Let each student is given a hostel room, Then h.name,roomno. → rollno.
  5. 5. •Armstrong shows that Rules 1,2,3 aresound & Complete.•These are calledArmstrong’sAxioms(AA)SOUNDNESS-•Every new FD X → Y Derived from a givenset of FDs F using AA is suchthat F ╞ {X → Y)
  6. 6. COMPLETENESS-• Any FD X→Y logically implied by F (i.e. F╞ {X→Y} ) can be derived from F using AACLOSURE OF A SET OF FDs-• Closure of a set of FDs is the set F+ of all the FDs that can be inferred from F.• Closure of a set of attributes X w.r.t F is the set of X + of all attributes that are Functionally determined by XEx- P{a, b, c, d, e, f} set of FDs F on it, as follows: F={a → d, b →{e, f}, {a, b }→ c} F+ :the closure of F a + ={a, d} b + ={b, e, f} {a, b} + ={a, b, c, d, e, f}
  7. 7. • EQUIVALENCE of sets of FDs: Two sets of FDs F & G are equivalent if F =G i.e. Every FD in F can be inferred from G & every FD in G can be inferred from F.• EXTRANEOUS ATTRIBUTE: The removal of which attribute doesn’t change F + . Ex- Given F={A → C, AB → C} B is extraneous in AB → C as A → C logically implies AB → C .• MINIMAL COVER: A minimal cover of a set of FDs G is a minimal set of dependencies F that is equivalent to E. Here F + =G +, if we modify G by deleting an FD or by deleting attribute From an FD in G, the closure changes. RHS of each FD in G is a single attribute.Ex-{A → B, ABCD → E, EF → GH, ACDF → EG} has the following minimal Cover: {A → B, ACD → E, EF → G, EF → H}
  8. 8. Functional dependency No transitive of nonkey dependency attributes on between the primary nonkey attributes Boyce- key - Atomic values only Codd and Higher FullAlldeterminants Functionalare candidate dependencykeys - Single of nonkeymultivalued attributes ondependency the primary key
  9. 9. • Un-normalized relations: First step in normalization is to convert the data into 2D table. Data can be repeated within a column.• First Normal Form (1 NF) Only atomic values at each row and column.• Second Normal Form (2 NF) A relation is said to be in Second Normal Form when every non-keyattribute is fully functionally dependent on the primary key. Applicable for composite key & when there is composite key , theremay exist partial FD, which 2NF denies, So to get 2NF we have toDecompose it into Relation schema. After Decomposition , it is Lossless or NOT should be verified.
  10. 10. • Full Functional Dependency:A FD X → Y is said to be a FULL FD if after removal of any attribute fromX, the FD doesn’t hold good anymore.• Partial Functional Dependency:A FD X → Y is partial FD if {X-A} → Y is also true.• Decomposition: Let R=(A,B,C,D) X=(P,Q,S,T) st. R= P υ Q υ S υ T Replacing R by P,Q,S,T- process of decomposing R
  11. 11. DESIRABLE PROPERTIES OF DECOMPOSITION:• Not all Decomposition of a schema are useful.• We require two properties to be satisfied. Lossless join property- The information in an instance r of R must be preserved in the instances .* If R is decomposed into P , Q and P ∩ Q ≠ Φ , then it is lossless. Dependency preserving property:- if a set F of dependencies hold on R it should be possible to enforcing appropriate dependencies on each r.
  12. 12. • EID → Name, Address, Birthdate• EID, Pname → StartDate• Candidate key is {EID, PName}.• The nonprime attributes are Name, Address, Birthdate, StartDate.• Nonprime attributes Name, Address, Birthdate violate 2NF because theyare functionally dependent
  13. 13. • 2NF, plus no transitive functional dependencies.• Given three attributes in a relation A, B, C, if A  B and B  C, thisforms a transitive functional dependency.• Avoid transitive dependencies for 3NFEx- Here, Customer_ID  Salesperson, and Salesperson Region, cause a transitive dependency
  14. 14. Solution:
  15. 15. • Most 3NF relations are also BCNF relations.• A 3NF relation is NOT in BCNF if:  Candidate keys in the relation are composite keys (they are not single attributes)  There is more than one candidate key in the relation, and  The keys are not disjoint, that is, some attributes in the keys are common Patient # Patient Name Patient Address 15 New St. New 1111 John White York, NY 10 Main St. Rye, 1234 Mary Jones NY Charles Dogwood Lane 2345 Brown Harrison, NY 55 Boston Post 4876 Hal Kane Road, Chester, Blind Brook 5123 Paul Kosher Mamaroneck, NY Hilton Road 6845 Ann Hood Larchmont, NY
  16. 16. Fourth Normal Form ( 4 NF)• Any relation is in Fourth Normal Form if it is BCNF and any multi-valued dependencies are trivial• Eliminate non-trivial multi-valued dependencies by projecting into simpler tablesJOIN DEPENDENCIES• A join dependency denoted by JD (R1,R2,R3,……Rn), specified on relational schema R specifies a constraint on the states r of R. The constraint states that every legal state r of R should have a non-additive join decomposition into R1,R2,….. Rn NOTE - An MVD is a special case of JD where n=2 i.e. a JD denoted as JD (R1,R2) implies an MVD (R1∩R2) →→(R1-R2)Fifth Normal Form• A relation is in 5NF if every join dependency in the relation is implied by the keys of the relation.• Implies that relations that have been decomposed in previous NF can be recombined via natural joins to recreate the original relation
  17. 17. • De-normalization is the process of modifying aperfectly normalized database design for performancereasons.• It is a natural and necessary part of databasedesign, but must follow proper normalization.• It always makes your system potentially lessefficient and flexible. So de-normalize as needed, but not frivolously.
  18. 18. Customer After: CustomerBefore: ID ID Address Address Name Name Telephone Telephone Order Order Order No Order No Date Taken Date Taken Date Dispatched Date Dispatched Date Invoiced Date Invoiced Cust ID Cust ID Cust Name
  19. 19. • The foreign key(or referential integrity)constraint can not be specified asa functional or multi-valued dependency because it relates attributes acrossrelations.• An ID R.X<S.Y between two sets of attributes – X of relation schema R &y of relation schema S – specifies the constraint that at any specific timewhen r is a relation state of R and s a relation state of S , we have ╥y(s(S)) ⊇ ╥x(r(R)) Condition• X of R and Y of S must have same no. of attribute.• The domains for each pair of corresponding attribute should becompatible. So far no normal form have been developed based on ID
  20. 20. • After we have the ER diagrams each relation in the schema must beindependently reviewed and normalized when needed.• Functional dependencies are the building blocks that enable theanalysis of data redundancy and the elimination of anomalies causedby data redundancy through the process of normalization• Normalization is a technique that facilitates systematic validationof participation of attributes in a relation schema from a perspectiveof data redundancy.• This process gives us the final opportunity to correct errors andestablish a robust design before implementing the database system
  21. 21. • Fundamentals of Database systems,5th edition by Ramez Elmasari,Shamkant B. Navathe• Database system concepts by A. Seilberschatz, H. korth, SSudersan• An introduction to Database system by C.J. Date• Lotito, J. (2001). Concepts of Database Design and Management.Retrived September 2007 fromhttp://www.sitepoint.com/article/database-design-management• Scamell, R.W., & Umanath N.S. (2007). Data Modeling and Database Design: Boston, MA: Thomson
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×