hello Hello, everyone, to learn the last half of the logical database design ( Click to review ER model into a relational database schema and functional dependencies ), today we learn the lower half: Paradigms and decomposition of relational schema . Sister school to teach database, never seen such a cool title, right? "Language does not startle," Yes, the title is so cool.
My little sister buried 18-year-old campus goddess of existence, the outstanding universal sport, personality gentle and virtuous. However, only I know, everybody's eyes shining little buried in the past is a hamster dressed in cloak, rolling on the floor, ate and slept and play super house women. And all this change, since the day is night.
Since then, the small underground often let me help her homework. The upper half of the last time she listened to the logical database design, and this time begged me to talk about the lower half. This tutorial by the way I buried with little dialogue to talk about the logical database design.
Blog continues to update, the other blog to see the same series. Welcome to my column "sister school to teach database system," I hope we can pay attention to me, and together learn database system.
Paradigm of the Relationship Model
Minimum coverage (canonicalcover) relational schema R (U) dependent function F is set to satisfy the following three conditions F
equivalent functional dependencies Fc
-
(Redundant functional dependency does not exist) functional dependency X → Y, such that the Fc and Fc- {X → Y} is equivalent to the absence of the Fc
-
(Redundant functional dependencies left portion attribute does not exist) in the absence of Fc-dependent functions X → Y, such that there Z⊂X Fc and (Fc- {X → Y}) ∪ {Z → Y} is equivalent to
-
(Unique function depends left portion) left Fc portion of any two different functional dependencies
The first paradigm (1NF)
If the relationship pattern of each attribute is inseparable R , R is called a first mode relationship paradigm, referred to as R∈1NF
- Question 1: data into exception. Description: The inserted data can not be inserted
- Question 2: delete abnormal data. Phenomenon: you should not have to remove deleted data
- Question 3: data modification cumbersome. Phenomenon: data modification is very tedious, error-prone
- Question 4: data redundancy. Phenomenon: there are a lot of redundant data
Main properties: a candidate key attributes
There is a problem
Question 1 (insert data anomalies): the insertion of data can not be inserted
Question 2 (delete abnormal data): you should not have to remove deleted data
Question 3 (data modification tedious): data modification tedious, error-prone
Question 4 (data redundancy): there are a lot of redundant data
Solution
-
Cause: Sdept and the non-primary property Sdean portion functions depend on the candidate key (Sno, Cno)
-
Solution: The SDC broken down into the following two relational schema:
- SD (Sno, Sname, Sdept, Sdean)
- SC (Sno, Cno Grade)
The second paradigm (2NF)
- If the relational schema R∈1NF , and each non-primary property of R are totally dependent on the function of the candidate key R , R is called the second mode relationship paradigm, referred to as R∈2NF.
There is a problem
Question 1 (insert data anomalies): the insertion of data can not be inserted
Question 2 (delete abnormal data): you should not have to remove deleted data
Question 3 (data modification tedious): data modification tedious, error-prone
Question 4 (data redundancy): there are a lot of redundant data
Solution
-
Cause: non-primary property Sdean transfer function depends on the candidate key Sno
-
Solution: The SD mode is decomposed into the following two relations: IS (Sno, Sname, Sdept), ID (Sdept, Sdean)
Third Normal Form (3NF)
If the relational schema R∈2NF , and each non-primary property of the transfer function of R not depend on the candidate key R , and R is a third paradigm called relational model, referred to as R∈3NF
There is a problem
No non-primary property in STC (Sno, Tno, Cno) (candidate key (Sno, Tno) and (Sno, Cno))
In a relationship, if a configuration attribute is a keyword candidate ( candidate key property of a set of properties), the main call attributes.
-
Question 1 (insert data anomalies): the insertion of data can not be inserted
-
Question 2 (delete abnormal data): you should not have to remove deleted data
-
Question 3 (data modification tedious): data modification tedious, error-prone
-
Question 4 (data redundancy): there are a lot of redundant data
Solution
-
Cause: the main part of the function depends on the property Cno candidate key (Sno, Tno)
-
Solution: The STC is decomposed into the following two modes relation: TC (Tno, Cno), ST (Sno, Tno)
Boyce-Codd paradigm (the BCNF)
-
If the relational schema R (the U-, F) ∈1NF , and F is the smallest coverage of each functional dependency X → Y a candidate key is the left portion of R X , R is called Relationship Model BC mode, referred to as R∈BCNF
-
If the relational schema R (the U-, F.) ∈3NF , and any of the main properties of R are directly dependent on the exact function of the candidate key R , and R is called Relationship Model BC mode, referred to as R∈BCNF
The relationship between paradigm
Relations mode decomposition
Provided R (the U-) on a relational model is a set of attributes U, ρ = {R1 (U1), R2 (U2), ..., Rn (Un)} is a decomposition of R (decomposition), if U = U1∪U2∪ ··· ∪Un, and for any i is not equal j, Ui has not included in Uj (without redundancy)
Relationship mode decomposition criteria 1: Lossless Connectivity (LosslessJoin)
Relationship mode decomposition criterion 2: functional dependency retention
Projection of functional dependencies
Provided R (U, F) relationship model, U is the set of attributes, F is the functional dependencies. For V⊆U, F V is projected on the function of X → Y X∪Y⊆V dependent set F + satisfying.
Maintaining functional dependency decomposition
Provided R (U, F) is a relational model, U is the set of attributes, F is the functional dependencies. Provided ρ = {R1 (U1), R2 (U2), ..., Rn (Un)} of the R is an exploded, Fi F is projected on the Ui. If F1∪F2∪ ··· ∪Fn cover F, then ρ is a function dependent holding mode decomposition.
Non-destructive determination of the connectivity
-
Objective: determining a relationship between the lossless mode decomposition meets the connectivity
-
When the determination method 1] a method of relational model is decomposed into two relational schema)
-
Theorem: relational schema R (U, F) decomposition ρ = {R1 (U1), R2 (U2)} necessary and sufficient conditions are met lossless connectivity is F | = U1∩U2 → U1 or F | = U1∩U2 → U2
Functional dependency determination of retention
-
Objective: determining a relational schema decomposition retention meets functional dependencies
-
Method 1: the determination of a function dependent on the definition of retention
-
Method 2: F functional dependencies for each functional dependency X → Y, the following algorithm determines whether F1∪F2∪ ··· ∪Fn | = X → Y
Decomposition of relational schema
3NF relational schema decomposition algorithm
Function: the relational schema R (U, F) is decomposed into a set of 3NF relational schema, and decomposition while maintaining the functional dependency, but also to meet the connectivity lossless
BCNF relational schema decomposition algorithm
Function: the relational schema R (U, F) decomposed into a set lossless join BCNF relational schema
to sum up
We play go play, go downtown downtown, Do not take a joke learning.
Relationship paradigm first paradigm, the second paradigm, the third paradigm, the BCNF paradigm is based entirely dependent function and the transfer function dependent progressive layers (if not clear functional dependency relationship can look back upper part).
It is worth noting that the specification is one of the criteria for evaluating relational schema. Each mode has a relationship if necessary into 3rd normal form or BCNF paradigm, welcome message exchange!