CH - 1 Relational Database Design Updated
CH - 1 Relational Database Design Updated
Chapter One
Relational Database Design
1
Introduction and overview
⚫ Database technology has evolved from primitive file
processing to the development of database
management systems with query and transaction
processing. Manual, File based (Excel), DBMS …with
SQL
⚫ Relational database systems have been widely used in
business applications.
⚫ With the advancement of database technology, various
kinds of advanced database systems have been
emerged and undergoing development to address the
requirements of new database applications
Introduction…
4
Introduction…
R(A, B, C,
D)11 12 33 44
3 2 1 4
4 1 2 3
X X
{A, B} {A, C} {A,
D}
{B, C} {B, D} {C, D}
X
{A,C,D}
Employee
Dept
Emp# ename Worksfordept Dept Dname
e1 red d1 d1 Pay
d2 Tax
e2 blue
d3 Art
e3 brown d2
Foreign key
Referential Integrity
Employee Dept
Examples:
A salaried employee who is also an engineer belongs to the
two subclasses:
ENGINEER, and
SALARIED_EMPLOYEE
A salaried employee who is also an engineering manager
belongs to the three subclasses:
MANAGER,
ENGINEER, and
SALARIED_EMPLOYEE
It is not necessary that every entity in a superclass be a
member of some subclass
Representing Specialization in EER Diagrams
Attribute Inheritance in Superclass / Subclass Relationships
3. Normal Forms
1. Introduction to Normalization
2. First Normal Form
3. Second Normal Form
4. Third Normal Form
5. Boyce-Codd Normal Form(BCNF)
6. Fourth Normal Form
1
1. Informal Design Guidelines for Relational Databases
GUIDELINE 1
Design a relation schema so that it is easy to explain its
meaning.
Do not combine attributes from multiple entity types
and relationship types into a single relation
EMPLOYEE *
DEPARTMENT
GUIDELINE 2
Design the base relation schemes so that no insertion deletion,
or modification anomalies are present.
GUIDELINE 3
Relation should be designed such that their tuples will have
few NULL values if possible.
Not applicable
NULL Unknown
Known but
absent
1. Informal Design Guidelines for Relational Data(Continued…)
GUIDELINE 4
Design relation schemas so that they can be joined with equality
conditions on attributes that either primary keys or foreign keys in
a way that guarantees that no spurious tuples are generated.
2. 1 Functional Dependencies (FDs)
→ TEXT
TEXT
→ COURSE(P)
Home Work:
– Prove the Augmentation rule.
2.3 Proof of the Rules of Inference(Continued…)
1) Proof.
X →YZ (given)
2) YZ →Y (Reflexive rule)
3) X →Y (Transitive rule)
1) X →YZ (given)
2) YZ →Z (Reflexive rule)
3) X →Z (Transitive rule)
2.3 Proof of the Rules of Inference(Continued…)
All four of these normal forms are based on functional dependencies among
the attributes of a relation.
A functional dependency describes the relationship between/among
attributes
in a relation.
– For example, if A and B are attributes or sets of attributes of relation R, B
is functionally dependent on A (denoted as A B), if each value of A is
associated with exactly one value of B.
In 1977 and 1979, a fourth (4NF) and fifth (5NF) normal form were
introduced which go beyond BCNF. However, they deal with situations
which are quite rare.
3.2 First Normal Form (1NF)
Alternative 1
DMGSSN → PLOCATION
Alternative 2 KEY:{DNUMBER,DLOCATION}
(better)
3.3 Second Normal Form(2NF)
STUDENT(SID,SNAME,C_CODE,GRADE)
STUDENT_COURSE_GRADE(SID,C_CODE, GRADE)
STUDENT_DETAILS(SID, SNAME)
22
2NF Example 2
Since the relation suffers from all the anomalies, it must be decomposed
into smaller relations. There are 3 possible decomposition for this relation:
– STUDENT_ACTIVITY(SID: pk, Activity)
– ACTIVITY_FEE(Activity: pk, Fee)
– STUDENT_FEE(SID: pk, Fee)
SSN→DNUMBER
DNUMBER →DMGRSSN
SSN →DMGRSSN
3.5 Boyce – Codd Normal Form(BCNF)
FD1
FD2
BCNF Example 1 (Continued…)
14-31
BCNF Example 2
Identify the normal form for the relation STUDENT and there exists any
anomaly in the relation.
– Update anomaly : change in advisor
– Insertion anomaly : adding a new advisor
– Deletion Anomaly : if a student is removed and if an advisor has only
one advisee
BCNF Example 2 (Continued…)
Student Relation
Before BCNF
Student and
Advisor Relations
in BCNF
3.6 Fourth Normal Form(4NF)
Multivalued dependency :
Consider a relation R which has three attributes A,B,C. For each value of
A there is a set of values of B and set of values of C. However, the set of
values of B and C are independent of each other, and then there exists
multivalued dependency between the attributes A, B, C in the relation R.
A ↠ B implies that for each value of A there is a set of values of B
A ↠ C implies that for each value of A there is a set of values of C
Basically, whenever two independent 1:M relationships A:B and A:C occur in
the same relation, a multi-valued dependency may occur
34
4NF (Continued…)
Multi-value dependency example:
SUBECT(COURSE,INSTRUCTOR,REFERENCE BOOK)
– COURSE INSTRUCTOR
– COURSE REFERENCE BOOK
– REFERENCE(COURSE,REFERENCE BOOK)
Course Reference Book
CSE 101 R1
CSE 101 R2
CSE 309 Ref 1
CSE 309 Ref 2
CSE 309 Ref 3
End of Slides
Questions?