Synthesis algorithm

from Wikipedia, the free encyclopedia

The synthesis algorithm describes how a relational database schema becomes a relation schema of the third normal form . The special thing about this algorithm is that, in contrast to the intuitive decomposition of the schema into the third normal form, it guarantees the maintenance of dependency in every case.

An alternative algorithm is the decomposition algorithm , which transfers into Boyce-Codd normal form (BCNF). However, dependencies can be lost (not true to dependency ). It is an alternative insofar as every relational schema that is transformed in BCNF is then automatically available in the third normal form.

requirement

All functional dependencies of the relation to be decomposed under the attributes must be known.

Example:

The synthesis algorithm then consists of four steps:

  1. Reduction of , d. H. the determination of the canonical coverage.
  2. Creation of the new relation schemes from the canonical cover.
  3. Possibly. the addition of a relation that only contains the original key.
  4. Elimination of the schemes that are contained in another scheme.

reduction

This is also called the calculation of the canonical coverage .

1st step: Left reduction

For all replace by , if is already determined by .

The above condition can be tested by checking whether is, where F denotes the set of functional dependencies. If so, can made be removed.

Example:

In the second relation, E is omitted because B and D are in the attribute envelope of A ( ). In the last relation, C is omitted because of . You can also put it this way: E is not needed in to achieve.

Solution:

2nd step: legal reduction

For all replace by , if is already determined transitive by .

The above condition can be checked by testing for each whether is. If so, can made be removed.

In the example above:

In the first relation B is omitted because = {A, B , D, E}. In the fourth relation the B is also omitted because of = { B , C, D, E, F}.

3rd step: Empty clauses

Eliminate form clauses

In the example from step 2, there are no dependencies with an empty, right-hand side. So in this case there is nothing to do here.

4th step: summarize

Fasse formulas to together.

In the example we now summarize expressions with the same left side:

New relation scheme

All Ψ Γ become R (Ψ, Γ).

In addition, a new key must be found. If necessary, a new relation must be created. Unnecessary relations can be deleted if they are contained in others.

Exemplary:

  • ( A , B, D, E) # A is the primary key
  • (B, C, D, F ) # F is the primary key
  • ( C, D , E, F) # CD is the primary key (the elements of this relation are already through and given, but to preserve the dependency they must still be listed, it should only be removed if one relation were completely contained in another. However, this is not possible because these cases were removed beforehand by the left and right reduction.)

Adding a relation

Now, by adding a relation, a relationship between , and must be established. This is made possible by a relation that only contains the source key (note that is). We get a scheme in the 3rd normal form as follows:

  • , where and respectively represent foreign keys and together generate the primary key of .

Formal algorithm

Input: universal scheme Output: 3. Normal form of

Individual evidence

  1. ^ A. Kemper, A. Eickler: Database systems , ISBN 3486576909 .