Databases: Introduction to Data Models
Tags: database, datascience, backend
Published: 2020-11-01 20:21:25

It is no news that data and databases are an important bit of every application and for us to store data in a database, we need some data-structures, hence the database systems we use usually include some complex data structures which we normally do not use. To make the system efficient in terms of data retrieval, and reduce complexity in terms of usability, developers use data abstraction which refers to hiding irrelevant details from the users. To be able to make data abstraction possible, developers make use of data models.

You might be wondering what a data model is, well it is simply a concept or notion for describing data, data relationships, data constraints and data semantics or simply put, a data model is way of defining how the logical structure of a database is presented or modeled. The different types of data models can be classified into the following categories;

### High-level Conceptual Data Models


They present or model data in a way that is similar to how humans perceive data. A typical example of a High-level Conceptual Data Model is the Entity-Relationship(ER) model which is based on the notion of real-world entities(objects) and the relationships among them. A relationship represents a logical association among entities and they are mapped with entities in various ways which could be;

* One to One

* One to Many

* Many to One

* Many to Many

The diagram below represent an ER model:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ywf3f6mkpru99ondmu8t.png)

### Record-based logical Data Models

Record-based logical data models provide concepts users can understand but are still similar to the way data is stored on the computer. Three well-known data models of this type are: hierarchical, network, and relational data models.

#### 1. Hierarchical model

In a hierarchical model, data is organized in a tree-like structure, implying a single parent for each record. This structure obliges that each child record has only one parent, whereas each parent record can have one or more child records. This model is illustrated below:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/v4fp4j5biqll3f40q6se.png)

#### 2. Network model
The network model expands upon the hierarchical model, allowing each record to have multiple parent and child records. It replaces the hierarchical tree with a graph thus allowing more general connections between the records. It was the most popular model before being replaced by the relational model. The network model is shown in the image below:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ltysd2mhg581odqdux7n.png)

#### 3. Relational model
The relational model represents data as relations or tables. For example, a database system may contain multiple tables (relations) which in turn have several attributes (columns) and tuples (rows). It is the most popular data model. The relational data model is shown in the image below:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/17k0qpm2kotl35rg3ovl.png)

### Physical data models
The physical data model represents how data is stored in computer memory, how it is scattered and ordered in the memory, and how it would be retrieved from memory. There are not as many physical data models as logical data models. An example of a physical data model is the Unifying Model. The diagrammatic representation of physical models is shown below:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bym2f1pf13if2fnu5p85.png)

Thank you for reading this post and if you found it helpful please don't hesitate to like and share. Follow me on twitter at [@flaacko_flaacko](https://twitter.com/flaacko_flaacko). Watch out for more posts on database related stuff, until then goodbye👋👋.