Template: Design new database table
11 May 2025 (Updated 27 May 2025)
1. Design the table structure
- Table name
- Write name
- Columns
- List columns and their types
- Foreign keys
- List foreign keys
- Indexes
- List indexes
Example:
- Table name
article
- Columns
- id: number
- title: string
- user_id: number
- created_at: datetime
- updated_at: datetime
- Foreign keys
- user_id -> user (id)
- Indexes
- (id) unique
2. Write some example queries
Write some example queries to get a feel for what it would look like to query your table for the data you’d need. For example:
- Find all articles written by a user
- Find articles created before some date
3. Ask AI tools to review your proposed database schema
Enter a prompt like the following into ChatGPT or whatever AI tool you use:
I need a <table> to store <blah> and was thinking of doing this:
<copy and paste your table structure design>
What do you think?
Tagged:
Misc