2. Slide 2 / 13
First Normal Form
Section 5 – Lesson 4
No multivalued attributes and no repeating groups.
Each attribute has a single value for each instance
of the entity.
If the attribute has multiple values, create an
additional entity and relate it to the original entity
with a m:1 relationship.
3. Slide 3 / 13
First Normal Form
Section 5 – Lesson 4
Probleme: - Ce se intampla daca se schimba regula facultatii si studentii pot
avea oricate note la un curs?
- Ce se intampla daca un student sau un profesor isi schimba
numele sau un student isi schimba adresa, trebuie sa modificam
aceste informatii in toate inregistrarile din BD unde acea
informatie apare
Probleme: - Deobicei, un student are mai multe note
la acelasi curs.
Varianta 1: - Inlocuim atributul grade cu atributele
grade1, grade2 si grade3 in ipoteza ca nu va exista
nici un curs la care studentii primesc mai mult de 2
note.
4. Slide 4 / 13
First Normal Form
Section 5 – Lesson 4
Solutia: Introducem o noua entitate STUDENT si in care vom
memora datele despre studenti iar in entitatea GRADE vom memora
doar notele
5. Slide 5 / 13
First Normal Form
Section 5 – Lesson 4
PROBLEMA: UID-ul unei note fiind compus din id-ul cursului si id-ul
studentului inseamna ca aceasta combinatie trebuie sa fie unica. Deci
nu avem voie sa avem doua inregistrari cu aceeasi pereche
(course_id, student_id) adica un student poate avea o singura nota la
o anumita materie… Dar daca instroducem in UID si data in care a
fost data nota respectiva problema este rezolvata: un student nu poate
primi 2 note la aceeasi materie in aceeasi zi (situatie destul de
rezonabila!)
6. Slide 6 / 13
Second Normal Form
Section 6 – Lesson 5
Second Normal Form
requires that any non-UID
attribute be dependent on the
entire UID.
If there are attributes that do
not depend on the entire
UID, those attributes should
be moved to a new entity.
7. Slide 7 / 13
Second Normal Form
Section 6 – Lesson 5
Comentarii:
- UID-ul entitatii GRADE este (COURSE ID + STUDENT ID)
- dar COURSE NAME nu depinde decat de COURSE ID nu si de
STUDENT ID
8. Slide 8 / 13
Second Normal Form
Section 6 – Lesson 5
Solutia: Cream inca o entitate: COURSE
9. Slide 9 / 13
Third Normal Form
Section 7 – Lesson 2
The rule of Third Normal Form states that no non-UID attribute
can be dependent on another non-UID attribute.
10. Slide 10 / 13
Third Normal Form
Section 7 – Lesson 2
Modelul obtinut anterior este deja in forma normala 3. Dar daca dorim sa
adaugam informatii suplimentare despre profesor: adresa, numar de telefon,
email etc. obtinem urmatorul ERD care nu este in forma normala 3, noile
informatii depinzand doar de atributul teacher id care nu este UID-ul entitatii
COURSE:
11. Slide 11 / 13
Third Normal Form
Section 7 – Lesson 2
Solutia: Introducem o noua entitate TEACHER
12. Slide 12 / 13
Third Normal Form
Section 7 – Lesson 2
Am obtinut o relatie menay-to-
many care trebuie rezolvata:
13. Slide 13 / 13
Normalization Rules
Normal Form Rule Description
First Normal Form All attributes are single valued.
Second Normal Form (2NF) An attribute must be dependent upon
entity’s entire unique identifier.
Third Normal Form (3NF) No non-UID attribute can be dependent
on another non-UID attribute.