Database Theory Review (I, II)

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/Unicorn_JF/article/details/102471979

First, the basic concept

1, data

The symbol is a description of the real world, the basic object is stored in the database.

2, the data model

Is described in a set of definitions of data, is a data structure.

3, the data pattern

With a given set of data models, the results of a particular transaction after modeling.

4, the level of abstraction of data

  1. Physical Mode: the form data is stored on disk.
  2. Logical mode: the form of data representation.
  3. An outer pattern (view): the way the user sees.

Three mode, two maps.

Independence 5, data

It is composed of two data mapping guaranteed.

  1. Logical Independence : i.e. change the logical form of representation of the data is changed, the view may not change.
  2. Physical independence : changes in the physical storage structure may not affect the view.

6, a database (DB)

Long-term storage in the computer can be organized, structured sharing of large data sets.

7, database management systems (DBMS)

Data management software layer is located between the user and the operating system, and database management to run establishment and maintenance of a database.

basic skills:

  1. Data definitions;
  2. Data manipulation;
  3. Integrity constraint checking;
  4. Access control;
  5. Concurrency control;
  6. Database recovery.

8, the database system (DBS)

By the application, DBMS, DB, DBA composition.

9, data management stage

Artificial Management -> File System -> Database System

Second, the data model

1, the first generation of the database system

Collectively referred to as formatted data model.

1-1, hierarchical model

The basic structure is similar to a tree. With parent-child relationship (PCR) to express the relationship to-many real-world two different types of records.

1-2, Network Model

Similar to a directed graph. The basic structure is the line (SET), each record is a master record other records, the case may be recorded as a linked list memory. The LINK : shows a self-ligation.

2, the second generation of the database system

Support database systems relational data model.

2-1 Relational Model

The basic structure is a table (Table) ,

basic concepts:

  1. Entity (Entry): reflect the objective things.
  2. Attribute (Attribute): an entity defined characteristics.
  3. Domain (Domain): attribute range.
  4. Entity set (Entry Set): the set of all property names exactly the same entity.
  5. Collection name and all attribute names entity set: an entity type (Entry Type).
  6. Code (Key): attribute distinguishing between entities.
  7. Relationship: is a table.
  8. Tuple: a row of data relationships.

3, relational algebra

Any operating system to meet the basic relationship is said to be complete. (A process of)

3-1, the basic operation

  1. Select (σ): The table in qualifying tuples find out. (No repetition)
  2. Projection (π): the table qualified property to find out. (Generally need to go heavy, but not by default)
  3. Cartesian product (×): splicing together the two tables.
  4. Set difference (-): 1 relationship belong to, but not part of the relationship between the elements 2 to find out.
  5. And (U): the primitive assembly, and two identical patterns.

1 and 2 are unary operators, 3,4,5 binary operations, the number of attributes that must be met (1) the same. (2) as the corresponding attribute type.

3-2, other operations

It can be derived from the basic operations.

  1. cross
  2. Connection Table
  3. division
  4. Outer join

3-3, the connection condition

⋈ R & lt c S = [sigma] c (R & lt × S), R & lt, S c do conditional connection table, corresponding to the selection criteria in the Cartesian product of the c tuple.

3-4, natural join (INNER JOIN)

Up to the most commonly used as a connector, do the equivalent connection in all the public properties, and the combined duplicate properties.

3-5, the outer connector

  1. The left outer join (* ⋈): left tuples encountered reservations, fill null value NULL nonconformity.
  2. Right outer join (⋈ *): the right to retain all tuples, fill null value NULL nonconformity.
  3. Full outer join (* ⋈ *): about all reservations, fill null value NULL nonconformity.

3-6, and outside

All attributes are combined, if the value is not null.

3-7, the division

Suitable for locate all records satisfying certain conditions ;

Let A table has attributes X, y; B table has attribute y;
A / B = {<X> | ∃ <X, y> ∈ A, ∀ <y> ∈ B},
any B is

Basic operation: find the A, B for all values of x and y values related, it is to find any x value and a y do independent difference.
Unsatisfied X: [pi] X (([pi] X (A) × B) -A);
satisfies X: [pi] X (A) - does not satisfy x.

4, relational calculus

And equivalent relational algebra expression, but non-procedural, an expression method of ranking logic. Only we need to express their demands be satisfied with the results, but do not explain the process of obtaining results.
- [tuple relational calculus (TRC)]: In a variable defined in units of tuple.
- [domain relational calculus (DRC)]: The attribute value defines variables.

4-1, domain relational calculus

{<X . 1 , X 2 , ..., X n- > | P (X . 1 , X 2 , ..., X n- , X n-+. 1 , ..., X n-m + )}
atomic formula:

  1. <x1,x2,…,xn>∈ R;
  2. X op Y; (X, Y variable domain)
  3. X-op constant; (wherein op is>, <, =, ≥, ≤, ≠)

Defined by the equation:

  1. All atomic formula is a formula;
  2. If p, q is the formula, ﹁q, p∧q, p∨q is formula;

4-2, security inquiry

There will be some problems in calculus, satisfy a query is not the result of an infinite number of safety.

4-3, skills

Queries can express with security calculus also can be expressed in relational algebra

4-4, tuple relational calculus

{T [<tuple>] | P (t)}

5. Summary

There are traditional data models: hierarchical, network, relational.
Applies: OLTP (Online Transaction Processing) applications to record basis, based structured storage.
Cons: not a good user-oriented; the links between entities can not be expressed in a very natural way; less data type, some demand is difficult to meet.

Modern data model: ER (entity - Contact), can be very good to describe things in the real world; object-oriented model, in the sense of breaking the restrictions 1NF; based on the logical model, (deductive database system).

Guess you like

Origin blog.csdn.net/Unicorn_JF/article/details/102471979