Præsentation er lastning. Vent venligst

Præsentation er lastning. Vent venligst

Database Normalization without Mathmatics

Lignende præsentationer


Præsentationer af emnet: "Database Normalization without Mathmatics"— Præsentationens transcript:

1 Database Normalization without Mathmatics
Normalization rules are design rules for database tables. In this slideshow, all the slides with math are hidden and you need not read them if you can understand how to normalize database tables without using math. Case examples are from the book: Lars Fank Databaser Teori og Praksis ISBN

2 Normalization rules may prevent redundant data.
What is redundancy? What are the problems with redundancy? What are the benefits of managed redundancy?

3 Normalization can more than reduce redundancy!
In non normalized databases it is possible to lose data that is valid. Normalization can increase flexibility. (What is database flexibility?)

4 Tables at Third Normal Form:
Example where non-normalized data may be lost. Table at Second Normal Form: SalesmanID City SalesCode S1 Aarhus 10 S2 Copenhagen 30 S4 Odense 20 S5 Tables at Third Normal Form: SalesmanID City S1 Aarhus S2 Copenhagen S4 Odense S5 City SalesCode Aarhus 10 Copenhagen 30 Odense 20

5 Table at first normal form:
Non-normalized table: Salesman ID City SalesCode Product ID QTY S1 Aarhus 10 S2 Copenhagen 30 P1 200 P3 100 S4 Odense 20 P5 P8 S5 50 500 P4 800 1. The record length must be fixed. 2. One record type per table First normal form. 3. The table must have a primary key. SalesmanID City SalesCode ProductID QTY S1 Aarhus 10 S2 Copenhagen 30 P1 200 P3 100 S4 Odense 20 P5 P8 S5 50 500 P4 800 Table at first normal form:

6 Key definitions: Determinant key =
Candidate key =any minimal set of attributes that may be used as a primary key. Nonprime attribute = Any attribute that is not part of a candidate key. SalesmanID SalesCode Bynavn City S1 10 Århus Aarhus S2 30 København Copenhagen S4 20 Odense S5 Determinant key = Candidate key for some of the nonprime attributes.

7 Boyce-Codd Normal Form (BCNF):
BCNF = If a table has more determinant keys they may all be used as the primary key. SalesCode Bynavn City 10 Århus Aarhus 20 Odense 30 København Copenhagen Determinant key = Candidate key for some of the nonprime attributes. Bemærk at BCNF er bedre end 3NF

8 What attributes are determinant keys?
By grouping the attributes around the Determinant keys they are related, to it is possible to design a database at BCNF. SalesmanID City SalesCode ProductID QTY S1 Aarhus 10 S2 Copenhagen 30 P1 200 P3 100 S4 Odense 20 P5 P8 S5 50 500 P4 800 What attributes are determinant keys?

9 Tables at BCNF Normal Form:
Table at first normal form: SalesmanID City SalesCode ProductID QTY S1 Aarhus 10 S2 Copenhagen 30 P1 200 P3 100 S4 Odense 20 P5 P8 S5 50 500 P4 800 Tables at BCNF Normal Form: SalesmanID ProductID QTY S2 P1 200 P3 100 S4 P5 P8 S5 50 500 P4 800 SalesmanID City S1 Aarhus S2 Copenhagen S4 Odense S5 City SalesCode Aarhus 10 Copenhagen 30 Odense 20

10 Exercise: Design a BCNF normalized Patient database and group the attributes around the determinant keys.

11 Opgave 1.22 Normaliser efterfølgende køreplan for busruter. Bemærk
at der findes en ordningsrelation mellem en busrutes stoppesteder.

12 First normal form. Second normal form. Third normal form.
Non matematical definition of the first, second, and third normal forms: First normal form. Second normal form. Third normal form. The non-key attributes of the normalized table must give information related to the primary key, the hole primary key, and nothing but the primary key. {De recordfelter, der ikke er primærnøglen i den normaliserede tabel, skal indeholde oplysninger om objektet, (der er identificeret af primærnøglen) om hele objektet , (der er identificeret af primærnøglen) og om intet andet end objektet (der er identificeret af primærnøglen) .}

13 Boyce-Codd Normal Form (BCNF):
BCNF = If a table has more determinant keys they may all be used as the primary key. The problem with the third normal form (3NF) is that it does not allow more than one candidate key in a table, and that is not acceptable. Salgskode Bynavn City 10 Århus AArhus 20 Odense 30 København Copenhagen Determinant key = Candidate key for some of the nonprime attributes.

14 Multivalued dependencies:
There is a multivalued dependency between two attributes if the same value in the first attribute may coexist with different values in the second attribute. Example: Relationship tables have normally multivalued dependencies.

15 Fourth normal form: Third normal form or even better BCNF must be fulfilled and if the table has more multivalued dependencies then these must be dependent of each other.

16 Fourth normal form (continued).
If the multivalued dependencies are independent of each other, the table must be split corresponding to the independent multivalued dependencies.

17 Exercise 1.21: The following authorization table illustrates who has authorizaised whom to the tables of a database. Is the authorization table at fourth normal form?

18 Exercise 1.13 Normaliser tabellerne i vedstående database.

19 End of session Thank you !!!


Download ppt "Database Normalization without Mathmatics"

Lignende præsentationer


Annoncer fra Google