{"id":1096,"url":"https://forum.supero.dev/t/coming-from-firestore-how-do-i-model-subcollections-1096","title":"Coming from Firestore: how do I model subcollections?","type":"question","status":"solved","category":{"slug":"data","name":"Data, Schemas & Queries"},"tags":["migration","data-model"],"author":{"handle":"supero-support","name":"Supero Support","team":true},"created":"2026-12-04T02:40:27.705Z","updated":"2026-12-04T02:40:27.705Z","upvotes":0,"error_text":null,"environment":{"client":null,"sdk_version":null,"deploy_target":null},"body_markdown":"In Firestore we had `customers/{id}/orders/{id}`. Is there an equivalent, or should each order just store a `customer_id` string?","answers":[{"id":"5e4cbfc9-403b-4bad-8621-af66ccd8c8ec","url":"https://forum.supero.dev/t/coming-from-firestore-how-do-i-model-subcollections-1096#post-5e4cbfc9-403b-4bad-8621-af66ccd8c8ec","author":{"handle":"supero-platform","name":"Supero Platform team","team":true},"accepted":true,"official":false,"outdated":false,"sdk_version":null,"upvotes":0,"created":"2026-12-04T02:40:27.705Z","updated":"2026-12-04T02:40:27.705Z","body_markdown":"The closest equivalent is a parent relationship. Set `parent_type` on the child schema to the container schema's bare name (`customer`), then pass the parent when you create:\n\n```python\ncustomer = org.crud.get(\"customer\", customer_uuid)\norder = org.crud.create(\"order\", parent=customer, name=\"order-001\", total=199.99)\n```\n\nThe SDK fills in `fq_name` and `parent_uuid`. Over REST, send `parent_uuid` and `parent_type` in the create body. To list one customer's orders, call GET list with `?parent_id=<customer uuid>`, or put `parent_id` in a `/list-bulk` body when you also need filters.\n\nWhen the link isn't ownership, such as an order pointing at a coupon, use a reference instead: declare it in the schema's `references[]`, set it with `ref-update`, and read it with `/refs` and `/back-refs`.\n\nSettle this before you import. `parent_uuid` can't be changed after create, and a schema update that changes `parent_type` while records exist is blocked with a 422.","comments":[]}],"licence":"CC BY-SA 4.0 (code: MIT-0)"}