Current location - Training Enrollment Network - Mathematics courses - Third-level database Chapter 5 exam points
Third-level database Chapter 5 exam points
chapter five

I. Overview of Relational Database System (I) Relational Database System

Relational database system is a database system that supports relational data model. Relational databases use mathematical methods to process data in the database. CODASYL's Information Algebra published in 1962 first proposed this method for data processing, and then David Child realized the set theory data structure on the 7090 computer in 1968, but the relational model was strictly put forward by the E.F.Codd system of IBM. From 65438 to 0970, E.F.Codd published many papers one after another, which laid the theoretical foundation of relational database.

(B) Relational data model

The relational data model consists of three elements: relational data structure, relational operation set and relational integrity constraint.

(1) relational data structure The data structure of the relational model is single. In the relational model, entities in the real world and various relationships between entities are represented by relationships. In the eyes of users, the logical structure of data in the relational model is a two-dimensional table.

(2) The common relational operations in relational operation set relational model are: selection, projection, join, division, union, intersection and difference. , and query, insert and delete. The expressive ability of the query is the most important part. The characteristic of relational operation is set operation, that is, the object and result of operation are sets. This mode of operation is also called one-time setup mode. Accordingly, the data operation mode of non-relational data model is one-time recording. The relational model gives the ability and characteristics of relational operation, which is realized by relational language. The characteristic of relational language (its advantage) is highly non-procedural. The so-called non-procedural means: ① The user does not need to ask the DBA to establish a special access path for him, and the choice of access path is completed by the optimization mechanism of DBMS. (2) users do not have to resort to loops, and do the repeated operations of data recursively.

(3) Relational Integrity Constraints The data integrity of a database refers to the correctness and compatibility of data in the database, which is a semantic concept, including two aspects: ① Compatibility and correctness with data required by applications in the real world. ② Compatibility and correctness between data in the database.

Second, the data structure of the relational model (I) the data structure and basic terms of the relational model

In the relational data model, the data structure uses a single two-dimensional table structure to represent the relationship between entities.

(1) relationship: a relationship corresponds to a two-dimensional table, and the two-dimensional table is the relationship name.

(2) Attributes and value fields: The columns (fields) in a two-dimensional table are called attributes. The number of attributes is called the number of relationships, and the values of columns are called attribute values. The range of attribute values is called range.

(3) Relationship mode: the row definition (record type) in the two-dimensional table, that is, the description of the relationship is called the relationship mode, which is generally expressed as: relationship name (attribute 1, attribute 2, …, attribute n).

(4) Tuple: A row (record value) in a two-dimensional table is called a tuple. A set of relational patterns and tuples are called relationships.

(5) Component: attribute values in tuples.

(6) candidate key or candidate key: If there are tuples in a relationship that can be used to uniquely identify the relationship, these attributes (or attribute combinations) are called candidate key or candidate key of the relationship.

(7) Primary key or primary key: among several candidate codes of a relationship, a tuple is designated to uniquely identify the relationship, and this designated candidate code is called the primary key or primary key of the relationship.

(8) Major attributes and non-major attributes: the attributes contained in any candidate code in the relationship are called major attributes or code attributes, and the attributes not contained in any candidate code are called non-major attributes or non-code attributes.

(9) foreign key or foreign key: When an attribute (or attribute group) in a relationship is the main code of another relationship, it is said that the attribute (or attribute group) is the foreign code of the relationship, although it is not the main code of the relationship or only a part of the main code.

(10) Reference relationship and reference relationship: Reference relationship is also called subordinate relationship, and referenced relationship is also called master relationship, which refers to two relationships associated with foreign codes. The relationship with foreign code as the main code is called referenced relationship; The relationship between foreign codes is called reference relationship or target relationship. It can be seen that the referenced relationship and the referenced relationship are linked by foreign codes, and this relationship is usually1:n. For the concept of database, we should distinguish between types and values. The type of database refers to the description of the structure and attributes of the database, and the type of relational database refers to the description of the structure of the relational database, which includes several relational sets. The value of database is the concrete assignment of type, and the value of relational database is a set of relationships corresponding to these relational patterns at a certain moment. Therefore, the type of database is also called the intention of database, and the value of database is also called the extensiveness of database. The type of database is stable, but the value of the database is constantly changing with time, because the data in the database is constantly changing.

(b) Formal definition of relationship and definition of relationship in relational database

Formal definition of 1. relation

Defining a relationship from a mathematical point of view is called the formal definition of relationship. There are two definitions as follows:

(1) Define a relationship from the viewpoint of set theory: a relationship is a set of tuples with k elements, that is, there are several tuples in the relationship, and each tuple has k attribute values (consider the relationship as a set, and the elements in the set are tuples).

(2) Define the relationship with the concept of value domain: the relationship is a subset of the cartesian product of the attribute value domain. Let the attribute of a relationship be A 1, …, An, and its corresponding range be D 1 …, D n (possibly the same), and define each subset of D 1, …, D n D = {(D 65438)D as a relationship. Here, the element (d, …, d n) of d is an n-tuple, and each value di in the element is called a component of the tuple. If Di(i= 1, 2…, n) is a finite set and its radix numder is mi(i= 1, 2, …, n), then the radix m of D 1 ×D 2 ×…D n is m =-N I =

2. Definition of relationship in relational database

(1) Every attribute is indecomposable. This is the most basic restriction of relational database on the relationship, which requires that all components of the relationship must be inseparable data items, that is, there is no table in the table.

(2) The number of data types and attributes in each relational schema is fixed, and each attribute must be named. Attribute names must be different in the same relational schema.

(3) Each relationship has only one record type, that is, a relationship mode.

(4) The order of tuples in a relationship (that is, the order of rows) is irrelevant.

(5) In the relationship, the order of attributes can be exchanged at will, and it should be exchanged with the attribute names, otherwise the order is very important.

(6) The same tuple is not allowed in the same relationship.