{"success":true,"name":"choose-sql-primary-key-strategy-deliberately-auto-increment-","description":"Creating a SQL table and picking its id column type.","category":"ai-brimind","path":"ai-brimind/choose-sql-primary-key-strategy-deliberately-auto-increment-/SKILL.md","file":"SKILL.md","content":"---\nname: choose-sql-primary-key-strategy-deliberately-auto-increment-\ndescription: \"Creating a SQL table and picking its id column type.\"\n---\n\n# Choose SQL Primary Key Strategy Deliberately: Auto-Increment vs UUID\n\n## When to use\nProject uses SQL, and you are defining a new table's primary key without weighing exposure, distribution, and index behavior.\n\n## Example request\nSequential ids in public URLs → competitors count your orders and enumerate records; predictable ids leak business information. UUIDs everywhere by reflex → random UUIDv4 scatters index inserts and bloats storage on huge tables; the choice has a physical cost. Ids generated in app code before insert needed → UUIDs shine there; auto-increment requires a round trip first. Mixed conventions across tables → JOINs and tooling get confusing; the project should have one stated id strategy.\n\n## Instructions\nAct like an architect who knows the id column outlives every feature built on it. Before creating a table: check what the project already uses and stay consistent unless there's a named reason. Weigh the real trade-offs: auto-increment integers are compact and index-friendly but predictable — never expose them raw in public URLs if enumeration reveals anything (use a separate public token if needed); UUIDs are safe to expose and generable client-side but cost storage and, in random form, scatter index writes (time-ordered variants exist where the engine or library supports them). The decision inputs are: is the id public, who generates it, and how big will the table get. Only finalize once the choice is justified against those three questions, not habit.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1123\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}