Lucas T.
Lucas T.

Reputation: 406

Are documents in NoSQL databases what a table is for a SQL database?

I'm new to the whole backend scene, and I'm trying to find what kind of database is the best for me, and I need to get what documents are. Are documents in NoSQL databases what a table is for a SQL database?

Upvotes: 5

Views: 5667

Answers (2)

Alberto Solano
Alberto Solano

Reputation: 8227

Only specific NoSQL database engines store information using documents and they're named NoSQL document oriented database engines. One of the most famous NoSQL document oriented database engines is MongoDB. They're also other NoSQL engines that store data in a different way, like Cassandra using a key-value structure.

Are documents in NoSQL databases what a table is for a SQL database?

Considering the NoSQL document oriented databases, the documents are much similar to rows of a table of a SQL database. A table of SQL database, instead, is similar to a collection of documents. There are anyway a lot of differences between them. For example:

  • In a SQL database, you have to specify a schema for your table and it's not very easy and recommended to change it, because it ensures the consistency of your data and lets you perform multiple checks (using JOINS, for example) on your data considering different tables.

  • In a NoSQL database, there's no schema to specify for a collection. This makes easy to store a lot of information without any problem. But what if you have to perform a JOIN to check the data stored in different collections? You can't, because there's no schema defined and no relationships to define between the collections.

I'm trying to find what kind of database is the best for me

It depends on what you want to do with each DBMS. If you want to store a lot of information without caring about joins, relationships between tables, atomicity of operations and so on, use a NoSQL database engine. Otherwise, use a SQL database engine.

Upvotes: 5

Philipp
Philipp

Reputation: 69703

Not every NoSQL database even has documents. It's just a small subset of NoSQL databases: The document-oriented databases. In these databases, multiple documents are in one collection. Documents and collection are roughly equivalent to row and table in a relational database.

Upvotes: 1

Related Questions