0% found this document useful (0 votes)
10 views

DBDesign-7

The document covers relational database design, focusing on schema refinement, functional dependencies, normalization, and normal forms (1NF, 2NF, 3NF, BCNF). It emphasizes the importance of good database design practices to avoid anomalies and ensure efficient queries. Additionally, it discusses decomposition properties, including lossless join and dependency preserving decomposition.

Uploaded by

Ayaan Sidddiqui
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

DBDesign-7

The document covers relational database design, focusing on schema refinement, functional dependencies, normalization, and normal forms (1NF, 2NF, 3NF, BCNF). It emphasizes the importance of good database design practices to avoid anomalies and ensure efficient queries. Additionally, it discusses decomposition properties, including lossless join and dependency preserving decomposition.

Uploaded by

Ayaan Sidddiqui
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Database Systems

(CSF 212)
Prof.R.Gururaj
BITS Pilani CS&IS Dept.
Hyderabad Campus
Relational Database Design
(Ch. 14 &15 of T1)
Content

❑Introduction to Schema Refinement


❑Functional Dependencies
❑Inference Rules
❑Normalization
❑Normal Forms
❑Lossless join decomposition
❑Dependency preserving decomposition

1 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus


Introduction to Database Design

A good database design practice is essential to develop


good relational schemas at logical level.

Objectives of good Database design:

❑Clarity in understanding the database and

❑To formulate good/efficient queries

This is achieved by schema refinement.

2 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus


Relational Schema design guidelines

Informal guidelines used as measures to determine the


quality of relational schemas.
❑Design a schema so that it is easy to explain the
semantics.
❑Design schemas so that no insertion, deletion and
modification anomalies are present. (anomalies)
❑Avoid placing attributes into base relations whose
values may frequently be NULL. (wastage of storage)
❑Design relations in such a way that they can be joined
on keys and no spurious tuples are formed. Avoid
relations that contain matching attributes that are not
PK, FK pairs. (spurious tuples)

2 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus


Functional Dependencies

Functional Dependency is a constraint between two sets


of attributes from the database.

Function Dependency X→Y


X functionally determines Y in a relation schema R if and
only if whenever two tuples of r(R) agree on their X values
they must necessarily agree on their Y values, but Y → X
is not true (need not be)

Ex: ssn → ename; {ssn, pnumber} → Hours

Note: FDs cannot be inferred. They should be defined by someone


who knows the semantics of the database very well.

3 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus


Diagrammatic Notation

Department {Dnumber → Dname, Mgrssn,mgrstartdate}


Mgrstubdate}
Dname Dnumber Mgrssn Mgrstartdate

Work_on {Essn, pno} → Hours

Essn Pno Hours

4 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus


Inference Rules for FDs

Rule 1 (1R1): (Reflexing)


If X ⊇ Y then X → Y otherwise non trivial
Rule 2 (1R2) (Augumentation)
X → Y; then XZ → YZ
Rule 3 (1R3) (Transitive)
X→Y ; Y → Z; Then X → Z;
Rule 4 (IR4) (Decomposition or projective rule)
X → YZ then X → Y; & X → Z;
Rule 5 (IR5) (union rule)
X → A; X→B ; then X → AB
Rule 6 (IR6) (Pseudo transitive)
X→Y ; WY → Z; then WX → Z;

We can find the closure F+ of F, by repeated application of rules IR-1 to


IR-3. These rules are called as Armstrong’s Inference rules.

5 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus


Normalization & Normal forms

Normalization process is first proposed by


Raymond Boyce and Edgar Codd in 1972.

Normalization of data – is the process of analyzing relation


schemas based on their FDs and PKs/Keys to minimize
the redundancy

7 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus


1. First Normal Form (INF)

It states that the domain of any attribute must include only


atomic (single / simple/ individual) values.
In the example given below, under the column Dloc each
row has more than on values.

Ex.: Dept DId Dname Dloc

10 Engg HYD

CHENNAI

20 Mark HYD

MUMBAI

8 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus


2.Second Normal Form (2NF)
It is based on full functional dependency.
{X → A} is fully functional if we remove any attribute from X then
that FD does not hold anymore.

Condition for 2NF: All non-key attributes are fully functionally dependent on
key (or) no non-key attribute should be dependent on part of key(partial
dependency).

eid pnum Hours ename ploc

9 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus


Here, {ename} is a non key attribute and
determined by {eid} which is part of the key. Hence
we say that ename not fully functionally dependent
on key.
The relation shown is not in 2NF. Now we can
decompose this in to three relations as shown
below.

eid ename pnum ploc eid pnum hours

10 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus


3. Third Normal form (3NF)

It is based on transitive dependency.


According to this, a relation should not have a non key attribute
functionally determined by another non key attribute. i.e., there should
be no transitive dependency.

ename eid address dnum dname dloc

Not in 3NF, because Dname is transitively dependent on eid.

11 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus


Now we can decompose the above into 2 relations.

ename eid address dnum Dnum Dname dloc

Condition for 3NF

For each FD, X → A in database

i) X must be a superkey or
ii) A is key attribute
12 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus
BCNF (Boyce Codd Normal Form)
It is a stricter form of 3NF

Condition

For each FD X →A
X must be a super key

13 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus


14 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus
Example

For 2 NF, 3NF and BCNF decompositions please


Refer to the Example given in page 485 of the
Textbook.

16 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus


Decomposition and Desirable properties

As we have seen, decomposition (of a bigger relation R


into smaller ones), is a major step in the process of
normalization.

But during this activity of decomposition, we need to


make sure that the decomposition is lossless and
dependency preserving

18 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus


Loss-less join Decomposition

Formally, a decomposition D={R1, R2, R3,……….Rm} of R has lossless


(nonadditive) join property with respect to set of dependencies F on R, if
every relation state r of R satisfies F, that holds where * is the NATURAL
JOIN of all relations in D that is-

 R1
( r ) = projection of r on R1

r is relation instance in R and F = FDs on R

(or)
if it is binary decomposition
{R1} → {R1, R2}

19 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus


Test for Lossless join property

20 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus


21 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus
Dependency Preserving Decomposition

Given a set of dependencies F on R, the projection of F on Ri


denoted by

(where Ri is a subset of R); is the set of FDs X → Y in F+ such that the


attributes in X  Y are contained in Ri.

( )
+
 R1 ( F )  R2 ( F )  ....,  Rm ( F ) = F +

Then it is dependency preserving decomposition.

 R1 ( f ) - is projection of F on R1.

23 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus


Summary
✓ Introduction to Database Design
✓Functional Dependencies and Inference Rules
✓Concepts in Normalization
✓Normal Forms (1NF,2NF,3 NF and BCNF)
✓Desirable properties of Decomposition
(requirements)
✓Lossless join decomposition and tests
✓Dependency preserving decomposition and tests

25 Database Systems Prof.R.Gururaj BITS Pilani, Hyderabad Campus

You might also like