Document Schema Design
Design a small subsystem that relies on Document Schema Design. Outline components, data flow, failure modes, and metrics.
Answers use simple, clear English.
Audio N/AQuick interview answer
Use Document Schema Design as the core idea. Example shape: Order embeds line items array; Product referenced by id when catalog shared across orders..
Detailed answer
Use Document Schema Design as the core idea. Example shape: Order embeds line items array; Product referenced by id when catalog shared across orders.. Watch for: Unbounded arrays hit 16MB doc limit; duplicate data needs sync strategy.. Measure success via latency/error/saturation. Core: Embed when data accessed together and bounded size; reference when unbounded growth or shared entities. Balance read patterns vs write amplification. Real-time example: Order embeds line items array; Product referenced by id when catalog shared across orders. Pros: Flexible schema evolves without migrations; embed reduces joins. Cons: Unbounded arrays hit 16MB doc limit; duplicate data needs sync strategy. Common mistakes: Deep nesting mirroring relational 3NF; giant embedded arrays. Best practices: Design for queries; use schema validation; monitor document size. Audience level: Engineering Manager.
Full explanation
Embed when data accessed together and bounded size; reference when unbounded growth or shared entities. Balance read patterns vs write amplification.
Real example & use case
Order embeds line items array; Product referenced by id when catalog shared across orders.
Pros & cons
Pros: Flexible schema evolves without migrations; embed reduces joins. Cons: Unbounded arrays hit 16MB doc limit; duplicate data needs sync strategy.
Common mistakes
Deep nesting mirroring relational 3NF; giant embedded arrays.
Best practices
Design for queries; use schema validation; monitor document size.
Follow-up questions
- How would you test Document Schema Design?
- What metrics prove Document Schema Design is healthy in prod?
- How does Document Schema Design change at 10× traffic?