Postgres and MongoDB both solve the challenge of data storage.
Key differences are tabulated below:
PostgreSQL |
MongoDB |
---|---|
Theoretical basis: |
|
Relational model |
Document collection |
Structure: |
|
|
No declarations are required. Collections accept the insertion of any document. |
Example record: |
|
( |
|
Record identification: |
|
Primary key |
Object ID |
Query and data manipulation language: |
|
SQL |
JavaScript |
Example query: |
|
|
|
Storing related information: |
|
Additional relations store related information. For example, the following definition creates an additional table for permitted brands when shopping:
Then associated records can be added to the new table: |
Related information is embedded directly into the inserted documents through complex structure. For example:
|
Further information about PostgreSQL and MongoDB can be found on their websites.