5 concepts · 10 practice questions
Key-value stores look up a value by key. Document stores keep nested records, such as an order with its line items, readable in one fetch. Wide-column stores partition rows by key and sort them within a partition, which suits huge write volumes. Graph databases follow relationships many hops deep. Most of them have weak or no joins, so you design the schema around the queries you will run and often store the same data in more than one shape. A flexible schema still has a schema: it just lives in your code.
# Document store: one read returns the order and its line items
order = {
"_id": "o_17",
"customer": {"id": "c_42", "name": "Ada"},
"items": [{"sku": "BK-1", "qty": 2, "price_cents": 1500}],
"status": "paid",
}
db.orders.insert_one(order)
db.orders.find_one({"_id": "o_17"})
# Wide-column: partition by user, sort by time; one partition per query
# PRIMARY KEY ((user_id), sent_at)
Sign in to read the rest and take the 10-question test.
Sign in to continue