MOOC Notes database (C): The basic concept of the relational model

The basic concept of the relational model

Relational Model Description

1. The first proposed in 1970 by the EFCodd.
2. from the treatment table (Table) table and the abstract, is based on the traditional operating table and its mathematical strict definition of the proposed introduction of the theory set theory and logic.
3. The classical model is one of the three databases, and now most database systems still use a relational data model.
4. standard database language (SQL language) is built on the basis of the relational model, database fields are also many theories are built on the basis of the relational model.

What Relationship Model

1. We the relationship (relation) are abstracted into a a Table.
Table 2. The relational model is the process, which consists of three parts:
① basic structure described various data DB (Table / Relation)
② describe various operations that may occur between the Table and the Table (relational operation)
③ these constraints described operations to be followed (integrity constraints)

Three elements relational model

① basic structure: the Relation / the Table
② basic operations: (: cross ∩, and ∪, difference -, and the like, for example, the projection π) the Relation the Operator
③ integrity constraints: Custom entity integrity integrity, completeness, and referring to the user.

About relational operators

Relational operators: relational algebra and relational calculus: relational calculus: field tuple calculus and calculus.
See next week's blog (probably)

Mathematical description of the relationship

First, the definition of the column in the range "field (the Domain)"

Domain (Domain)

1. The set values of a set, the set values have the same data type. The set of the set of integers, strings, all students set
the number of elements in a set is 2. The base domain (the Cardinality)

Redefinition "tuple" and may be all combined into tuples: Cartesian Product

Cartesian product (Cartesian Product)

1. a set of domain D . 1 , D 2 , ......, D n- Cartesian product of:
D . 1 × D 2 × D × ...... n- = {(D . 1 , D 2 , ....., D n- ) | D I ∈D I , I} =. 1 .... n-
2. each element of the Cartesian product (D . 1 , D 2 , ......, D n- ) referred to as a n- tuple

Tuple (D . 1 , D 2 , ......, D n- ) for each value of D I I am called a component (Component)
tuple (D . 1 , D 2 , ......, D n- ) is a composition formed from any of the fields each take a value, this Cartesian product is the set of all possible combinations, namely: Cartesian product is a set of all possible n- tuple formed by n fields
if D I cardinality m I , the Cartesian product of cardinality, i.e., the number of tuples m . 1 × m . 1 × ... × m n-

Since all tuples of Cartesian product is not meaningful, so ...

Relations (Relation)

1. a set of domain D . 1 , D 2 , ......, D n- subset of the Cartesian product of the
2 tuples of those having a certain significant aspects of the Cartesian product is called a relation (the Relation)
Because of the relationship between different columns may come from the same domain, to distinguish between the need for each column a name, that name is the property name.
3. The relationship may be R & lt (A . 1 : D . 1 , A 2 : D 2 , ..., A n- : D n- ) said may be abbreviated to R & lt (A . 1 , A 2 , ..., A n- ), this description is called relationship model (Schema) or table header (head)
4.R is the name of a relationship, a I is the attribute, D I is the corresponding attribute field, n being the degree of relationship or mesh (degree), base (cardinality) the relationship between the number of tuples called relationships
such as: family (husband: a man, his wife: women, children: children) or family (husband, wife, children)
5. R relational schema attributes to the field of image in many kinds of ships DBMS directly described as the attribute type and length.
例如: Student (S # char (8), Sname char (10), Ssex char (2), Sage integer, D # char (2), Sclass char (6))

Relational model and relational

1. Under the same relational schema, there are many relationships can
2. The relational model is a structural relationship, the relationship is a time mode data
3. The relational schema is stable: the relationship between the value of a certain time, is included with time may change

Property relationships and related concepts

1. The column is homogeneous: i.e. the component in each column from the same domain, the same type of data
2. Different columns from the same domain, called as a property of each of which, different to give different properties the property name.
3. interchangeability column position (independence)
4. interchangeability row position (independent of)
any 5. In theory, the relationship between two tuples can not be identical. (Set of requirements: You can not have two elements in the same set); real-world applications, table (Table) may not fully comply with this feature.
(This also explains the relationship between the table and are not identical).
6. Each tuple refers to the same components of the two-tuples are the same.
7. The property can not be divided characteristics: also known as a first relationship Paradigm

Some important concepts on the relationship

Code candidate (Candidate Key) / candidate key

A set of attribute relationships that can uniquely identify the value of a tuple, if any is removed from a property of the group attribute, it is not of this nature, so called candidate code set of attributes.
Candidate code is not necessarily only one candidate set of code may comprise a plurality of attributes.
For example, high school students school student table number is a candidate key.

Master Code (Primary Key) / primary key

When there are a plurality of candidate codes can be selected as a primary key.
DBMS to the primary key for each tuple main lead management relations.

Primary and non-primary property attribute

Attribute contains any candidate codes is called primary property and other properties referred to as non-primary property is
the simplest, the candidate code contains only one attribute.
Most extreme, all the properties of candidate code constituting this relationship, known as full code (All-Key).

Outer code (Foreign Key) / foreign key

In a relation R group attribute, it is not a candidate key R, it is another relation candidate code with the corresponding S, R group attribute called the outer code or foreign keys.
Two relationships are usually connected together by an outer code.

The integrity of the relational model

Entity integrity

The primary key attribute value relations can not be null.

Null: I do not know, does not exist or meaningless value

Database with null values, will affect many aspects, such as the impact of aggregate function operation correctness, can not participate and arithmetic, comparison or logic operation and so on.
When a null value is that require special handling, paying particular attention.

Referential integrity

Multiple properties within a certain range corresponding to the relationship between a relationship between the outer code in the outer code.
A tuple of a relation may not have the outer code.

User-defined integrity

Integrity constraints for the user specific application environment definition.
When the update operation occurs, DBMS will automatically Yasuteru integrity constraints verify the correctness of the update operation.

Guess you like

Origin www.cnblogs.com/z-y-k/p/11574748.html