【Intermediate Software】Database—Three Common Exam Patterns and Real Questions

1. Concept:

        Using the normalization theory, the function set of the relational schema meets specific requirements, and the relational schema that satisfies the specific requirements is called a paradigm. The relationship is divided into 5 normal forms (Normal Form) according to its normalization degree from low to high, which are called 1NF, 2NF, 3NF (BCNF), 4NF and 5NF. Those with a higher degree of normalization must be a subset of the lower ones . (i.e. containment relationship)

2. Soft test part:

        Software intermediate software designers rarely take the 4th and 5th paradigms, so we hardly consider them when preparing for the exam. The database part also accounted for 5 to 6 points in the morning test , and then there was still a big question in the afternoon. 

Third, the first normal form:

definition:

        If the relational schema R does not contain multi-valued attributes (each attribute must be an inseparable data item) , then R satisfies the first normal form (First Normal Form), denoted as R∈1NF

Note:        1NF is the minimum requirement for normalization and the most basic paradigm to be followed by the relational schema. A relation that does not satisfy 1NF is a denormalized relation 

      Simply put, each component in the relationship must be an indivisible data item. That is, there cannot be a small table. For example, the following employee table does not belong to the first normal form. 

 

Fourth, the second normal form:

definition:

        If the relational schema R(U, F)∈1NF, and each non-primary attribute in R fully functionally depends on a candidate key of R, then R satisfies the second normal form (Second Normal Form), denoted as R∈2NF

In layman's terms, 2NF is based on 1NF, and each non-primary attribute in the table does not depend on a column in the composite primary key. 

 

 cause problems:

        A relational schema that does not satisfy 2NF will cause the following problems. The above figure is an example:

        1. Insert exception . Inserting a new student, if the student does not take a course, the CNO is empty, but because the code cannot be empty, it cannot be inserted.

        2. Remove exceptions . A student has only selected one course, and now the course will be deleted, and the basic information of the student will also be deleted.

        3. Update exception . If a student wants to transfer from one department to another, if the student chooses K courses, the relevant field values ​​of the student must be modified to 2K (department, residence). If there is any omission, it will destroy the consistency of the data. sex.

       The reason for the above problems is that some functions of SDEPT and SLOC depend on the code

Solution:

       The solution is to use projection decomposition to decompose the relational schema into multiple relational schemas .

        Projection decomposition is to decompose the non-primary attributes and determinants to form a new relationship, the determinants are maintained in the original relationship, and the functional dependencies are transformed accordingly ( remove the partially dependent attributes in the relationship schema, and separate the partially dependent attributes into a new relationship. mode )

        The above relationship schema decomposition results are as follows:

        Because after schema decomposition, the non-primary attribute pairs in the two relational schemas are completely functionally dependent, so they both satisfy 2NF

 Fifth, the third normal form:

definition:

If the relational schema R(U,F)∈2NF , and each non-primary attribute does not depend on any candidate key, the third normal form is satisfied, denoted as R∈3NF

In layman's terms, on the basis of satisfying 2NF, there is no transitive dependence of non-primary attributes on codes in the table. 

 

Solution:

       SL is also projected and decomposed, and the results are as follows:

        There is no longer a transfer function dependency in the decomposed relationship, that is, the relationship models SD and DL both satisfy 3NF

 Note: 3NF is the lowest normal form that a usable relational schema should satisfy, that is, a relational model that does not satisfy 3NF is actually not usable

 Sixth, the real question:



 


Guess you like

Origin blog.csdn.net/m0_56233309/article/details/124016494