cafs
Module Overview
Module 5: Database Design Theory and Normalization
Key Topics:
Informal Design Guidelines for Relation Schemas
Functional Dependencies, Inference Rules, Equivalence, and Minimal Cover
Properties of Relational Decompositions
Algorithms for Relational Database Schema Design
Normal Forms Based on Primary Keys
Boyce-Codd Normal Form (BCNF)
Multi-Valued Functional Dependencies
Fourth Normal Form (4NF)
Fifth Normal Form (5NF)
Database Design Approaches
Bottom-Up Design Methodology:
Starts with attributes and constructs relation schemas based on individual binary relationships.
Less popular due to the need to gather many relationships initially.
Top-Down Design Methodology:
Begins with attribute groupings that naturally exist together.
Relations are analyzed and decomposed further to meet design criteria.
Informal Design Guidelines for Relation Schemas
Clear Semantics to Attributes:
Design relation schemas that are easy to explain and interpret.
Avoid mixing attributes from different entity or relationship types within a relation.
Redundant Information and Update Anomalies:
Minimize storage usage and avoid redundancy in tuples.
Example: Natural join can lead to repeated data (e.g., department info in employee relations)
Must address anomalies: insertion, deletion, modification.
Insertion Anomalies:
Insertion may require providing complete department information even when inserting a new employee.
A new department cannot be added if it has no employees, violating entity integrity.
Deletion Anomalies:
Deleting the last employee of a department may lead to loss of department info.
Modification Anomalies:
Changing department details requires updating all associated employee records.
Avoid NULL Values:
Excessive NULL values waste space and can complicate aggregate operations.
Guidelines for Base Relations
Design schemas that eliminate insertion, deletion, or modification anomalies.
Avoid having many attributes with frequent NULL values; ensure that any NULLs are exceptional.
Generation of Spurious Tuples
Spurious Tuples:
Arise from incorrect joins where non-key attributes are not maintained as foreign keys.
Functional Dependencies (FDs)
A functional dependency, X -> Y indicates that the value of Y is determined by X.
Determining the closure of a set of attributes (X+):
All attributes that can be functionally derived from X based on functional dependencies.
Inference Rules for FDs
Reflexive: If X ⊆ Y, then Y->X holds.
Augmentation: If X->Y, then XZ->YZ.
Transitive: If X->Y and Y->Z, then X->Z.
Decomposition: If X->YZ, then X->Y and X->Z hold.
Maintenance of Functional Dependencies
Equivalence of Functional Dependency Sets:
Two sets of dependencies are equivalent if each can infer the other.
Minimal Set of Functional Dependencies:
A minimal cover has each FD with a singleton right-hand side and cannot lose redundancy or dependency.
Normal Forms
First Normal Form (1NF)
Requires that attributes must have atomic values (no multi-valued attributes).
Second Normal Form (2NF)
Nonprime attributes in R must be fully functionally dependent on the primary key, ensuring no partial dependencies.
Third Normal Form (3NF)
A relation is in 3NF if it is in 2NF and there are no transitive dependencies of nonprime attributes on the primary key.
Boyce-Codd Normal Form (BCNF)
A relation schema is in BCNF if every functional dependency X->Y has X as a superkey.
Fourth Normal Form (4NF)
Addresses multi-valued dependencies. A relation is in 4NF if every nontrivial MVD implies that X is a superkey.
Fifth Normal Form (5NF)
A relation is in 5NF if, for every join dependency, every segment is a superkey.
Properties of Relational Decompositions
Attribute Preservation: Each attribute in R must appear in at least one relation schema to avoid data loss.
Dependency Preservation: Decomposition must capture all functional dependencies represented in the original schema.
Nonadditive Join Property: Guarantees no spurious tuples are generated after decomposition.