Six common data models that programmers should know


The data model provides the basis for data storage, retrieval and operation in a database management system (DBMS), and affects the structure and access of data.

The figure below shows the six major data models.

1. Flat model

The flat data model is one of the simplest database models. It organizes data into a table, where each row represents a record and each column represents an attribute. This model resembles an Excel spreadsheet and is easy to understand and implement. However, it lacks the ability to effectively handle complex relationships between data entities.

2. Hierarchical model

The hierarchical data model organizes data into a tree structure, where each record has only one parent record but can have multiple child records. This model works well for situations where there is a clear "parent-child" relationship between data entities. However, it struggles when dealing with many-to-many relationships.

3. Relational model

The relational model was proposed by EF Codd in 1970. It represents data as a table (relationship) and consists of rows (tuples) and columns (attributes). It supports data integrity and avoids redundancy through the use of keys and normalization. The advantage of the relational model is its flexibility and simplicity of the query language SQL (Structured Query Language), which makes it the most widely used data model in traditional database systems. It can efficiently handle many-to-many relationships and support complex queries and transactions.

4. Star model

Star schema is a specialized data model used in OLAP (Online Analytical Processing) applications in data warehouses. It is characterized by a central fact table containing measurable quantitative data, surrounded by dimension tables containing descriptive attributes related to the fact data. This model is optimized for query performance in analytical applications, providing simple and fast data retrieval by minimizing the number of connections required for queries.

5. Snowflake model

Snowflake schema is a variation of star schema in which dimension tables are normalized into multiple related tables, thereby reducing redundancy and increasing data integrity. This creates a snowflake-like structure. Although the snowflake model results in more complex queries due to the increased number of joins, it has advantages in storage efficiency and is also beneficial when the dimension tables are large or frequently updated.

6. Network model

The network data model allows each record to have multiple parent nodes and child nodes, forming a graph structure that can represent complex relationships between data entities. This model overcomes some of the limitations of the hierarchical model by efficiently handling many-to-many relationships. However, its design and querying can be complex, and it has been replaced by the relational model in most applications, although it is still used in some professional fields.

Editor in charge: Zhao NingningSource: ByteByteGo