Database Design for AI Coders | SheCodes
Intermediate 7 min read

Database Design for AI Coders

A database is just a collection of linked spreadsheets that your app uses to remember things. Let's break it down in plain English. Use our Database Planner to map out your tables visually.

In this chapter

  • What a database is (think: linked spreadsheets)
  • Tables, rows, and relationships explained simply
  • Which database to pick for your first project
  • How to ask your AI tool to design and set up your database

The Big Picture

Imagine a Google Sheets file with multiple tabs. Each tab holds different information: one for users, one for blog posts, one for comments. A database works the same way, except it's built to handle thousands (or millions) of entries without slowing down.

πŸ“Š The whole file = Your Database
πŸ“‹ Each tab / spreadsheet = A Table
πŸ“ Each row in a tab = One entry (a user, a post, etc.)

Key Concepts in Plain English

πŸ“‹ Table (Spreadsheet) A spreadsheet that holds one type of thing. You might have a Users spreadsheet, a Posts spreadsheet, and a Comments spreadsheet. Think: one Google Sheet tab = one table
πŸ“ Row (One Entry) A single line in your spreadsheet. If you have a Users table, each row is one person. If you have a Posts table, each row is one blog post. Row 1: Alex, [email protected], joined Jan 5
πŸ“Š Column (Header) The headers at the top of your spreadsheet. They define what information you collect for each entry. Name, Email, Date Joined, Profile Photo
πŸ”’ Unique ID Every entry gets a number so you can find it, like a student ID. No two entries share the same number, which makes it easy to look up any specific one. User #1, User #2, User #3...
πŸ”— Link to Another Spreadsheet A column that points to an entry in a different spreadsheet. Like a "written by" column in your Posts spreadsheet that points to the Users spreadsheet. Post "My Trip" β†’ written by User #3 (Alex)
πŸ—ΊοΈ The Blueprint The plan for your whole database: what spreadsheets exist and what columns each one has. You tell your AI tool the blueprint, and it creates everything for you. "I need Users, Posts, and Comments spreadsheets"

The magic of databases is that spreadsheets can reference each other. Here are the three ways they connect.

πŸ‘€ β†’ πŸ“‹ One-to-One

One entry connects to exactly one entry in another spreadsheet.

One user has one profile. One profile belongs to one user.

Real-world analogy: Your driver's license links to exactly one person.

Tell your AI:

β€œSet up a database where each user has one profile with bio, avatar, and social links.”

πŸ‘€ β†’ πŸ“πŸ“πŸ“ One-to-Many

One entry connects to many entries in another spreadsheet. This is the most common type.

One author writes many blog posts. Each blog post has one author.

Real-world analogy: One teacher has many students in their class.

Tell your AI:

β€œSet up a database where users can write many blog posts. Each post belongs to one user.”

πŸ“πŸ“ ↔ 🏷️🏷️ Many-to-Many

Entries on both sides can connect to many entries on the other side. Needs a helper spreadsheet in between.

A blog post can have many tags. A tag can be on many posts.

Real-world analogy: Students take many classes. Each class has many students.

Tell your AI:

β€œSet up a database for blog posts and tags where each post can have multiple tags and each tag can be on multiple posts.”

What Kind of Information Can You Store?

When you tell your AI to create a database, it needs to know what kind of information goes in each column. Here are the everyday types.

✏️ Text Names, emails, descriptions, blog post content: anything made of words. "Alex Johnson", "[email protected]", a full blog post
πŸ”’ Numbers Quantities, ages, prices, ratings: anything you'd do math with. 42, 3.5 stars, 150 items in stock
βœ… Yes / No Anything that's either true or false. Is this user an admin? Is this post published? Published: Yes, Admin: No
πŸ“… Dates & Times When something happened or will happen. Signup dates, appointment times, deadlines. Joined: March 15, 2025 at 2:30 PM
πŸ’° Money Prices, totals, balances: stored with exact decimal precision so you never lose a penny. $29.99, $1,250.00
πŸ”— Links / URLs Web addresses, image URLs, file links: stored as text but used as references. https://example.com/photo.jpg
πŸ“‹ Choices from a List When there are only a few valid options. Think dropdown menus: status, role, category. Status: active, paused, or cancelled
πŸ†” Unique IDs Automatically assigned numbers or codes that identify each entry. You rarely set these yourself. User #1, User #2, User #3...

Example Database Blueprints

Here's what the spreadsheet setup looks like for common apps. You can tell your AI tool to create any of these.

