Lecture 5.1
Lecture 5.1
Partha Pratim
Das
Week Recap
Objectives &
Database Management Systems
Outline
Module 21: Relational Database Design/1
Features of Good
Relational Design
Redundancy and
Anomaly
Decomposition
Module Summary
Department of Computer Science and Engineering
Indian Institute of Technology, Kharagpur
Module 21
Objectives &
• Illustrated equivalence of algebra and calculus
Outline
Features of Good
• Introduced the Design Process for Database Systems
Relational Design
Redundancy and
• Elucidated the E-R Model for real world representation with entities, entity sets,
Anomaly
Decomposition
attributes, and relationships
Atomic Domains • Illustrated ER Diagram notation for ER Models
and First Normal
Form
• Discussed translation of ER Models to Relational Schema and extended features of ER
Module Summary
Model
• Deliberated on various design issues
Module 21
Objectives &
Outline
Features of Good
Relational Design
Redundancy and
Anomaly
Decomposition
Atomic Domains
and First Normal
Form
Module Summary
Module 21
Objectives &
Outline
Features of Good
Relational Design
Redundancy and
Anomaly
Decomposition
Atomic Domains
and First Normal
Form
Module Summary
Module 21
Partha Pratim
Das
Week Recap
Objectives &
Outline
Features of Good
Relational Design
Redundancy and
Anomaly
Decomposition
Atomic Domains
and First Normal
Form
Module 21
Objectives &
• Avoids redundant storage of data items
Outline
Features of Good
• Provides efficient access to data
Relational Design
Redundancy and
• Supports the maintenance of data integrity over time
Anomaly
Decomposition • Clean, consistent, and easy to understand
Atomic Domains
and First Normal • Note: These objectives are sometimes contradictory!
Form
Module Summary
Week Recap
Objectives &
Outline
Features of Good
Relational Design
Redundancy and
Anomaly
Decomposition
Atomic Domains
and First Normal
Form
• ID: Key
• building , budget: Redundant Information
• name, salary , dept name: No Redundant Information
Module 21
Atomic Domains
and First Normal
Form
Module Summary
Module 21
Partha Pratim • Redundancy: having multiple copies of same data in the database.
Das
◦ This problem arises when a database is not normalized
Week Recap
◦ It leads to anomalies
Objectives &
Outline • Anomaly: inconsistencies that can arise due to data changes in a database with
Features of Good
Relational Design
insertion, deletion, and update
Redundancy and
Anomaly ◦ These problems occur in poorly planned, un-normalised databases where all the data
Decomposition
is stored in one table (a flat-file database)
Atomic Domains
and First Normal There can be three kinds of anomalies
Form
Module 21
• Insertions Anomaly
Partha Pratim
Das ◦ When the insertion of a data record is not possible without adding some additional
Week Recap
unrelated data to the record
Objectives &
◦ We cannot add an Instructor in instructor with department if the department does
Outline
not have a building or budget
Features of Good
Relational Design • Deletion Anomaly
Redundancy and
Anomaly
◦ When deletion of a data record results in losing some unrelated information that
Decomposition
Atomic Domains
was stored as part of the record that was deleted from a table
and First Normal
Form
◦ We delete the last Instructor of a Department from instructor with department, we
Module Summary
lose building and budget information
• Update Anomaly
◦ When a data is changed, which could involve many records having to be changed,
leading to the possibility of some changes being made incorrectly
◦ When the budget changes for a Department having large number of Instructors in
instructor with department application may miss some of them
Database Management Systems Partha Pratim Das 21.10
Redundancy and Anomaly (3)
Objectives &
• What causes redundancy?
Outline
◦ Dependency ⇒ Redundancy
Features of Good
Relational Design ◦ dept name uniquely decides building and budget. A department cannot have two
Redundancy and
Anomaly different budget or building. So building and budget depends on dept name
Decomposition
Atomic Domains
• How to remove, or at least minimize, redundancy?
and First Normal
Form ◦ Decompose (partition) the relation into smaller relations
Module Summary ◦ instructor with department can be decomposed into instructor and department
◦ Good Decomposition ⇒ Minimization of Dependency
• Is every decomposition good?
◦ No. It needs to preserve information, honour the dependencies, be efficient etc.
◦ Various schemes of normalization ensure good decomposition
◦ Normalization ⇒ Good Decomposition
Database Management Systems Partha Pratim Das 21.11
Decomposition
Module 21
Partha Pratim • Suppose we had started with inst dept. How would we know to split up (decompose)
Das
it into instructor and department?
Week Recap
• Write a rule “if there were a schema (dept name, building, budget), then dept name
Objectives &
Outline would be a candidate key”
Features of Good
Relational Design • Denote as a functional dependency: dept name → building, budget
Redundancy and
Anomaly • In inst dept, because dept name is not a candidate key, the building and budget of a
Decomposition
department may have to be repeated.
Atomic Domains
and First Normal
Form
◦ This indicates the need to decompose inst dept
Module Summary
Module 21
Module Summary • The next slide shows how we lose information – we cannot reconstruct the original
employee relation – and so, this is a lossy decomposition.
Module 21
Partha Pratim
Das
Week Recap
Objectives &
Outline
Features of Good
Relational Design
Redundancy and
Anomaly
Decomposition
Atomic Domains
and First Normal
Form
Module Summary
Module 21
Features of Good
Relational Design
Redundancy and
Anomaly
Decomposition
Atomic Domains
and First Normal
Form
Module Summary
Module 21
Module 21
Partha Pratim
Das
Week Recap
Objectives &
Outline
Features of Good
Relational Design
Redundancy and
Anomaly
Decomposition
Atomic Domains
and First Normal
Form
Module 21
Partha Pratim • A domain is atomic if its elements are considered to be indivisible units
Das
◦ Examples of non-atomic domains:
Week Recap
Objectives &
. Set of names, composite attributes
Outline . Identification numbers like CS101 that can be broken up into parts
Features of Good
Relational Design • A relational schema R is in First Normal Form (INF) if
Redundancy and
Anomaly ◦ the domains of all attributes of R are atomic
Decomposition
◦ the value of each attribute contains only a single value from that domain
Atomic Domains
and First Normal
Form • Non-atomic values complicate storage and encourage redundant (repeated) storage of
Module Summary data
◦ Example: Set of accounts stored with each customer, and set of owners stored with
each account
◦ We assume all relations are in first normal form
Module 21
Partha Pratim • Atomicity is actually a property of how the elements of the domain are used
Das
◦ Strings would normally be considered indivisible
Week Recap
◦ Suppose that students are given roll numbers which are strings of the form CS0012
Objectives &
Outline or EE1127
Features of Good ◦ If the first two characters are extracted to find the department, the domain
Relational Design
Redundancy and of roll numbers is not atomic
Anomaly
Decomposition ◦ Doing so is a bad idea
Atomic Domains
and First Normal
. Leads to encoding of information in application program rather than in the
Form database
Module Summary
Module 21
Week Recap
Objectives &
Outline
Features of Good
Relational Design
Redundancy and
Anomaly
Decomposition
◦ A telephone number is composite
Atomic Domains
and First Normal ◦ Telephone number is multi-valued
Form
Module Summary
Module 21
Week Recap
Objectives &
Outline
Features of Good
Relational Design
Redundancy and
Anomaly ◦ is in 1NF if telephone number is not considered composite
Decomposition
Atomic Domains
◦ However, conceptually, we have two attributes for the same concept
and First Normal
Form
. Arbitrary and meaningless ordering of attributes
Module Summary . How to search telephone numbers
. Why only two numbers?
Module 21
Week Recap
Objectives &
Outline
Features of Good
Relational Design
Redundancy and
Anomaly
Decomposition
Module 21
Week Recap
Objectives &
Outline
Features of Good
Relational Design
Redundancy and
Anomaly
Decomposition
Module 21
Objectives &
Outline
Features of Good
Relational Design
Redundancy and
Anomaly
Decomposition
Atomic Domains
and First Normal
Form
Module Summary
Slides used in this presentation are borrowed from http://db-book.com/ with kind
permission of the authors.
Edited and new slides are marked with “PPD”.