Loading in 2 Seconds...
Loading in 2 Seconds...
UFCE8V-20-3 Information Systems Development 3 (SHAPE HK). Lecture 6 : Data Normalisation. Normalisation (1). What is Normalisation ?
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
Lecture 6 : Data Normalisation
Informally, normalisation can be thought of as a process defined within the theory of relational database to break up larger relations into many small ones using a set of rules. Normalisation resolve problems with data anomalies and redundancy. It is essentially a two-step process to:
1. put the data into tabular form (by removing repeating groups); and
2. to remove duplicated records to separate tables.
As we work through the normalisation process, we will make use of data that relates to the Bus Depots’ Database – a description and E-R model of which was handed out in last weeks session and is also available from the resource area.
Well-normalised databases have a design that reflects the true dependencies between entities, allowing the data to be updated quickly with little risk of introducing inconsistencies. Before discussing how to design a well-normalised database using Codd'snormalisation techniques, we first consider a poor database design.
Consider for example a relation 'bus' which includes bus registration number, model, type number, type description, depot name (note that names have changed slightly from the study for the purposes of this example):
There are several problems with the previous relation:
A formal definition for the term functional dependence is:
Given a relation which has attributes (x, y, ...), we say that an attribute y is functionally dependent on another attribute x, if (and only if) each x value has associated with it precisely one y value (at any one time).
For example, examine the following relation:
In the previous diagram, attributes cname, csalary and dno are each functionally dependent on attribute cno - given a particular cnovalue, there exists precisely one corresponding value for each of the cname, csalary and dno.
In general then, the same x-values may appear in many different tuples of the relation; if y is functionally dependent on x, then every one of these tuples must contain the same value.
Going back to the cleaner example, we can represent these functional dependencies diagrammatically as:
The previous figure is an example of a determinacy diagram. The arrow line can be read as 'depends on' (reading from left to right). So we say, for example, 'cno depends on cname'. We can also 'read' the diagram from right to left. This time the arrowed line is read as 'functionally dependent on'. So we say, for example 'cname is functionally dependent on cno'.
The attribute or group of attributes on the left-hand side are called the determinant. The determinant of a value is not necessarily the primary key. In the example, cno is a determinant of cname because knowing the cleaner's number we can determine the cleaner's name.
Recognizing the functional dependencies is an essential part of understanding the meaning or semantics of the data. The fact that cname, csalary and dno are functionally dependent on cno means that each cleaner has one name, has one salary and works at precisely one depot.
The notion of functional dependence can be extended to cover the case where the determinant (particularly the primary key) is composite, i.e. it consists of more that one attribute.
Full functional dependence
An attribute y is defined to be fully functionally dependent on attribute x if it is functionally dependent on x and not functionally dependent on any subset of the attributes of x where it is a composite attribute.
The opposite of full functional dependence is partial dependence. Where we have data values that depend on only a part of the primary key, then we have a partial dependency.
This occurs when the value of an attribute is not determined directly from the primary key, but through the value of another attribute and this attribute in turn is determined by the primary key.
A number of normal forms have been proposed, but the first five normal forms have been widely accepted.
The normal forms progress from first normal form, to second, and so on. Data in second normal form implies that it is also in first normal form - i.e. each level of normalisation implies that the previous level has been met.
Other normal forms such as Boyce-Codd (BCNF) which is an extension of 3NF.
Correspondence between the normal forms:
Consider the following example forms that record information about cleaners at the Middlesex Depot and the buses they look after. Note that three extra attributes, roster number, roster date and job complete have been added to the original model. The cleaner ticks against the appropriate job after he/she has completed the cleaning of a particular bus.
The un-normalised relation:
The next step in the normalisation process is to remove the repeating groups from the unnormalised relation. A relation is in 1 NF if - and only if - all domains contain only atomic or single values, i.e. all repeating groups of data are removed.
A repeating group is a group of attributes that occurs a number of times for each record in the relation. So for example, in the Roster relation, each roster record has a group of buses (roster record 104 has 6 buses).
Selecting a suitable key for the table
In order to convert an un-normalised relation into first normal form, we must identify the key attribute(s) involved. From the un-normalised relation we can see that each roster has a roster_no, each cleaner a cno, each depot a dno, each bus a reg_noand each type a tno. In order to convert an un-normalised relation into normal form, we also have to identify a key for the whole relation. Bearing this definition in mind, on examination the primary key of the relation is roster-no, reg_no.
We now draw the determinacy diagram for the roster relation, showing the attributes which are dependent on the primary key:
Determinacy diagram for the first normal form:
Roster relation in first normal form:
We now describe the second step in the normalisation process using the relation above which is in first normal form.
Firstly we determine the functional dependencies on the identifying attributes (i.e. the primary key (roster_no, reg_no) and its parts.
If the key is composite, the other attributes must be functionally dependent on the whole of the key. In other words we are looking for partial functional dependencies. In the example, roster date is functionally dependent on the partial key roster_no - there is only one roster_date for a particular roster_no. Also cno, cname, dno, dnameetc are all functionally dependent on the partial key reg_no. The attribute 'status', however, is the only attribute fully functionally dependent on the whole of the primary key.
Determinacy diagram for the second normal form:
Roster in first second normal form:
2NF has less redundancy than 1NF as we have removed repeating groups.
However there are still a number of problems:
A 3NF relation is in 2NF but also it must satisfy the non-transitive dependency rule, which states that every non-key attribute must be non-transitively dependent on the primary key. Another way of saying this is that a relation is in 3NF if all its non-key attributes are directly dependent on the primary key. Transitive dependencies are resolved by creating new relations for each entity.
There are three transitive dependencies in the Bus relation above as is illustrated by vertical lines in the 2NF determinacy diagram. For example: cno is functionally dependent on reg_no; cname is functionally dependent on reg_no. Additionally, cname is functionally dependent cno.
We therefore have the transitive dependency:
reg_nodetermines cno and cno determines cname then
Two other transitive dependencies are identified involving tname and dname. The determinacy diagrams for third normal form are given on the next slide:
Determinacy diagram for the third normal form:
Roster in third normal form:
Steps of the Normalisation process (1) :