Chapter 2 RM and Normalization V2
Chapter 2 RM and Normalization V2
Chapter 02:
ER
Transformation
RM
Normalization is a process that
Normalisation improves a database design by
generating relations that are of
Functional higher normal forms.
dependencies Normal forms
3
The relational model
Informally, the relational model can be defined as follows:
A relationship schema specifies the name of the relationship as well as the list
of attributes with their domains.
The relationship diagram is:
Person (num : integer, FN : String, LN : String)
Remarks :
4. Cardinality
The cardinality of a relation is its number of occurrences.
5. Occurrence
An occurrence is an element of the whole represented by a
relation. In other words, an occurrence is a row in the table.
7 Concepts of the relational model
6. Candidate key
In relational theory, all tuples must be distinct.
A relation therefore has at least one subset (A1,A2,….Ak) of the set of
attributes which makes it possible to identify each of the tuples of the
relation.
Informally, a key is a minimum set of attributes whose values knowledge
makes it possible to identify a unique record of the relationship
considered.
A key is invariant over time. In general, there are several keys for the
same relation R.
8
Concepts of the relational model
Every relation has at least one candidate key and can have
several. This has the consequence that there can never be two
identical occurrences within a relationship: these two
occurrences would in fact represent the same object.
Key Examples :
EMPLOYEE (number, last name, first name, salary) has a candidate key:
number
If we are certain that 2 employees never have the same name, name is a
2nd Candidate key;
So EMPLOYEES (number, last name, first name, salary) has 2 candidate
keys: number (which we will certainly choose as the primary key) and (last
name, first name)
10
Concepts of the relational model
8. Foreign key
Example :
CUSTOMER(CustomerNum,CustomerLastName,CustomerFirst
Name)
CustomerNum —> CustomerLastName.
There is a DF between client num and client name, because if we
know a value of the client num property (eg: 4553), only one
value of the name property can correspond to it (eg: Benbou).
The converse is false Customer name —> Customer number is
not a DF. If we know the value of the Client Name property, we
cannot deduce the Client Num property from it, because there
can be several clients who have the same name.
14 Functional Dependencies (Cont.)
Examples.
1. SSN → ENAME
2. PNUMBER → {PNAME, PLOCATION}
3. {SSN, PNUMBER} → HOURS
4. Others?
- impossible
- impossible
Example :
Let F be the set of DF relative to
R( N°veh, Type, Couleur, Marque, Puissance)
Normalization
31 What is Normalization ?
▪ Normalization divides larger tables into smaller tables and links them
using relationships.
1 Jojo 20 1 Jojo 20
2 Kit 25
2 Kit 25
1 Jojo 20
33 Redundancy (Cont..)
2 BB C2 JAVA F2 KK 50000
Suppose a new faculty joins the University, and the Database Administrator
inserts the faculty data into the above table. But he is not able to insert
because Sid is a primary key, and can’t be NULL. So this type of anomaly is
known as an insertion anomaly.
38 Delete Anomaly
Database Normalization
41 First Normal Form (1NF)
Example:
Additional:
Reminder:
Non-Prime attributes: The attributes which do not form a candidate key are
called non-prime attributes.
Is it 1NF?
How can you make it 1NF?
57 Example 1 (Cont..)
But is it 3NF?
61 Example 1 (Cont..)
But either way, non-key fields are dependent on MORE THAN THE
PRIMARY KEY (studentID). And 3NF says that non-key fields must
depend on nothing but the key
62 Example 1 (Cont..)
63 Example 1 (Cont..)
END