How it works
When you describe what your app needs, the AI automatically creates the database schema to support it. For example:Create a table for tracking customer support tickets with status, priority, assignee, and timestamps.The AI will:
- Create a
ticketstable with the appropriate columns and data types - Add indexes for commonly queried fields
- Set up any necessary relationships to other tables
- Generate the API routes and UI components to work with the data
Schema visualization
The Data tab in the app editor includes an interactive ERD (Entity Relationship Diagram) that shows your complete database schema at a glance. The diagram displays:- All tables and their columns
- Data types for each column
- Primary keys and foreign key relationships
- Relationship lines connecting related tables
Table browser
The Data tab also includes a table browser where you can work with your data directly. From the table browser, you can:- View rows in any table with sortable columns
- Add rows by filling in a form for each column
- Edit rows by clicking on a cell and modifying its value
- Delete rows individually or in bulk
How the AI accesses the database
The AI generates server-side code to read and write data. Database queries always run on the server — in API routes or server components — never in client-side code. The AI typically uses asql helper function for direct queries:
All database queries run server-side. The AI places them in Next.js API routes (
app/api/...) or server components to keep your database credentials secure.Working with your database through chat
You can ask the AI to perform database operations directly from the chat:Show me all tickets created in the last 7 days.
Add a “priority” column to the tickets table with values: low, medium, high, critical.
Delete all test records from the users table where the email contains “example.com”.The AI executes these operations and shows you the results inline. For destructive operations like deleting data or dropping tables, the AI will confirm before proceeding.
Best practices
- Let the AI manage the schema. Describe what you need in plain language and let the AI create the tables, columns, and relationships. You can always refine with follow-up prompts.
- Use the Data tab to verify. After the AI creates or modifies your schema, check the ERD and table browser to confirm everything looks right.
- Seed data for testing. Ask the AI to generate realistic sample data so you can test your app’s UI and workflows before connecting real data.
- Be specific about data types. If you need a column to be an enum, a timestamp, or a JSON field, mention it in your prompt. The AI will choose sensible defaults, but explicit instructions lead to better results.