Presentation is loading. Please wait.

Presentation is loading. Please wait.

April 20022CS3X1 Database Design Normalisation (1) John Wordsworth Department of Computer Science The University of Reading Room.

Similar presentations


Presentation on theme: "April 20022CS3X1 Database Design Normalisation (1) John Wordsworth Department of Computer Science The University of Reading Room."— Presentation transcript:

1 April 20022CS3X1 Database Design Normalisation (1) John Wordsworth Department of Computer Science The University of Reading J.B.Wordsworth@rdg.ac.uk Room 129, Ext 6544

2 April 20022CS3X2 Lecture objectives Explain the benefits of normalisation. Describe and recognise common anomalies in table designs. Explain the concept of functional dependency among attributes in a table. Describe the characteristics of tables in 1NF and 2NF. Perform normalisation to 2NF.

3 April 20022CS3X3 Why normalise? To control the degree of redundancy in a database design –control, not necessarily eliminate To ensure that all information has an independent place in the database schema –eliminate anomalies of various kinds

4 April 20022CS3X4 Anomalies Delete anomaly –delete last tutee of JAO, no way of retaining JAO in table Insertion anomaly –new student; can’t insert record for new student unless tutor already exists Update anomaly –change of LPhone; all records must be altered

5 April 20022CS3X5 Repeating groups This table contains a “repeating group”: the columns SName, SHall, SDegree. It is the attributes that repeat, not their values. This table has two rows; each cell in the R/H 3 columns has a composite value.

6 April 20022CS3X6 First normal form (1NF) In first normal form every cell in the table has one and only one value. Transform to 1NF by eliminating repeating groups What is a suitable primary key for this relation?

7 April 20022CS3X7 Another 1NF table

8 April 20022CS3X8 Consider two attributes A, B in a relation, R The value of A determines the value of B –for each value of A there is one and only one value of B –A  B; (  A determines B); (  B is FD on A) –A is said to be a determinant E.g. A  UNIT CODE; B  UNIT TITLE –Note: may be two different units with the same title –A  B does not imply B  A Functional dependency

9 April 20022CS3X9 Dependency diagram LName SName LPhone SDegree SHall UCode UTitle Primary Key

10 April 20022CS3X10 Full and partial dependency Note that although the primary key is composite, some attributes are functionally dependent on only part of it. E.g. LName is FD on SName This is called partial dependency. In second normal form we eliminate partial dependencies.

11 April 20022CS3X11 Second normal form (2NF) LName SName LPhone SDegree SHall UCode UTitle Primary Key Registration (SName, UCode); Unit (UCode, UTitle); Student (SName, LName, LPhone, SDegree, SHall)

12 April 20022CS3X12 The 2NF relations Registration Units  

13 April 20022CS3X13 The 2NF relations (contd.) Student 

14 April 20022CS3X14 Key points Normalisation is an operation on a table to remove anomalies. Tables can exhibit functional dependencies between attributes. Tables in 1NF have no repeating groups. Tables in 2NF have no partial dependencies.


Download ppt "April 20022CS3X1 Database Design Normalisation (1) John Wordsworth Department of Computer Science The University of Reading Room."

Similar presentations


Ads by Google