Relational versus document catalog
Catalog: relational tables vs one document
bounded data embeds, unbounded data references
A - Relational: entities + keys
brands
id PK
name UNIQUE
logo_url, logo_v
products
id PK
brand_id FK
name, price
N..1
prod_categories
product_id FK
category_id FK
many-to-many
reviews
product_id FK
UNIQUE(prod, user)
idx (prod, id)
brand change: 1 atomic row
reviews: keyset on (prod, id)
B - Document: one nested tree
product doc (JSON)
brand_thumb: embedded (tiny)
categories: [..] embedded
reviews: NOT here - see below
one read, O(n) rewrite risk
reviews collection
reference + second query
keyset cursor (stars, id)
million-review array breaks the doc
bounded + tiny: embed - unbounded: reference
pagination by keyset, uniqueness by constraint, brand rename = 1 row