Chapter 33 — Quiz

12 questions. Answers at the bottom.


Multiple choice

Q1. MongoDB is a ____ database. - A) key-value - B) document - C) graph - D) relational

Q2. Redis is best known for: - A) Deep graph traversal - B) Fast key-value access (caching, sessions) - C) Joins - D) Full-text search

Q3. Cassandra (column-family) is optimized for: - A) Ad-hoc queries - B) Massive write throughput across many nodes - C) Deep relationship traversal - D) Strong consistency above all

Q4. A graph database (Neo4j) shines when you: - A) Look up values by key - B) Traverse relationships deeply (many hops) - C) Need maximum write throughput - D) Store flexible documents

Q5. NoSQL systems often trade strong consistency for: - A) Slower writes - B) Availability/partition tolerance (eventual consistency) - C) More joins - D) Stricter schemas

Q6. For flexible/variable document data, PostgreSQL offers: - A) Nothing - B) JSONB (indexable documents inside the relational DB) - C) Only text columns - D) A separate server

Q7. Choosing MongoDB for deeply relational data typically sacrifices: - A) Speed only - B) Joins, transactions, and enforced integrity - C) Storage - D) Nothing

Q8. "Schemaless" really means: - A) No structure at all - B) The schema lives in the application, unenforced - C) Faster queries - D) Automatic indexing

Q9. Redis is usually deployed: - A) Instead of a relational database - B) Alongside one (e.g., as a cache in front of PostgreSQL) - C) Only for graphs - D) As a warehouse

Q10. The factors for choosing a database are: - A) Popularity and hype - B) Data model, consistency needs, query patterns, scale - C) Vendor marketing - D) Programming language


True/False

Q11. PostgreSQL's JSONB can cover many "we need a document database" needs without a separate system. (True / False)

Q12. Eventual consistency is fine for a bank account balance. (True / False)


Short answer

Q13. A team says "our data comes from an API as JSON, so we should use MongoDB." Give a balanced response.

---

Answer key

Q1 — B. Document.

Q2 — B. Fast key-value access (caching/sessions).

Q3 — B. Massive write throughput, horizontal scale.

Q4 — B. Deep, multi-hop relationship traversal.

Q5 — B. Availability/partition tolerance → eventual consistency (CAP, Ch. 35).

Q6 — B. JSONB — indexable documents inside the relational DB.

Q7 — B. Joins, transactions, and integrity (the Lumen mistake).

Q8 — B. The schema moves to the app, unenforced.

Q9 — B. Alongside (commonly a cache in front of a relational DB).

Q10 — B. Data model, consistency, query patterns, scale (Ch. 37).

Q11 — True. JSONB gives document flexibility with transactions/joins retained.

Q12 — False. Balances need strong consistency; eventual consistency could show wrong amounts.

Q13. JSON-from-an-API doesn't require a document database — PostgreSQL's jsonb stores and indexes JSON natively (Ch. 16), so you get document flexibility and keep transactions, joins, and integrity for the relational parts of your data. Adding MongoDB means another system to deploy, secure, back up, and keep consistent. Use jsonb first; reach for MongoDB only if you have a concrete need it meets that PostgreSQL genuinely can't (e.g., effortless horizontal scaling for a workload that's purely document-shaped with no relational core).

Scoring: 10–12 you've got the judgment; 7–9 review the families and theme #4; below 7, redo Exercises B.