Databases are generally divided into hierarchical databases, network databases, and relational databases. Different databases are connected and organized according to different data structures.
1. Data Structure Model
(1) Data Structure
The so-called data structure refers to the organization form of the index data or the relationship between the data. If D is used to represent data and R is used to represent a set of relationships between data objects, DS = (D, R) is called a data structure. For example, Set
There is a telephone number book that records the names and numbers of N people. In order to conveniently find a person's phone number, sort the person's name and number in alphabetical order, and follow the corresponding phone number after the name
Number. In this way, to find a person's phone number (assuming that the first letter of his name is Y), you only need to find the names starting with Y. In this example, the data set D is the name and phone number.
The relationship r between them is arranged in alphabetical order, and its corresponding data structure is DS = (D, R), that is, an array. (2) Data Structure Types
The data structure is divided into the logical structure of the data and the physical structure of the data. The logical structure of data is to observe and analyze data from a logical point of view (that is, the relationship between data and the organization method), without the data storage location.
Off. The physical structure of data refers to the structure where data is stored in the computer, that is, the implementation form of the logical structure of data in the computer. Therefore, the physical structure is also called the storage structure. This section only studies the logical structure of data and
The method that reflects and implements the data connection is called the data model.
Currently, there are three popular data models: hierarchical and mesh models based on graph theory and relational structure models based on relational theory.
2. hierarchical, mesh, and Relational Database Systems
(1) Layered Model
A layered structure model is essentially a directed ordered tree with a root node (in mathematics, a "Tree" is defined as a non-return connected graph ). Example is the organizational structure of a higher education institution. This organization ends
The figure is like a tree. The school department is the root node, and each department, Major, teacher, and student is the branch node. The connection between the root and the branch is called the edge, the ratio of the root and edge is 1: N, that is, the root only
There is one and N branches.
A database system created based on a hierarchical model is called a hierarchical model database system. IMS (Information Manage-mentsystem) is a typical example.
(2) Mesh Structure Model
The relationship between doctors, wards, and patients in a hospital. Each doctor is responsible for treating three patients, and each ward can accommodate one to four patients. If you think of a doctor as a data set, the patient and ward are the other two numbers.
According to the collection, the ratio of doctors, patients, and wards is M: N: P (M doctors, N patients, P ward ). This data structure is a mesh data structure. Its general structure model records the ri
(I =, 8) meets the following conditions:
① There can be more than one node without any parent (such as R1, R2, and R3 ).
② At least one node has more than one parent. In the example of "doctors, patients, and wards", "doctors have multiple nodes (M doctor nodes) without" parent ", the "ward" has P nodes (that is, the ward) and more than one "parent" (that is, the patient ).
Relationship between doctors, wards, and patients
Mesh Structure Model
The database system established according to the mesh data structure is called the mesh database system, which is typically represented by dbtg (Data Base Task Group ). Mathematical methods can be used to convert a mesh data structure into a hierarchical data structure.
(3) relational structure model
Relational Data Structures classify some complex data structures into simple binary relationships (two-dimensional table forms ). For example, a company's employee relationship is a binary relationship. Each column of the table with four rows and six columns is called one.
Fields (attribute). The field name is equivalent to the title (attribute name) in the title bar. each row of the table contains six attributes (employee ID, name, age, gender, position, and salary) is a person
. This table clearly shows the basic information of the employees of the organization.