1. attributes and domains in the real world, a thing is often described by several features which become attributes ). The value range of each attribute corresponds to a set of values and becomes the domain of the attribute ). Generally, in the relational data model, all domains are limited to atomic data ). For example, integers and strings are atomic data.
1. attributes and domains in the real world, a thing is often described by several features which become attributes ). The value range of each attribute corresponds to a set of values and becomes the domain of the attribute ). Generally, in the relational data model, all domains are limited to atomic data ). For example, integers and strings are atomic data.
1. attributes and fields
In the real world, a thing is often described by several features which become attributes ). The value range of each attribute corresponds to a set of values and becomes the domain of the attribute ). Generally, in the relational data model, all domains are limited to atomic data ). For example, integers and strings are atomic data, while collections, records, and arrays are non-atomic data. This restriction of the relational data model is called the First Normal Form (1NF) condition.
2. Main terms
- Degree: the number of attributes n is the object or Degree of the link.
- Candidate Key: if the value of an attribute (or attribute group) in a link uniquely identifies a tuples, this attribute (Attribute Group) is called a Candidate code.
- Primary Key: If one link has more than one candidate code, select one of them as the master code.
- Key attribute: the attribute contained in any candidate code is called the primary attribute.
- Non-Key attribute: an attribute that is not included in any candidate code is called a Non-code attribute.
- Foreign code (Foreign Key): If the property (Attribute Group) in relational mode R is not the link code, but it is the code of other relations, then this property (Attribute Group) for relational mode R, it is an external code. For example, the customer's loan contact c-l (c-id, loan-no) and the property c-id is the customer relationship code, so c-id is the external code; the property loan-no is the code in the loan relationship, so loan-no is also an external code.
- Full code (All-Key): All attribute groups of the relational model are candidate codes of the relational model.
For example, in relational mode R (T, C, S), attribute T indicates the instructor, attribute C indicates the course, and attribute S indicates the student. Assume that a teacher can teach multiple courses. A course can be taught by multiple teachers, and students can listen to different courses taught by different teachers. To distinguish each tuples in a relationship, the R code of this relational mode should be the full attribute T, C, and S, that is, All-Key.
3. Relationship nature
A basic link has the following five properties.
- The component must take the atomic value, and each component must be a data item that cannot be further divided.
- The column is homogeneous, and the component in each column must be of the same type of data from the same domain.
- Duplicate attribute names are not allowed.
- The order of the rows and columns is irrelevant.
- The two tuples cannot be exactly the same, which is guaranteed by the master code constraint. However, if you do not define integrity constraints for some databases, two or more rows of the same tuples are allowed.
4. Three types of links
- Basic Relationship (also known as basic table or base table ). Is an actually existing table, which is the logical representation of the actually stored data.
- Query a table. The table corresponding to the query result.
- View charts. Is a table exported from a basic table or other visual charts. Because it is not stored independently in the database, and the database only stores its definition, it is often called a virtual table.