πŸ“ Blog Needs spreadsheets for Users, Posts, Comments, and Tags. Users
Who writes and comments: their name, email, profile photo, and when they joined
Posts
Each blog post: title, the content, who wrote it, and when it was published
Comments
Reader feedback: the comment text, who wrote it, which post it's on, and when
Tags
Categories like "Travel" or "Food" that can be attached to posts
πŸ›’ Online Store Needs spreadsheets for Users, Products, Orders, Order Items, and Reviews. Users
Shoppers: their name, email, and shipping address
Products
What you sell: name, description, price, photo, and how many are in stock
Orders
Each purchase: who bought it, the total cost, order status, and date
Order Items
The specific products in each order: which product, how many, and the price paid
Reviews
Customer feedback: star rating, review text, who wrote it, and which product
πŸ“‹ Team Project App Needs spreadsheets for Organizations, Users, Projects, and Tasks. Organizations
The company or team: name, plan level, and when they signed up
Users
Team members: name, email, which organization they belong to, and their role
Projects
Each project: name, which organization it belongs to, and who created it
Tasks
Things to do: title, status (to-do, doing, done), which project, and who it's assigned to
πŸ’¬ Social Media Needs spreadsheets for Users, Posts, Likes, Follows, and Comments. Users
People on the platform: username, display name, bio, and profile photo
Posts
What people share: the text or image, who posted it, and when
Likes
Who liked what: links a user to a post they liked
Follows
Who follows whom: links one user to another user they follow
Comments
Replies to posts: the comment text, who wrote it, and which post it's on

Prompts to Tell Your AI Tool

Copy and paste these into Claude Code, Cursor, Bolt, or whatever AI tool you use. Replace the words in [brackets] with your own details.

Start a new database

β€œSet up a database for a [blog / online store / booking app] with tables for [users, posts, comments] and connect them with the right relationships.”

Add a new spreadsheet (table)

β€œAdd a new table called [Reviews] to my database. Each review should store the text, a star rating (1-5), which user wrote it, and which product it's for.”

Connect two spreadsheets

β€œConnect my [Posts] table to my [Users] table so that each post belongs to one user, and one user can have many posts.”

Set up a complete app database

β€œI'm building a [recipe sharing app]. Design the complete database with all the tables I'll need, explain what each table stores, and set up the connections between them.”

Explain what you built

β€œExplain the database you just created in simple terms. What tables are there, what does each one store, and how are they connected?”

Database Platforms

These are services that host your database in the cloud. You don't need to install anything: just sign up and your AI tool can connect to them. Most also include authentication so users can log in.

Tools That Help Your AI Connect to the Database

Your app needs a "bridge" to talk to the database. These tools act as translators: your AI writes app code on one side, and the tool converts it into database instructions on the other. You don't need to understand how they work; just tell your AI which one to use. Learn more about how this fits together in our backend guide.

Prompt This

Copy-paste these prompts into your AI tool to apply what you just learned.

DESIGN A DATABASE SCHEMA

β€œDesign a database schema for my [type of app]. I need to store [data types]. Show me the tables, columns, and relationships between them.”

CREATE SUPABASE TABLES

β€œCreate Supabase tables for my project: [describe your app]. Include proper data types, foreign keys, and row-level security so users can only access their own data.”

ADD A NEW TABLE

β€œAdd a new [reviews/orders/bookings] table to my existing database. Connect it to my [users/products] table and explain the relationship.”

Frequently Asked Questions

Do I need to learn SQL or any database language?

No! Your AI tool writes all the database code for you. You just need to understand the concepts on this page so you can describe what you want. Say things like "I need a Users table connected to a Posts table" and your AI handles the rest.

What's the difference between SQL and NoSQL?

SQL databases are like structured spreadsheets with strict columns: every entry follows the same format. NoSQL databases are more flexible, like folders where each file can have different information. For most AI coding projects, SQL databases (like Supabase or Neon) are the easier choice because AI tools work better with them.

How do I know what tables my app needs?

Think about the "things" in your app. A blog has users, posts, and comments. An online store has users, products, orders, and reviews. Each "thing" gets its own table. When in doubt, tell your AI tool what your app does and ask it to design the database for you.

Can I change my database after I've started building?

Yes! You can always add new spreadsheets, add new columns, or change how things are connected. Just tell your AI tool: "Add a 'phone number' column to my Users table" and it will handle the change for you.

Where does my database actually live?

On a server in the cloud, managed by a platform like Supabase or Neon. You sign up, get a connection address (like a web link), and your AI tool uses that address to read and write data. You don't need to install anything on your computer.

Is my data safe?

The platforms listed above all handle security, backups, and encryption for you. For extra safety, tell your AI: "Make sure users can only see and edit their own data, not anyone else's." This keeps everyone's information private.