"Sister school to teach database system" (five) logical database design (lower)

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

  1. (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

  2. (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

  3. (Unique function depends left portion) left Fc portion of any two different functional dependencies
    Here Insert Picture Description

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
Here Insert Picture Description

  • 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

  1. Cause: Sdept and the non-primary property Sdean portion functions depend on the candidate key (Sno, Cno)

  2. Solution: The SDC broken down into the following two relational schema:

  • SD (Sno, Sname, Sdept, Sdean)
  • SC (Sno, Cno Grade)

The second paradigm (2NF)

  1. 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.

Here Insert Picture Description

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

  1. Cause: non-primary property Sdean transfer function depends on the candidate key Sno

  2. 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
Here Insert Picture Description
Here Insert Picture Description

There is a problem

No non-primary property in STC (Sno, Tno, Cno) (candidate key (Sno, Tno) and (Sno, Cno))
Here Insert Picture Description

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
    Here Insert Picture Description

  • 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

  1. Cause: the main part of the function depends on the property Cno candidate key (Sno, Tno)

  2. Solution: The STC is decomposed into the following two modes relation: TC (Tno, Cno), ST (Sno, Tno)

Boyce-Codd paradigm (the BCNF)

  1. 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

  2. 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
    Here Insert Picture Description

The relationship between paradigm

Here Insert Picture Description

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)
Here Insert Picture Description

Relationship mode decomposition criteria 1: Lossless Connectivity (LosslessJoin)

Here Insert Picture Description
Here Insert Picture Description

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.
Here Insert Picture Description

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.
Here Insert Picture Description

Non-destructive determination of the connectivity

  1. Objective: determining a relationship between the lossless mode decomposition meets the connectivity

  2. When the determination method 1] a method of relational model is decomposed into two relational schema)

  3. 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

  1. Objective: determining a relational schema decomposition retention meets functional dependencies

  2. Method 1: the determination of a function dependent on the definition of retention

  3. 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
Here Insert Picture Description

BCNF relational schema decomposition algorithm

Function: the relational schema R (U, F) decomposed into a set lossless join BCNF relational schema
Here Insert Picture Description

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!

Published 116 original articles · won praise 1194 · Views 190,000 +

Guess you like

Origin blog.csdn.net/JAck_chen0309/article/details/105086044