wtf( )unctionsystem design, drawn
← all problemsDatabasesHard

A document model borrowed from the relational schema

A team moved to a document store and kept their normalised design: users in one collection, orders in another, line items in a third. Rendering one order page now makes four round trips and joins them in application code.

The document store has no joins. The design assumed one and moved the work into the application, where it's slower and no longer transactional.

Shape the document around the read that actually happens.
Components — tap one, then tap a slot on the diagram
!Rendering one order page takes four round trips and a join written in application code.

Boundaries, outermost first: Document store: orders, line_items Outside every boundary: Order page (one screen), an empty slot for the what one read returns Connections: Order page calls what one read returns — one read (step 1) what one read returns calls orders (step 2) what one read returns controls line_items — no longer needed

orders
line_items
Order pageone screen