Three models of databases

Preface

The data model is the core of the database system. This article briefly introduces the three main database models.


1. Format the model

Formatting model is a collective term for hierarchical model and mesh model

1. Hierarchical model

① The concept of hierarchical data model

The hierarchical model uses the attribute structure to represent various entities and the connections between entities

② Data structure of the hierarchical model

Features:

  1. The parent of the node is unique;
  2. Can only directly handle one-to-many entity connections;
  3. Each record type can define a sort segment, also known as a code field;
  4. Any record value can only show its full meaning when viewed by its path;
  5. No child record value can exist independently of the parent record value.

③Data manipulation of hierarchical model

  • Inquire
  • insert
  • delete
  • Update

④Integrity constraints of the hierarchical model

  1. If there is no corresponding parent node value, the child node cannot be inserted;
  2. If the parent node is deleted, the corresponding child node value is also deleted;
  3. During the update operation, all corresponding records should be updated to ensure data consistency.

⑤The advantages and disadvantages of the hierarchical model

  • Advantages
    The data structure of the hierarchical model is relatively simple and clear; the
    query efficiency is high, and the performance is better than the relational model, not lower than the mesh model; the
    hierarchical data model provides good integrity support.

  • Disadvantages
    Many-to-many connections between nodes are unnatural; there are many
    restrictions on insert and delete operations, and application programming is more complicated;
    query child nodes must pass through parent nodes;
    level commands tend to be programmed;

2. Mesh model

①The concept of mesh model

The mesh database system adopts the mesh model as the data organization method. The
typical representative is the DBTG system:
■Also known as the CODASYL system
■A system scheme proposed by DBTG in the 1970s. The
actual system
■Cullinet Software's IDMS
■Univac's DMS1100
■IDS/2 of Honeywell
■IMAGE of HP

②Data structure of the mesh model

A collection of basic hierarchical connections that satisfy the following two conditions:

  1. Allow more than one node without parents;
  2. A node can have more than one parent.

Representation method (same as hierarchical data model)

  • Entity type: Use record type to describe
    each node-a record type (entity)
  • Attributes: describe with fields.
    Each record type can contain as many as thousands of fields
  • Connection: Use the connection between nodes to represent the one-to-many parent-child connection between record types (entities)

③Manipulation and integrity constraints of the mesh model

The network database system (such as DBTG)
imposes some restrictions on data manipulation and provides certain integrity constraints.
Code: a collection of data items that uniquely identify the record.
There is a pair of parent records and child records in a connection. Multi-contact
support for certain constraints between parent records and child records

④The advantages and disadvantages of the mesh model

  • Advantages
    a. It can describe the real world more directly, such as a node can have multiple parents
    b. It has good geography and high access efficiency
  • Disadvantages
    a. The structure is more complex, and with the expansion of the application environment, the database becomes more and more complex, which is not conducive to the end users to master
    b. DDL, DML language is complex, users are not easy to use
    c. The connection between records is through storage Take the path to achieve, the user must understand the details of the system structure

3. The difference between mesh model and hierarchical model

■The mesh model allows multiple nodes without parent nodes
■The mesh model allows nodes to have multiple parent nodes
■The mesh model allows multiple connections between two nodes (composite connections)
■The mesh model can Describe the real world more directly. The
hierarchical model is actually a special case of the mesh model.

Second, the relationship model

①The concept of relational model

The relational database system adopts the relational model as the data organization method.
In 1970, EF Codd, a researcher in the SanJose Research Office of IBM, proposed the relational model of the database system for the first time.
Almost all database management systems newly launched by computer manufacturers support the relational model.

②Data structure of relational model

From the user's point of view, the logical structure of data in the relational model is a two-dimensional table composed of rows and columns.

  • Relation
    ●A relationship corresponds to a table in general

  • Tuple
    A row in the table is a tuple

  • Attribute
    ●A column in the table is an attribute. Give each attribute a name, which is the attribute name

  • Main code (Key)
    ●Also called code key. A certain attribute group in the table, it can uniquely determine a tuple

  • Domain (Domain)
    ● is a set of values ​​with the same data type. The value range of the attribute comes from a certain domain.

  • Component
    ● An attribute value in the tuple.

  • Relationship Mode ●Description of the relationship Relationship name (attribute 1, attribute 2, .attribute n) Student (student number, name, age, gender, department name, grade)

The relationship must be standardized and meet certain constraints. The
most basic constraints: Each component of the relationship must be an inseparable data item, and there are no tables in the table.

An example of a salary table (there is a table in the table)

③ Manipulation and integrity constraints of relational models

  • Data operation is a set operation, the operation object and the operation result are both related
    ■Query
    ■Insert
    ■Delete
    ■Update
  • The access path is concealed to the user, the user only needs to point out "what's the matter", without specifying "how to do it"
  • Relational integrity constraints
    ■ entity integrity
    ■ referential integrity
    ■ user-defined integrity

④ The advantages and disadvantages of relational databases

  • Advantages
    1. Based on strict mathematical concepts
    2. Single concept
    ● Entities and all kinds of connections are represented by relations
    ● The results of data retrieval are also relations
    3. The access path of the relational model is transparent to users
    ● Has higher Data independence, better security and confidentiality
    ●Simplifies the work of programmers and the work of database development and establishment
  • Disadvantages
    1. The access path is transparent to the user, and the query efficiency is often not as good as the formatted data model
    . 2. In order to improve performance, the user's query request must be optimized, which increases the difficulty of developing a database management system

to sum up

Current research work in the database field is based on relational methods, so when you learn about databases, you should focus on relational databases.

Guess you like

Origin blog.csdn.net/qq_42392049/article/details/112670533