How to find a candidate code relationship model

By definition the first candidate code: If the value of a property set relationship can uniquely identify a tuple, the attribute is said group of candidate codes.

If W is a candidate key, two conditions must be met: W is the U-closure; W without redundancy.

R mode is provided in relation U = ABC ....... attributes like N, U in the range of four kinds of attributes in the FD:

Simple methods seeking candidate codes:
(1) If attribute is not functional dependency concentrated there, it must be included in the candidate code; and
(2) if there is attribute is not functional dependency concentration of any right of functional dependency is present, it must contain in the candidate code; and
(3) if property appears only in the left set of functional dependencies, the attribute must be included in the candidate code.
(4) If attribute or tuple uniquely identifies the group, it is the candidate code;

Algorithm: key candidate seeking the following steps:
1. Only the right part of the attribute appearing FD, does not belong to the candidate code;
2. FD attribute in the left portion only occur, there must be a particular code among the candidates;
3. External attributes must exist among any candidate code;
4. 3 other properties in combination with properties individually, seeking properties closure until the closure of X is equal to U, if equal to U, then X is a candidate code.

Example 1: R <U, F>, U = (A, B, C, D, E, G), F = {AB -> C, CD -> E, E -> AA -> G }, seeking candidate code.

  By G only appears on the right side, so that G must not belong to the candidate code; and B, D only in the left, so that B, D must belong to candidate code; BD closure or BD, then the BD are combined, in addition to G, BD can be carried out with a, C, E combinations
  look ABD
  ABD ABD packet from itself, and AB -> C, CD -> E, a -> G, the closure is so ABD ABDCEG = U
  look BDC
  CD -> E, E -> a, a -> G, BDC from the package itself, the closure of the BDC BDCEAG = U
  last see the BDE
  E -> a, a -> G, AB - > C, BDE itself from the package, the closure of the BDE BDEAGC = U

  Since (ABD), (BCD), (BDE) of the closure are so ABCDEG candidate codebook has three problems are ABC, BCD and BDE

 

Example 2: R <U, F>, U = (A, B, C), F = {AB -> C, C -> B}, seeking candidate code.

Because A only appears on the left, so A must be a candidate key. A closure is A, then the combination of A, and may be a combination of B, C.

First look AB, AB from the package itself AB, and AB -> C, so that the closure is AB ABC = U.

Look AC, AC package itself from AC, and C -> B, so that the closure is AC ABC = U.

Because AB, AC closures are ABC, which is U, so the candidate key is AB, AC.
---------------------
Author: the way forward 1
Source: CSDN
Original: https: //blog.csdn.net/weiyongle1996/article/details/73481163
copyright Disclaimer: This article is a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin www.cnblogs.com/zhoading/p/10934944.html