Chapter 8. JSON and NoSQL
In Chapter 7, we zoomed the lens to the client side in the client–server relationship of the Web. In this chapter, we are going to zoom that lens to the server side to a type of database that not only uses JSON documents to store data, but interfaces with the outside world through a web API.
We live in the “information age” where vast amounts of data and knowledge are easily accessible. We can query for information on a specific subject like “naked mole-rat” on sites like Wikipedia. The information on “naked mole-rat” has to be stored somewhere, and that somewhere is ultimately a database.
If you’ve worked with a database in the past and are familiar with SQL, you were most likely working with a relational database. Relational databases are structured with tables, columns, and rows. Each table is representative of something, such as an account. The table representing an account may have a relationship with a table that represents addresses for accounts. A key in each table, such as a column that contains an account identifier, forms a relationship between the two tables.
To create, manipulate, and query these relational databases, we use Structured Query Language (SQL). With SQL, I can query for columns and rows from one or more tables of the database (Example 8-1).
Example 8-1. A simple SQL query that will return columns and rows for AccountID, FirstName, and LastName from the Account table
SELECT accountId, firstName, lastName FROM Account
With the ...