Document Databases
In this chapter, we run the shop API for many merchants as Shopend, and we design a document database for its products, carts, and orders.
After reading this chapter, you should be able to:
- Define multi-tenancy and explain how it affects a request, authorization, and shopper accounts
- Explain why merchant-defined attributes do not fit a column for each attribute
- Define document, collection, and document database, and read a MongoDB lookup
- Decide what to embed in a document and what to reference
- Change an embedded item with an update operator and explain why this avoids a lost update
- Explain why our code must check references and handle documents written under an older design
- Distinguish a snapshot from a copy that must stay in sync with its source
- Explain why a list that keeps growing should not be embedded
- Explain why placing an order needs a conditional update and a transaction across documents
- Add attributes to a GraphQL schema without breaking existing queries
- Compare a document design with an attribute table and a JSON column
Sections
- Shopend
- Multi-tenancy
- Product Attributes
- Attributes as Columns
- A Product as a Document
- Designing the Product Document
- What Goes in a Document
- Connecting Carts to Products
- What an Order Must Remember
- Lists That Keep Growing
- Placing an Order Together
- Attributes in the GraphQL Schema
- Relational or Document