2.1.1 Relationships

-------------------------------------------------- -------------------------------------------------- --------------------------------------
2.1 Relational database structure and formal definition 3 elements of

data model : Relational data structures, relational operation sets, relational integrity constraints.

-------------------------------------------------- ------------------
2.1.1 Relationship
1. Domain (Domain) A set of values ​​with the same data type.

2. Cartesian Product Set operations. Given a set of domains D1,D2,...,Dn, these domains can be the same domain. The Cartesian product of D1,D2,...,Dn is
D1×D2×...×Dn = {(d1,d2,...,dn)|di∈Di,i=1,2,... ,n}
where each element (d1,d2,...,dn) is called an n-tuple
and a value di in the element is called a component.
If Di(i=1,2,...,n) is a finite set and its cardinal number is mi(i=1,2,...,n), then D1×D2×...× The cardinality M of Dn is:
         

3. Relation
A subset of D1×D2×...×Dn is called a relation on the domain D1×D2×,...Dn, expressed as R(D1,D2,.. .,Dn)
Here R represents the name of the relationship, and n is the degree or degree of the relationship.
Each element in the relation is a tuple in the relation, usually denoted by t.
When n=1, the relation is called Unary relation, or unary relation.
When n=2, the relation is called binary relation.
A relation is a finite subset of a Cartesian product, so a relation is also a two-dimensional table, with each row of the table corresponding to a tuple and each column of the table corresponding to a field. Since the fields can be the same, in order to distinguish them, each column must have a name, called an attribute. An n-order relationship must have n attributes.
If the value of an attribute group in the relationship can uniquely identify a tuple, the attribute group is called a candidate key (Candidatekey).
If a relationship has multiple candidate keys, one of them is selected as the primary key.
The attributes of the candidate code are called prime attributes. Attributes that are not included in any candidate key are called non-prime attributes or non-key attributes.
In the simplest case, the candidate key contains only one attribute. In the most extreme case, all attributes of a relation schema are candidate keys for this relation, called all-keys.
In general, the Cartesian product of D1,D2,...,Dn has no practical semantics. Only some subset of it has real meaning.


Relationships can be of three types: base relationships (often also called base tables or base tables), lookup tables, and view tables.
The base table is the table that actually exists, it is the logical representation of the actual stored data.
The query table is the table corresponding to the query result.
A view table is a table derived from a basic table or other view tables. It is a virtual table and does not correspond to the actual stored data.


The relational model requires that the relation must be normalized, that is, the relation must satisfy certain normative conditions. The most basic of these normative conditions is that each component of the relation must be an indivisible data item. Normalized relationship abbreviation (Normal Form).

In layman's terms, there are no tables in relational tables, in short, "tables in tables" are not allowed. As shown below:

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326520814&siteId=291194637