SQL vs. NoSQL Comparison 00:00:01 The same customer in two representations A shop needs both an order detail page and a customer-wide report. Represent the same data as related tables and as a nested document. Then run both questions against each representation. The user is one row in users. The orders are two rows that hold the user's id. The same facts in one record. The user's id is no longer repeated in each order. Alice with the orders. Tables: an indexed join, three rows. Document: one read. Who bought a pen? With an index on product, the table answers. The document store needs an index inside the array, or reads every document. The design that reads one complete order most conveniently can make cross-order questions more expensive. Compare the workloads with realistic cardinalities and indexes before choosing. 00:00:56 Add a field while old clients are alive A new version adds an optional field. In a relational design it may require a schema migration. In a document design records of multiple shapes can coexist. Neither approach removes the compatibility work. Two orders without notes. A nullable column is added. Every row has it, empty for now, and every program can see it. Each reader of documents must cope with absent notes, for ever. SQL can refuse notes that are too long. A document store needs a validation rule or code. Write down how old readers handle a missing field, how mixed-version writes behave, and when a backfill or stricter validation can safely finish. 00:01:37 Choose against a short list of promises The shop needs to preserve inventory and payments across related records. It may also want a fast flexible catalog page. Separate those invariants from the convenience of rendering a screen. Orders, sessions, catalogue and feed. No store yet. Only orders have rules across records. One million orders a day: 10 a second, 30 at peak, 120 rows. The feed is 600,000 a second. Only now the stores. Sessions at this rate would also fit SQL; their lifetime and shape favour key-value. Use the simplest authoritative model that satisfies the critical promises with the team's operational skills. Add a read projection only when its measured benefit pays for managing another copy. 00:02:24 A second store creates a synchronization problem A naive request updates the primary database and a second store independently. A crash between the calls leaves a partial result even if both products are individually reliable. The app writes the new price, 12, to the database first. The app dies. Search still says 10, and nothing will ever fix it. With a change stream the app writes only the database. The change is delivered. If search is down, the stream waits and continues from its position. Commit one authoritative change with durable evidence for asynchronous propagation. Make consumers idempotent, track projection lag and define how the customer reads immediately after a write. 00:03:04 Migrate a live shop without silently dropping edits Take an initial snapshot, then capture changes after the snapshot's logical position. Copying a large dataset without that boundary can miss writes that arrived while the copy was running. Copy all records as of one position in the log. The app notices nothing. Apply the changes made since. Versions stop a late change from replacing a newer one. One percent, then ten, then all. Writes still go to the current store. Once, briefly paused. The new store is the truth, and changes flow back for a while. Compare old and new reads, rehearse rollback, and switch ownership in a controlled sequence. A successful benchmark cannot replace a plan for serving real people during the migration.