A Brief Introduction to Document-Based NoSQL Databases
Firestore is a document-based NoSQL database, and in order to properly understand how to use it we will need to cover some basic concepts. Our use of the database will be rather simple, so it is not critical that you have a thorough understanding of how a document-based database works, but it will certainly help to understand at least a little.
Before we get into specifically discussing “document” databases, I think it is useful to quickly cover some other types of NoSQL databases (which basically covers anything that is not a typical “relational” style database like MySQL). Some types of NoSQL databases include:
- Key-Value (redis, Amazon DynamoDB, memcached)
- Columnar / BigTable (HBase, Cassandra, Amazon SimpleDB)
- Document (Firestore, CouchDB, MongoDB, Riak)
- Graph (Neo4J, AllegroGraph, InfoGrid)
Two commonly used NoSQL database structures are Key-Value and Document (like the Firestore database we will be using). Key-Value and Document-based databases are both very similar in nature, but there are differences.
A Key-Value database is a simple way to store values indexed by a key
. You
would already be familiar with this concept if you have used the browser’s local
storage to store data. To use the browser’s local storage as an example, you
would set a value on a key like this:
localStorage.setItem('name', 'Josh');
and then you could later retrieve the value by using the key like this:
localStorage.getItem('name');