DBMS 3.1 PDF
DBMS 3.1 PDF
UNIT – III
SCHEMA REFINEMENT
NORMAL FORMS
VARDHAMAN COLLEGE OF ENGINEERING
Shamshabad – 501 218, Hyderabad
B.Tech. CSE IV Semester (VCE - R11) T P C
3+1* -- 4
(A1511) DATABASE MANAGEMENT SYSTEMS
2
UNIT - I
INTRODUCTION: History of database systems, introduction to database
management systems, database system applications, database systems versus
file systems, view of data, data models, database languages- DDL & DML
commands and examples of basic SQL queries, database users and
administrators, transaction management, database system structure, application
architectures.
UNIT - II
THE RELATIONAL MODEL: Introduction to the relational model, integrity
constraints over relations, enforcing integrity constraints, querying relational
data, logical database design: E-R to relational, introduction to views,
destroying/altering tables and views.
SQL: Overview, the form of a basic SQL query, union, intersect and except
operators, nested queries, aggregate operators, null values, complex integrity
constraints in SQL, triggers and active databases, designing active databases.
VARDHAMAN COLLEGE OF ENGINEERING
Shamshabad – 501 218, Hyderabad
B.Tech. CSE IV Semester (VCE - R11) T P C
3+1* -- 4
(A1511) DATABASE MANAGEMENT SYSTEMS
4
UNIT - III
SCHEMA REFINEMENT AND NORMAL FORMS: Introduction to schema
refinement, functional dependencies, reasoning about FDs. Normal forms: 1NF,
2NF, 3NF, BCNF, properties of decompositions, normalization, schema
refinement in database design, other kinds of dependencies: 4NF, 5NF, DKNF,
case studies.
VARDHAMAN COLLEGE OF ENGINEERING
Shamshabad – 501 218, Hyderabad
B.Tech. CSE IV Semester (VCE - R11) T P C
3+1* -- 4
(A1511) DATABASE MANAGEMENT SYSTEMS
5
UNIT - IV
TRANSACTIONS MANAGEMENT: Transaction concept, transaction state,
implementation of atomicity and durability, concurrent executions, serializability,
recoverability, implementation of isolation, transaction definition in SQL, testing
for serializability.
UNIT - V
OVERVIEW OF STORAGE AND INDEXING: Data on external storage, file
organizations and indexing, index data structures, comparison of file
organizations, indexes and performance tuning. Tree structured indexing -
intuition for tree indexes, indexed sequential access method (ISAM), B+ Trees -
a dynamic tree structure.
IBM DB2 FUNDAMENTALS*: DB2 product family - versions and editions, DB2
database and its objects, DB2 pure XML, backup and recovery, concurrency
and its isolation levels, working with SQL, DB2 programming fundamentals -
UDF, stored procedures.
TEXT BOOKS:
1. Raghurama Krishnan, Johannes Gehrke (2007), Database Management
Systems, 3rd edition, Tata McGraw Hill, New Delhi, India.
REFERENCE BOOKS:
1. Elmasri Navate (1994), Fundamentals of Database Systems, Pearson Education,
India.
2. Abraham Silberschatz, Henry F. Korth, S. Sudarshan (2005), Database System
Concepts, 5th edition, McGraw-Hill, New Delhi, India.
3. Peter Rob, Carlos Coronel (2009), Database Systems Design, Implementation
and Management, 7th edition, India.
UNIT – III
8
SCHEMA REFINEMENT
Introduction to schema refinement
Functional dependencies
Reasoning about FDs
NORMAL FORMS
1NF, 2NF, 3NF, BCNF
Properties of decompositions, normalization,
schema refinement in database design
Other kinds of dependencies: 4NF, 5NF, DKNF
Case studies
The Evils of Redundancy
9
5 7
Use of Decomposition (cont.)
14
231-31-5368 Smiley 22 8 30
131-24-3650 Smethurst 35 5 30
434-26-3751 Guldu 35 5 32
612-67-4134 Madayan 35 8 40
Problems related to Decomposition
15
i.e., given two tuples in r, if the X values agree, then the Y values
must also agree. (X and Y are sets of attributes.)
An FD is a statement about all allowable relations.
Must be identified based on semantics of application.
An FD X →Y where Y ⊆ X
-called a trivial FD, it always holds good
An FD X →Y where Y ⊈ X
-non-trivial FD
An FD X →Y where X ∩Y = Ø
-completely non-trivial FD
FUNCTIONAL DEPENDENCIES (FDs) cont.
19
Problems due to R → W :
S N L R H
123-22-3666 Attishoo 48 8 40
Update anomaly: Can
we change W in just 231-31-5368 Smiley 22 8 30
the 1st tuple of 131-24-3650 Smethurst 35 5 30
SNLRWH? 434-26-3751 Guldu 35 5 32
Insertion anomaly: What
612-67-4134 Madayan 35 8 40
if we want to insert an
employee and don’t know S N L R W H
the hourly wage for his 123-22-3666 Attishoo 48 8 10 40
rating?
231-31-5368 Smiley 22 8 10 30
Deletion anomaly: If we
delete all employees with 131-24-3650 Smethurst 35 5 7 30
rating 5, we lose the 434-26-3751 Guldu 35 5 7 32
information about the 612-67-4134 Madayan 35 8 10 40
wage for rating 5!
Constraints on a Relationship Set
21
Check if Y is in X +
Does F = {A → B, B → C, C D →E } imply A → E?
i.e, is A → E in the closure F + ? Equivalently, is E in A+ ?
Closure of a Set of FDs
25
The set of all FDs implied by a given set F of FDs is called the
closure of F and is denoted as F+.
Reflexive Rule:
F ⊨{X →Y | Y ⊆ X} for any X. Trivial FDs
Augmentation Rule:
{X →Y} ⊨ {XZ →YZ}, Z ⊆ R. Here XZ denotes X ⋃ ⋃Z
Transitive Rule:
{X →Y, Y →Z} ⊨ {X →Z}
Armstrong's Axioms are sound in that they generate only FDs in F+
when applied to a set F of FDs.
They are complete in that repeated application of these rules will
generate all FDs in the closure F+.
Closure of a Set of FDs (or Armstrong’s Inference Rules)
27
The normal forms based on FDs are rst normal form (1NF), second
normal form (2NF), third normal form (3NF), and Boyce-Codd normal
form (BCNF).
These forms have increasingly restrictive requirements: Every relation in
BCNF is also in 3NF,
every relation in 3NF is also in 2NF, and every relation in 2NF is in
1NF.
A relation is in first normal form if every field contains only atomic
values, that is, not lists or sets.
This requirement is implicit in our definition of the relational model.
Although some of the newer database systems are relaxing this
requirement
2NF is mainly of historical interest.
3NF and BCNF are important from a database design standpoint.
1st Normal Form
The Requirements
39
data.
1st Normal Form
Example - 1
42
ORDER:
1. Order_No
2. Order_Date
3. Customer_No
4. Item_No
5. Item_Name
6. Qty_Ordered As many as items ordered in the ORDER
7. Rate_Per_Unit
8. Item_Value
1st Normal Form
Example - 1 (cont.)
43
ORDER ORDER_ITEM
1. Order_No (PK) 1. Order_No (PK)
2. Order_Date 2. Item_No (PK)
3. Customer_No 3. Item_Name
4. Qty_Ordered
5. Rate_Per_Unit
6. Item_Value
3. Duplicate in the new table the primary key of the table from
which the repeating group was extracted or vice versa.
Example (1NF) ISBN AuName AuPhone
0-55-123456-9 Main Street Small House 714-000-0000 $22.95 0-55-123456-9 Jones 123-333-3333
ORDER ORDER_ITEM
1. Order_No (PK) 1. Order_No (PK)
2. Order_Date 2. Item_No (PK)
3. Customer_No 3. Item_Name
4. Qty_Ordered
5. Rate_Per_Unit
6. Item_Value
Both these relations are now in the Second Normal Form (since we
have assumed that the rate_per_unit cannot be derived from the
Item_No.
1st Normal Form
Example
53
Students table
Student# AdvID AdvName AdvRoom
123 123A James 555
124 123B Smith 467
Registration table
Student# Class#
123 102-
102-8
123 104-
104-9
124 209-
209-0
124 102-
102-8
Steps to convert a table to its 2nd Normal Form
55
key.
Group the removed items in the another table.
Assign the new table with the key i.e. part of a whole
composite key.
Steps to convert a table to its 2nd Normal Form
Example - 3
56
EmpProj
1. Project_number (PK)
2. Project_name
3. Employee_number (PK)
4. Employee_name
5. Rate_category
6. Hourly_rate
Going through all the fields reveals the following:
Project_name is only dependent on Project_number
EmpProj
1. Project_number (PK)
2. Project_name
3. Employee_number (PK)
4. Employee_name
5. Rate_category
6. Hourly_rate
To convert the table into the Second Normal Form remove and place
these fields in a separate table, with the key being that part of the
original key they are dependent on.
This leads to the following 3 tables:
EmpProj Emp Proj
1. Project_number(PK) 1. Employee_number (PK) 1. Project_number(PK)
2. Employee_number(PK) 2. Employee_name 2. Project_name
3. Rate_category
4. Hourly_rate
2nd Normal Form Example - 4
58
ORDER_ITEM
1. Order_No (PK)
2. Item_No (PK)
3. Qty_Ordered
4. Rate_Per_Unit
5. Item_Value
ORDER_ITEM
1. Order_No (PK)
2. Item_No (PK)
3. Qty_Ordered
4. Rate_Per_Unit
5. Item_Value
Transitive dependency:
An FD X →Y in a relation schema R for which there is a set
ofattributes Z ⊆
⊆R such that
X →Z and Z →Y and Z is not a subset of any key of R
Ex: student (rollNo, name, dept, hostelName, roomNo, headDept)
Keys: rollNo, (hostelName, roomNo)
rollNo→dept; dept →headDept hold
So, rollNo→headDept a transitive dependency
Head of the dept of dept D is stored redundantly in every
tuplewhere D appears.
Relation is in 2NF but redundancy still exists.
3rd Normal Form
Example - 2
65
Students table:
Student# AdvID AdvName AdvRoom
123 123A James 555
124 123B Smith 467
Students table:
Student# AdvID
123 123A
124 123B
73
3rd Normal Form
Example - 6
74
EmpProj
1. Project_number (PK)
2. Project_name
3. Employee_number (PK)
4. Employee_name
5. Rate_category
6. Hourly_rate
To convert the table into the Second Normal Form remove and place
these fields in a separate table, with the key being that part of the
original key they are dependent on.
This leads to the following 3 tables in 2NF:
EmpProj Emp Proj
1. Project_number(PK) 1. Employee_number (PK) 1. Project_number(PK)
2. Employee_number(PK) 2. Employee_name 2. Project_name
3. Rate_category
4. Hourly_rate
3rd Normal Form
Example - 6
75
Proj
1. Project_number(PK)
2. Project_name