Because every layer depends on the schema. Once code is written against a schema, changing it forces changes in controllers, middlewares, validators, and frontend. Schema changes cascade through the codebase.
Why design the schema before coding?
More FAQs in Why You Should Design the Schema Before Coding
Collections (entities), fields, types, constraints (required, unique, default, enum), indexes, and relationships (ref vs embed). All of these are hard to change after code is written.
Use ref for one-to-many with large N (e.g., user and messages). Use embed for small, tightly coupled data that always loads together (e.g., an address inside a user). Embedding is fast but bloats documents; ref keeps them small.
Based on the queries you will run. If you often look up by email, add a unique index on email. If you often check if a request from A to B exists, add a compound unique index on (fromUserId, toUserId). Indexes serve queries.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.