Key-value and document databases
We are now going to look at key-value and document databases. These are both NoSQL databases, but they have different use cases:
- Key-value databases have a unique key (such as a primary key) and then values stored next to the key. Key-value databases are useful when you have large amounts of data that needs to be queried quickly and when you have data that doesn't have clearly defined columns or data structures. Key-value databases let you store almost any data in the value component without the need to strictly define it, as you would with an RDBMS, where you would specify a string or integer, for example.
- Document databases store data in formats such as JavaScript Object Notation (JSON). JSON is used widely in programming languages, so having a database that uses the same format makes it an efficient choice for many developers. We will discuss JSON in more detail later.
First, let's look at key-value databases more closely...