Professional Documents
Culture Documents
Design
Design
Design
UNIT -6
Database Design
Informal Design Guidelines for Relation Schemas; Functional Dependencies;
Normal Forms Based on Primary Keys; General Definitions of Second and
Third Normal Forms; Boyce-Codd Normal Form.
Fourth Normal Form; and Fifth Normal Form;
Whenever we are going to form relational schema there should be some meaning
among the attributes.This meaning is called semantics.This semantics relates one
attribute to another with some relation.
Eg:
Insertion anomalies
Deletion anomalies
Modification anomalies
Page 1 of 12
Database Management System
The main goal of the schema diagram is to minimize the storage space that the base
memory occupies.Grouping attributes information relations has asignificant effect on
storage space.
Eg;
Eg:
If we integrate these two and is used as a single table i.e Student Table
Here whenever if we insert the tuples there may be ‘N’ stunents in one department,so
Dept No,Dept Name values are repeated ‘N’ times which leads to data redundancy.
Another problem is updata anamolies ie if we insert new dept that has no students.
If we delet the last student of a dept,then whole information about that department will be
deleted
If we change the value of one of the attributes of aparticaular table the we must update
the tuples of all the students belonging to thet depy else Database will become
inconsistent.
Note: Design in such a way that no insertion ,deletion,modification anamolies will occur
Note: Relations should be designed such that their tuples will have as few NULL
values as possible
Attributes that are NULL frequently could be placed in separate relations (with the
primary key)
Page 2 of 12
Database Management System
Bad designs for a relational database may result in erroneous results for certain JOIN
operations
The "lossless join" property is used to guarantee meaningful results for join
operations
Note: The relations should be designed to satisfy the lossless join condition. No
spurious tuples should be generated by doing a natural-join of any relations.
Functional dependency
Page 3 of 12
Database Management System
Inference rules also known as Armstrong's Axioms are published by Armstrong. These
properties are as given below:
Normalization:
Normal form: Condition using keys and FDs of a relation to certify whether a
relation schema is in a particular normal form
Page 4 of 12
Database Management System
• Each attribute in an entity must depend on the whole key, not just a part of it.
Page 5 of 12
Database Management System
It is already in 2NF
Page 6 of 12
Database Management System
Example 1
CUSTOMER
Page 7 of 12
Database Management System
This is not in strict 3NF as the City could be obtained from the Post code attribute. If you
create a table containing postcodes then city could be derived.
POSTCODES
PostCode City
SW7 2AP London
WC2H 7JY London
CV4 7AL Coventry
Example 2.
The Description of what the certificate means could be obtained frome the certifcate
attribute - it does not need to refer to the primary key VideoID. So split it out and use the
primary key / secondary key approach.
Example 3
CLIENT
CINEMAS
CinemaID CinemaAddress
LON23 1 Leicester Square. London
Page 8 of 12
Database Management System
In this case the database is almost in 3NF - for some reason the Cinema Address is being
repeated in the Client table, even though it can be obtained from the Cinemas table. So
simply remove the column from the client table
Definition:
A multivalued dependency (MVD) X —>> Y specified on relation
schema R, where X and Y are both subsets of R, specifies the
following constraint on any relation state r of R: If two tuples t1 and t2
exist in r such that t1[X] = t2[X], then two tuples t3 and t4 should also
Page 9 of 12
Database Management System
Example
Page 10 of 12
Database Management System
A relation decompose into two relations must have the lossless-join property,
which ensures that no spurious tuples are generated when relations are reunited
through a natural join operation.
However, there are requirements to decompose a relation into more than two
relations. Although rare, these cases are managed by join dependency and fifth
normal form (5NF).
Constraints as Assertions
Page 11 of 12
Database Management System
Assertions: An Example
“The salary of an employee must not be greater
than the salary of the manager of the department
that the employee works for’’
CREAT ASSERTION SALARY_CONSTRAINT
CHECK (NOT EXISTS (SELECT *
FROM EMPLOYEE E, EMPLOYEE M,
DEPARTMENT D
WHERE E.SALARY > M.SALARY AND
E.DNO=D.NUMBER AND
D.MGRSSN=M.SSN))
SQL Triggers
Objective: to monitor a database and take initiate action when a
condition occurs
Triggers are expressed in a syntax similar to assertions and
include the following:Event
Such as an insert, deleted, or update operation
Condition
Action
To be taken when the condition is satisfied
Page 12 of 12