Difference between Relational model and Document Model
Last Updated :
10 Sep, 2024
The relational model organizes data into tables with rows and columns, ideal for structured data. On the other hand, the document model stores data in hierarchical documents, which offers more flexibility for managing unstructured or semi-structured data. Both models serve different purposes in database management.
What is the Relational Model?
The relational model is a model for the management of the database. It is called so because the data is stored in the form of relations i.e., in the form of tables. Every row consists of related data. These rows in the table depict a real-world entity. To work with Python and the Relational data model we need a prerequisite knowledge of - SQL and Pandas. Panda is a library of Python.
Advantages
- It uses a predefined schema, which ensures data integrity.
- Supports complex joins for querying related data.
- Follows ACID properties, which ensures reliable transactions.
Disadvantages
- It is Less suitable for hierarchical or unstructured data.
- It is slower due to the need for complex joins and rigid schema.
What is the Document Model?
In the document model, the data is stored in the form of documents. The documents consist of the records which describe the actual data of the document. A nested document can be used to provide information about subcategories of the data. The document can also be used to represent real-world objects.
Advantages
- It Offers a dynamic schema, allowing for flexible data storage.
- Generally faster for read and write operations due to its document-based structure.
- Supports easy replication and horizontal scalability.
Disadvantages
- Lacks support for complex joins.
- Does not follow strictly to ACID properties, it follows the CAP theorem.
Difference Between Relational and Document Model
Relational Model | Document Model |
---|
It is row-based. | It is document-based. |
Not suitable for hierarchical data storage. | Generally used for hierarchical data storage. |
It consists of a predefined schema. | It consists a dynamic schema. |
ACID properties are followed by this model. (Atomicity, Consistency, Isolation, and Durability). | CAP theorem are followed by this model. (Consistency, Availability, and Partition tolerance). |
It is slower. | It is faster than Relational Model. |
Supports complex joins. | Does Not support for complex joins. |
It is column-based. | It is field-based. |
They are vertically scalable | They are horizontally scalable |
Fast replication support is not provided. | They provide easy replication support |
It is more used now-a-days to store data in database. | It is comparatively less used. |
To add attributes in a relational model, database schema needs to be modified for including additional columns and their data types. | In a document-based database, you need to add additional key-value pairs in the document for representing new fields. |
Conclusion
The relational model is in environments where data integrity and complex querying are most important, while the document model is for applications which require flexible, hierarchical data storage and rapid scaling.
Similar Reads
Difference between E-R Model and Relational Model in DBMS In database management systems (DBMS), two key methods are the Relational model and the Entity-Relationship (E-R) model. Each has a specific function in the development and operation of databases. While the Relational model provides the practical structure for organizing and managing data in relatio
4 min read
Difference between Network and Relational data model Data models specify the organization, archiving, and manipulation of data in database management systems (DBMSs). The Network Data Model and the Relational Data Model are two popular forms of data models. Each of these models has distinct characteristics, benefits, and uses for organizing and managi
5 min read
Difference between Relational database and NoSQL 1. Relational Database : RDBMS stands for Relational Database Management Systems. It is most popular database. In it, data is store in the form of row that is in the form of tuple. It contain numbers of table and data can be easily accessed because data is store in the table. This Model was proposed
2 min read
Difference Between Hierarchical, Network and Relational Data Model In order to define the connections, organization, and structure of data in a database management system (DBMS), data models are essential. The effectiveness of a database's ability to store, retrieve, and alter data is greatly influenced by the choice of data model. The Hierarchical, Network, and Re
6 min read
Difference between MongoDB and Amazon DocumentDB 1. MongoDB : MongoDB is an open-source document-oriented database used for high volume data storage. It falls under classification of NoSQL database. NoSQL tool means that it doesnât utilize usual rows and columns. MongoDB uses BSON (document storage format) which is binary style of JSON documents.
2 min read