A non-relational database does not use tables, rows, columns, primary keys, relationships, or schemas. Instead, a
NoSQLdatabase stores data using various storage models, depending on the type of data stored.Due to the lack of a defined structure for the database,
NoSQLdatabases are very scalable and flexible. When dealing with datasets that are not very well defined and structured, aNoSQLdatabase would be the best choice for storing our data.There are 4 common storage models for
NoSQLdatabases:- Key-Value
- Document-Based
- Wide-Column
- Graph
Each of the above models has a different way of storing data. For example, the
Key-Valuemodel usually stores data inJSONorXML, and has a key for each pair, storing all of its data as its value:
graph LR
subgraph Posts
box1[id
date
content]
box2[id
date
content]
box3[id
date
content]
end
box1 --> Key1[Key]
box1 --> Value1[Value]
box2 --> Key2[Key]
box2 --> Value2[Value]
box3 --> Key3[Key]
box3 --> Value3[Value]
- The above example can be represented using
JSONas follows:
{
"100001": {
"date": "01-01-2021",
"content": "Welcome to this web application."
},
"100002": {
"date": "02-01-2021",
"content": "This is the first post on this web app."
},
"100003": {
"date": "02-01-2021",
"content": "Reminder: Tomorrow is the ..."
}
}
It looks similar to a dictionary/map/key-value pair in languages like
PythonorPHP‘i.e.{'key':'value'}’, where thekeyis usually a string, thevaluecan be a string, dictionary, or any class object.The
Document-Basedmodel stores data in complexJSONobjects and each object has certain meta-data while storing the rest of the data similarly to theKey-Valuemodel.Some of the most common
NoSQLdatabases include:
| Type | Description |
|---|---|
| MongoDB | The most common NoSQL database. It is free and open-source, uses the Document-Based model, and stores data in JSON objects |
| ElasticSearch | Another free and open-source NoSQL database. It is optimized for storing and analyzing huge datasets. As its name suggests, searching for data within this database is very fast and efficient |
| Apache Cassandra | Also free and open-source. It is very scalable and is optimized for gracefully handling faulty values |
- Other common
NoSQLdatabases include:Redis,Neo4j,CouchDB, andAmazon DynamoDB.


