Database Per Service Pattern 00:00:01 Three departments scribble in the same ledger The order, inventory and customer teams all reach into the same tables. That makes joins convenient, but a seemingly private column rename can break a caller on the other side of the shop. All services read and write one database. Joins and transactions just work. The user team renames a column in its own table. The order and stock services read that column. Nobody told them. Orders need ten times the reads. The whole database must grow, and a heavy report slows checkout. Start by tracing which team reads and writes each fact. Service ownership is an enforceable contract for change. Sharing a physical database server can still allow logical ownership through permissions and schemas. 00:00:48 Each department signs its own records Draw a line around orders, users and stock. Give each fact an owner, and require other departments to use that owner's API or published data contract. Independent storage technology is then possible where useful. Orders, users and stock each get exactly one owner. The order service tries to read user data. The database says no. The user team renames its column. Nobody else notices. Orders get read replicas. Stock may move to another kind of store. The boundary also removes some easy joins and cross-table transactions. Price the new communication and consistency requirements before moving data between physical stores. 00:01:33 An order can exist while its lamp is still unreserved The order owner records a pending order and outgoing event in one transaction. Stock independently decides whether a reservation is possible. A successful request to orders never guarantees a physical lamp already exists. The order service writes the order and an outbox row in one local transaction. The stock service reads the event when it is ready. The order service does not wait. One statement checks and reserves. The event id is remembered in the same transaction. The order becomes reserved. Between the first and this step the two databases told different stories. Give the reservation and rejection events stable identities. The customer-facing state must expose the interval between acceptance and resolution, including a useful outcome if no lamp remains. 00:02:24 Build the receipt from three departments To display one order, a composer retrieves its reference identifiers and asks other services for the required names and products. Those reads can have different response times or fail independently. The client wants order 7 with the customer and the products. There is no join across databases. The order service answers with ids: user 3, products 5 and 9. The composer joins in memory. If users is down the page shows unknown user instead of an error. That must be decided in advance. If a current name is optional, design a labeled fallback in advance. If the displayed name must match the original invoice, preserve the historical value at purchase time instead. 00:03:11 A projection lets order history survive a user outage An order page reads a local projection of customer names updated by events. Version checks stop a delayed older rename from overwriting a newer one. The query remains possible while the owner is briefly unavailable. The user service writes to its own data. The user owner publishes a rename event carrying the new value and the record version. The order service saves the new name if the version is newer. The order list shows names even when users is down. The name may be some seconds old. The local projection is a copy with an age and rebuild plan. Authority stays with the source. Decide which consumers require current truth and which can safely read the independent view.