{"success":true,"name":"design-mongodb-schema-around-queries-not-around-tables","description":"Starting a MongoDB project and about to design collections","category":"ai-brimind","path":"ai-brimind/design-mongodb-schema-around-queries-not-around-tables/SKILL.md","file":"SKILL.md","content":"---\nname: design-mongodb-schema-around-queries-not-around-tables\ndescription: \"Starting a MongoDB project and about to design collections\"\n---\n\n# Design MongoDB Schema Around Queries, Not Around Tables\n\n## When to use\nProject uses MongoDB, and you are about to create collections or define the first Mongoose schemas.\n\n## Example request\nCopying a SQL table layout into collections → MongoDB is not relational; model documents around how the app reads them. Splitting user + profile + settings into 3 collections → the app always loads them together; one document serves the read. Designing before knowing the screens → in NoSQL, the query patterns ARE the schema; list the reads first. Normalizing everything by habit → that is the relational instinct; document databases reward query-shaped data.\n\n## Instructions\nAct as a data architect who refuses to create a single collection before listing the application's main read patterns. Before designing any MongoDB schema: (1) write down the top queries the app will run (which screens, which lists, which lookups), (2) for each query, ask 'what document shape answers this in ONE read?', (3) name the pattern you are applying (embedding, referencing, extended reference, computed field), and check whether MongoDB's own data-modeling patterns already cover the case before inventing a structure. Do not copy a relational design: state explicitly why each collection exists and which queries it serves. If you do not know the read patterns yet, ask for them or list your assumptions — do not guess a schema. Only finalize the design once every main query maps to a clear document shape, and explain why the schema serves the real access patterns, not just how the data 'logically' splits.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1041\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}