Sabtu, 25 April 2009

Database Normalization

Database is usually the one part of an information system that consists of, among others, Data, DBMS software, computer Hardware, software and computer operating systems, application programs, programmers.

There are database design process :

  1. Collection and analysis requirement user.
  2. Develop the ER model based on requirement user
  3. Convert ER Model to set the relation (table)
  4. Normalization of relations, for the anomaly
  5. To implement the database for each table to create relationships that have been in the normalization

Normalization process is the establishment of the database structure so that most of the ambiguity can be removed. Normalization stage, starting from the most mild (1NF) to most stringent (5NF). Normalization is usually only up to the level of 3NF or BCNF because already sufficient to generate the table-a table of good quality. The purpose why we do Normalization is to loss of data double, decrease complexity, and to simplify data modification process.

Normalization purposes : minimize the repetition of information , to reduce the complexity and easily identify entities or objects.

Why do normalization?

  1. Optimization table structures
  2. Increase the speed of process.
  3. Eliminate income data the same
  4. More efficient use of storage media
  5. Reduce redundancy
  6. Avoiding anomalies (insertion anomalies, deletion anomalies, update anomalies).
  7. Improved integrity data

A table saying good (efficient) or normal if following there 3 criteria :

  1. If there is decomposition (decomposition) table, then the decomposition will be guaranteed safe (Lossless-Join Decomposition). That is, after the table is described / in the decomposition into a new table-table, the table-table can generate a new table with the same exact.
  2. Maintain the functional dependence on the change data (Dependency preservation).
  3. No violate Boyce-Code Normal Form (BCNF)

If the three criteria (BCNF) can not be met, then at least the table does not violate the Normal Form of the third stage (3rd Normal Form / 3NF).

Functional dependency (FD) is a restriction that comes from the meaning of attributes and relationships between attributes. Functional Dependency attributes describe the relationship in a relationship. An attribute said functionally dependant on the other, if we use the value attribute to determine the value of the other attributes. Symbol that is used to represent è functional dependency. è read the functional set. FD from the fact that there is (obtained at the analysis system).

Notation: A è B. Means A and B are attributes of a table. A means of determining the functional B or B depends on A, if and only if there are 2 rows of data with the same value of A, then B is also the same value.

Normal form is a condition (using the FD and key) that determines whether a scheme relationships meet certain criteria. There are several normal forms based on a number of criteria:

  1. Primary keys (1NF, 2NF, 3NF)
  2. All Candidate Keys (2NF, 3NF, BCNF)
  3. Multivalued dependencies (4NF)
  4. Join dependencies (5NF)

FIRST NORMAL FORM (First Normal Form - 1NF)

A table on the form said to be normal if I did not reside in the unnormalized form of a table, where there is a kind of field multiplication and field that allows a null (empty) 1NF is not allowed on the:

  1. Attribute values, many (Multivalued attributes).
  2. Attribute a composite or a combination of both.
  3. Nested relations.

So, price is the domain attribute must be atomic rates.

Advantage of the 1NF compared Unnormalized relation (UNRs) is a simplification in the form of representation and ease of use in developing a query language

Second NORMAL FORM (Second Normal Form - 2NF)

Normal form 2NF met in a table if it meets the form of 1NF, and all the attributes than the primary key, have a full Functional Dependency on primary key. A table does not meet 2NF said, if there are attributes that Functional Dependency are only partial (only depending on the part of the primary key). If there are attributes that have no dependence on the primary key, then the attributes must be moved or removed.

  • Functional dependency X à Y if it is said of a remove attribute A from X means that Y is no longer dependent functional.
  • Functional dependency X à Y if it is said partial delete an attribute A from X means that Y is functionally dependent.
  • Relation scheme R in the form 2NF if every non-primary key attribute A Î R is functionally dependent on the full primary key R.

Third NORMAL FORM (Third Normal Form - 3NF)

Normal form 3NF fulfilled if the form meets 2NF, and if there are no non-primary key attribute that has a dependence on non-primary key attributes of the other (transitive dependencies).

Table following students eligible 2NF, 3NF, but does not meet

Because the table above there are still non-primary key attribute (ie, Kota and Provinsi), which has a dependence on non-primary key attributes of the other (ie KodePos), namely:

KodePos à {Kota, Provinsi}

So that the table in the decomposition needs to be:

Mahasiswa (NIM, NamaMhs, Jalan, KodePos)

KodePos (KodePos, Provinsi, Kota)

Boyce-Codd Normal Form (BNCF)

Boyce-Codd Normal Form constraint has a stronger form of the Normal third. To be BNCF, relations must be in the First Normal Form and forced each of the attributes depends on the function in the super key attributes.

In the example below there is a relationship seminar, is the Primary Key NPM + Seminar. Students may take one or two seminars. Each seminar requires 2 each of the students and led by one of the 2 seminar. Each leader can only take one seminar course. NPM and Seminar in this example and show a Pembimbing.

Seminar relations is a Third Normal Form, but not BCNF because Code Seminar is still dependent on the function Pembimbing, if any Pembimbing can only teach a seminar. Depending on the seminar is not a super key attributes such as required by BCNF. But relations Seminar should be parsed into two namely:

Normal form of the fourth and fifth

Relations in fourth normal form (NF 4) if the relation in BCNF and does not contain a lot of dependence values. To remove the dependency of many values from a relation, we divide the relationship into two new relations. Each relation contains two attributes that have a lot of relationship value.

Relations in fifth normal form (5NF) deal with the property called the join without any loss of information (lossless join). Fifth normal form also called the 5 NF PJNF (projection join normal form). The case is very rare and appear difficult to detect in practice.

Reference:

- http://iaprima.staff.gunadarma.ac.id/Downloads/files/5460/Bahasan9b_Normalisasi.pdf

- http://kuliah.dinus.ac.id/ika/prc4.html

- ER Ngurah Agus Sanjaya. Slide Part 6 - NORMALISASI.

Tidak ada komentar:

Posting Komentar