{"success":true,"name":"design-the-sql-schema-around-real-queries-not-just-the-data","description":"Creating or changing SQL tables for a new feature.","category":"ai-brimind","path":"ai-brimind/design-the-sql-schema-around-real-queries-not-just-the-data/SKILL.md","file":"SKILL.md","content":"---\nname: design-the-sql-schema-around-real-queries-not-just-the-data\ndescription: \"Creating or changing SQL tables for a new feature.\"\n---\n\n# Design the SQL Schema Around Real Queries, Not Just the Data\n\n## When to use\nProject uses SQL, and you are about to create tables or add columns before listing the queries the feature will actually run.\n\n## Example request\nPerfectly normalized tables → every screen needs five JOINs; the schema ignored the read patterns. One giant table 'to keep it simple' → every write locks everyone; it ignored the write patterns. Storing JSON blobs to avoid schema decisions → now you can't filter or index on the fields; the decision was postponed, not avoided. Copying a schema from a tutorial → your app sorts and filters differently; schemas serve queries, not diagrams.\n\n## Instructions\nAct like an architect who designs storage backwards from usage. Before creating or altering tables: write down the 3–5 most frequent queries the feature will run — what they filter by, sort by, and join on. Then shape the schema so those queries are simple and indexable, applying normalization as the default and denormalizing only with a named reason. Check whether the database already offers a fitting built-in (JSON columns, enums, generated columns, views) before inventing a workaround. If you don't yet know the queries, that's the missing information — get it before designing. Only finalize the schema once each key query maps cleanly onto it, and explain how the design serves those queries rather than just mirroring a diagram.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1026\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}