What exactly are the relationships in a relational database? (1)

definition

The definition of the relationship can be given by the following formula.

R ⊆ (D1×D2×D3 · · · ×Dn)

(The relation is represented by the symbol R, the attribute is represented by the symbol Ai, and the domain of the attribute is represented by the symbol Di)
This formula reads as "Relation R is a subset of the Cartesian product of domains D1, D2, …, Dn".
The formula is very concise, in order to facilitate understanding, let us give a simple example to explain. First, suppose
there are 3 attributes a1, a2, a3, and then we describe their domains. The
domain of definition mentioned here is the same as the domain of function in mathematics, which refers to the "value set of attributes". We assume that
attribute a1 can take one value, attribute a2 can take two values, and attribute a3 can take three values.
The definition domain corresponding to each attribute is called d1, d2, d3
Insert picture description here

Cartesian product

When using these 3 domains to generate relations, what is the maximum number of tuples
? The answer is 6. The calculation method is very simple, that is, 1×2×3=6. All tuples are
shown in the following table.
Insert picture description here

This relationship R1 is the Cartesian product. Cartesian product refers to " the set with the largest number of combinations generated by the domain of each attribute
"
. Therefore, all relations
Rn generated by the above three domains are a subset of this Cartesian product. For example, in addition to R1, we can also define R2, which is
defined by "R1 in the first row and second row

Guess you like

Origin blog.csdn.net/MyySophia/article/details/114905417