relational database
First, the origin of the relational database
1. The system is strictly proposed by the relationship database model is the US IBM E.CODD.
2, 1970, E.f.codd continued to improve and develop relationship theory.
3, C.j.data is the most famous independent writer, scholars and consultants in the field of relational database.
Second, the relationship model overview
The relational model consists of three parts: relational data structure, relational operation set, and relational integrity.
1. Single data structure relationship
The data structure in the relationship model is very single. The relationship is a two-dimensional table in the relationship between entities and entities.
2, relationship operation
The relationship operations commonly used in the relational model are included. The relationship operation is characterized by a collection of operation, ie, the objects and results of the operation are set. This way of operation has also become a set of ways. Accordingly, the data operation mode of the non-relational data model is a one record.
3, three types of integrity constraints: solid integrity, reference integrity, user-defined integrity.
Third, relational data structure and formal definition
1, relationship
1. Domain: The domain is a set of values with the same data type.
2. Cartesian:
Definition: given a set of domains D1, D2, ..., DN, which can be identical in these domains. D1, D2, ..., DN of Cartesi:
D1 × D2 × ... × DN = {(D1, D2, ..., DN) | di∈di, i = 1, 2, ..., n}
Each element (D1, D2, ..., DN) is called an N tone group or a tether. Each value di in the tuple is called a component.
If Di (i = 1, 2, ..., n) is a limited set, the base is Mi (i = 1, 2, ..., n), then D1 × D2 × DN of the base M is: Mi product.
3. relationship:
Definition: The subset of D1 × D2 × ... × DN is called the relationship between the domains D1, D2, ..., DN, indicated as:
R (D1, D2, ..., DN)
D1 × D2 × ... × DN is expressed as all possible combinations on the domain, and many of the groups in real life are meaningless data, and a relationship is definitely included in D1 × D2 × ... × DN, so in mathematics Define the relationship as a subset of D1 × D2 × ... × DN.
The relationship is a limited subset of the Cartesi, so the relationship is also a two-dimensional table, and each row of the table corresponds to a tuple, and each column of the table corresponds to one domain. Since the domain can be the same, in order to distinguish, a name must be columnized, called attributes. N objects must have n attributes.
Candidate: If the value of a certain attribute group in the relationship can uniquely identify a tuple, the data is called a candidate code.
Full code: If there is a plurality of candidate codes, one of them is selected as the master code. The owner of the main code is called primary attribute. The attributes that are not included in any candidate code are called non-code properties. All data groups of the relationship model are candidate codes of this relationship mode, called full code.
There are three types of relationships: basic relationships, query tables, and view tables.
Limit and expansion of relationships:
(1) Unlimited relationship is meaningless in the database system. Therefore, the relationship in the defined relational data model must be a limited set.
(2) Cancellation of the relationship tuples by adding an attribute name to each column of the relationship.
The basic relationship has the following six properties:
1. The column is homogeneous, that is, the components in each column are the same type of data, from the same domain.
2. Different columns can come from the same domain, called each of them as an attribute, and different attributes are given different attribute names. 3. The order of the column does not matter, that is, the order of the columns can be exchanged any.
4. Any two tuples cannot be identical.
5. The order in the line does not matter, that is, the order of the line can be exchanged any.
6, the component must take the atom value, that is, each component must be an unacceptable data item.
Remarks: In many actual relational database products, the basic table does not completely have these six properties, for example, some database products (such as FoxPro) still distinguish the order of attribute sequence and tuples; many relational database products, such as Oracle , FoxPro et al, they all allow two identical tuples in the relational table.
Fourth, relational mode
Definition: The description of the relationship is called the relationship mode. It can be formally expressed as:
R (U, D, DOM, F)
Relationship modes can usually be referred to as:
R (u) or r (A1, A2, ..., AN)
V. Integrity of the relationship
1, physical integrity
Entity Integrity Rules: If attribute A is the primary property of the basic relationship R, the attribute A cannot take null values.
The entity integrity rules are as follows:
(1) Entity integrity rules are for basic relationships. A basic table usually corresponds to an entity set in the real world.
(2) The entity in the real world is distinguishing, ie they have some uniqueness identification.
(3) Accordingly, the main code is used as the unique identifier in the relational model.
The attribute in the horses is that primary attributes cannot take null values. The so-called null value is "do not know" or "uncertain" value.
2, reference integrity
External code definition: Set F is one or a set of properties of the basic relational R, but not the code R, if f corresponds to the main code KS of the basic relationship S, said F is the outer code of the basic relationship R (FOREIGN KEY The basic relationship R is referred to, and the basic relationship S is the reference relationship or the target relationship. Relationships r and s are not necessarily different.
Note: f cannot be the main code of the relationship R, the KS must be the main code of the relationship S.
Reference integrity rules is to define the reference rules between the external code and the main code:
Reference Integrity Rules: If the attribute (or attribute group) f is the outer code of the basic relational R, it corresponds to the main code KS of the basic relationship S (the basic relationship R and S are not necessarily different), then for R The value of each tuple in f must be:
Or take null value (each attribute value of f is null);
Or equal to the main code value of a group in S.
3. User-defined integrity: is a constraint condition for a specific relational database.
Sustainable continued.
Well-off
Xiaokang1949@hotmail.com
2004-2-29