How to create database tables (by hand or with AI)
In TeleportHQ, you add tables to a database from the Add a new table card in the database's panel. Click Create Tables to define the table and its columns yourself, or Create using AI to describe what you need, for example "a bakery shop with products and orders", and let AI build the tables. A table is like a spreadsheet tab: each column is a field, each row is one item.
Before you start
- You need a database that supports table creation: the TeleportHQ database, PostgreSQL, MySQL, MariaDB, Amazon Redshift, Supabase, CockroachDB or TiDB. Start with How to set up the built-in TeleportHQ database if you have none.
- Creating tables with AI uses AI tokens. See What uses AI tokens?
- The TeleportHQ database has table and column limits per plan: 30 tables and 20 columns per table on the trial, Pro and Premium. See TeleportHQ database limits by plan.
Open the Add a new table card
- In the left sidebar, click Data Sources (the database icon).
- Click your database card, for example Bakery database.
- In the panel that opens, find the Database Tables section. Its Add a new table card has the buttons Create Tables, Import from File, Create using AI and, when the project has a business description from the AI website builder, Generate from Business.
You can also start a table from the table window: click View Data next to any table, then Add new table at the bottom of the Tables list on the left.
Create a table by hand
To create a TeleportHQ database table yourself, for example a products table:
- On the Add a new table card, click Create Tables. The table window opens on the Create New Table form.
- In Table Name, replace
new_tablewithproducts. Names use lowercase letters, numbers and underscores. - In the first column, type the Name
id, choose the TypeINTEGER, and tick Primary Key and Auto Increment. The primary key is the field that tells rows apart, and Auto Increment numbers new rows for you. - Click Add Column, type the name
nameand choose the typeVARCHAR(text). - Click Add Column again, type
priceand chooseNUMERIC(a number with decimals). - For each column, decide whether it may be empty. New columns start with Nullable ticked; untick it to make the field required. Tick Unique if no two rows may share the value.
- Click Create Table.
A message confirms Table "products" created successfully. The Columns tab above the list counts your columns, up to 20, for example Columns (3/20). The Indexes tab lets you add indexes at the same time; see How to add columns and link tables together.
Create tables with AI
To let AI create TeleportHQ database tables from a description:
- On the Add a new table card, click Create using AI. The Create Tables with AI window opens, with Example prompts and Tips for better results.
- In Describe your tables, write what you need, up to 2,000 characters. For example:
A bakery shop: products with name, price, photo and category; orders linked to customers with date, total and status; customers with name, email and phone. - Press Enter, or click Generate Tables. (Shift+Enter starts a new line.)
A message confirms Successfully created N table(s). The tips suggest naming the columns you want, mentioning links between tables ("linked to", "belongs to"), and listing special rules such as unique values or defaults.
Generate tables from your business description
When the project has a business description from the AI website builder, the card also shows Generate from Business ("Uses AI to automatically generate database tables based on the business description you provided during project setup."). Click it: AI creates tables that fit your business, for example menu_items and reservations for a restaurant. A message confirms Successfully created N table(s) from business description. This also uses AI tokens.
Check that it worked
The new tables appear under Database Tables, each with its columns listed and a View Data button. Click it to start adding rows. See How to view, add and edit records.
Troubleshooting
"At least one column must be set as primary key" Tick Primary Key on one column, usually id.
"At least one column with a name is required" Fill in the name of at least one column.
"Foreign key requires table and column selection" You ticked Foreign Key on a column. Choose its References Table and References Column, or untick it.
"You've reached the maximum number of tables for your plan (limit: N). Upgrade your plan or remove unused tables to continue." Your TeleportHQ database has the most tables your plan allows. Remove a table you don't need, or upgrade. See TeleportHQ database limits by plan.
"Maximum 20 columns allowed per table" A table can have at most 20 columns, and Add Column stops working at 20. Split the data into two linked tables.
"order" is a reserved keyword and cannot be used as a column name Some words are reserved by the database, such as order, group, select or table. Use a longer name, for example order_date.
"Failed to generate tables" AI couldn't create the tables. Check that you have AI tokens left, make the description more specific, and try again.
Good to know
- Name rules: table and column names use letters, numbers and underscores, can't start with a number, can't contain two underscores in a row or end with one, and can be up to 64 characters.
- Linking tables (for example each order belongs to a customer) is done with a foreign key. See How to add columns and link tables together.
- Other connected databases that can create tables, such as MongoDB, Firestore, Airtable, ClickHouse and Turso, have no Add a new table card. Use Add new table in their table window instead.
- Have your data in a spreadsheet already? Import it from a file to create the table and its rows in one step.