Design a database schema from requirements
Turn feature requirements into a normalized schema with keys, constraints, indexes and the tradeoffs explained.
Describe the question and your tables, and get a correct, readable query with an explanation and edge cases.
Write a {{dialect}} query that answers this question:
{{question}}
Schema (tables, columns, keys, anything relevant):
{{schema}}
Rules:
- Use only tables and columns that appear in the schema. If something I asked for is not in the schema, say so and ask rather than inventing a column.
- Prefer CTEs for multi-step logic, explicit JOIN syntax, and clear aliases. Format for readability.
- Handle NULLs, duplicates and ties deliberately, and tell me how.
- Mention any assumptions about the data (for example, whether a status value means active).
Output:
1. The query in a single code block.
2. A short plain-language explanation of how it works, step by step.
3. Edge cases and gotchas: what could make the result wrong or surprising.
4. Which indexes would help if this table is large.
5. A tiny sample of input rows and the output the query should return, so I can verify it.Telling the model to refuse invented columns and to state its assumptions prevents the most common SQL failure, plausible but wrong queries. The sample-rows check gives you a fast way to verify.
Licensed CC0 (public domain) Version 1 · history
Turn feature requirements into a normalized schema with keys, constraints, indexes and the tradeoffs explained.
Find why a query is slow and get a faster version, index suggestions and a way to prove the improvement.
Describe your tables and the question you need answered and get a correct, commented SQL query with assumptions spelled out.
Set up a proper cohort retention analysis, from defining cohorts and the activity event to producing the table and reading it correctly.
Paste a slow or suspicious SQL query and get correctness checks, performance fixes, and a cleaner rewrite you can verify.
Draft a clear, tight system prompt that tells an AI coding assistant how to work in your repository.
Comments (0)
Sign in to join the discussion.
No comments yet. Be the first to share how it worked.