prompt
Database Schema Designer
Designs a normalized database schema with tables, keys, and relationships from requirements.
You are a database architect. Design a schema for the requirements below. Inputs: - What the app does + the entities: {{requirements}} - Database: {{database}} (PostgreSQL, MySQL, etc.) - Scale/access patterns: {{patterns}} Produce: 1. The tables: each with columns, types, primary key, and NOT NULL/unique constraints. 2. Relationships: foreign keys, and the cardinality (1:1, 1:many, many:many via a join table). 3. The CREATE TABLE statements in valid {{database}} syntax. 4. Indexes for the main access patterns in {{patterns}}. 5. 2-3 design notes: a normalization choice, where you'd denormalize for {{patterns}}, and one thing to watch as it scales. Rules: normalize sensibly (avoid repeating groups) but call out any deliberate denormalization for performance; use correct {{database}} types; name tables/columns consistently; add timestamps where useful; flag any requirement that's ambiguous about cardinality. Don't over-engineer for scale you won't hit.
Variables
{{requirements}}App + entities{{database}}Database{{patterns}}Scale/access patternsExample output
Requirements: a blog with users, posts, and tags. PostgreSQL. Tables & relationships: - users (1) \u2192 posts (many). - posts (many) \u2194 tags (many) via post_tags. CREATE TABLE users ( id uuid PRIMARY KEY DEFAULT gen_random_uuid(), email text UNIQUE NOT NULL, name text NOT NULL, created_at timestamptz NOT NULL DEFAULT now() ); CREATE TABLE posts ( id uuid PRIMARY KEY DEFAULT gen_random_uuid(), author_id uuid NOT NULL REFERENCES users(id), title text NOT NULL, slug text UNIQUE NOT NULL, body text, published_at timestamptz, created_at timestamptz NOT NULL DEFAULT now() ); CREATE TABLE tags ( id uuid PRIMARY KEY DEFAULT gen_random_uuid(), name text UNIQUE NOT NULL ); CREATE TABLE post_tags ( post_id uuid NOT NULL REFERENCES posts(id) ON DELETE CASCADE, tag_id uuid NOT NULL REFERENCES tags(id) ON DELETE CASCADE, PRIMARY KEY (post_id, tag_id) ); Indexes: CREATE INDEX idx_posts_author ON posts(author_id); CREATE INDEX idx_posts_published ON posts(published_at DESC) for the homepage feed. Notes: many:many tags use a join table (post_tags) with a composite PK to prevent dupes. If you list "posts by tag" constantly, the post_tags(tag_id) lookup is covered by the PK's leading column \u2014 add an index on (tag_id, post_id) if queries lead with tag. Watch the posts feed query as the table grows \u2014 the published_at index keeps it fast.
Details
Author
AI Khazna
License
—
Security
Vetted
Type
prompt
Related assets
More curated picks in Development & Code.
npm install @modelcontextprotocol/server-everything
npm install @modelcontextprotocol/server-memory
npm install @modelcontextprotocol/server-filesystem
npm install @modelcontextprotocol/server-git
npm install @modelcontextprotocol/server-fetch
npm install @modelcontextprotocol/server-sequentialthinking
Audit before you install
Run any source through our checks - AI visibility, security, performance, and stack detection.
Automated Web Security Scan
security
PageSpeed Analyzer
performance
AI Content Quality Test
arabic content
AI Agent / MCP Server Tester
ai testing
Site Stack Detector
migration
AI SEO / AEO / GEO Audit
ai visibility
llms.txt Generator
ai visibility
Readability Score
arabic content
Schema / JSON-LD Builder
ai visibility
AI Cost Calculator
ai testing
Headline Analyzer
arabic content