Uploading CSV files or an Excel (.xlsx) workbook during project creation infers a relational schema, detects column types, and imports the rows into managed PostgreSQL. This walkthrough uses one small dataset, customers and orders, so you can compare the two upload paths and still land on the same database.
The outcome is the same either way: two tables, a foreign key, three customers, four orders. Excel adds a table review step first. After you confirm the tables, schema inference, types, and import match CSV.
You do not connect an external warehouse. Import writes into the PostgreSQL database for this project.
The sample data
Use two tables. For CSV, save them as customers.csv and orders.csv. For Excel, put them on two sheets named customers and orders in one .xlsx workbook. Keep a header row. Do not put a title above the headers.
customers
id,email,country,created_at
1,ada@example.com,IN,2026-09-01
2,grace@example.com,DE,2026-09-04
3,linus@example.com,US,2026-09-10
orders
id,customer_id,status,total,ordered_at
10,1,paid,49.00,2026-09-12
11,1,paid,12.50,2026-09-20
12,2,refunded,49.00,2026-09-22
13,3,paid,88.00,2026-10-02
customer_id in orders should match id values in customers. That is what lets tofudb treat orders.customer_id as a foreign key instead of an orphan integer. Dates here are YYYY-MM-DD. Totals are numbers with no currency symbol.
Create the project
- Click New Project in the dashboard.
- Enter a name. Optionally set a domain (for example E-Commerce & Retail) and a database alias.
- Choose a migration source rather than Fresh Database or a starter template:
- CSV File if you have
.csvfiles - Excel Spreadsheet if you have a
.xlsxworkbook
- CSV File if you have
Starter templates are hidden once you pick a file source. The uploaded files define the schema.
CSV path
Upload both files in one pass. Inference needs customers.id in the same batch as orders.customer_id. If you upload only orders.csv, there is no parent table to attach the foreign key to.
tofudb detects the header row, column names, and types, then proposes relationships. You review the draft schema before it is committed to the live instance.
Excel path
Upload the workbook. tofudb opens Review Excel tables before it infers a schema.
You should see:
- A spreadsheet-style grid of the active sheet (row numbers, column letters, cells)
- Sheet tabs along the bottom (
customers,orders, and a sheet count) - Colored outlines around each detected table
- A toolbar that appears once you select a row, a column, or a cell range
Work through the review in this order.
1. Confirm each sheet has the right table. Switch to customers, then orders. The outline should cover the header row plus every data row (three customers, four orders). If the detector missed a row or included empty cells below the data, drag to select the real range and choose Use as table bounds. If nothing was detected, use Define table from sheet, or select cells and Use selection as table.
2. Confirm the header. Click the row number of the first data header (id, email, …). If that row is already the header, you will see Remove header row. If a title row was picked instead, select the real header and choose Use as header row. Extra title rows above the data confuse column names. Set the header explicitly rather than hoping inference guesses.
3. Exclude columns you do not want. Click a column letter, then Exclude column from import. Use this for notes, computed totals, or helper columns that should not become database columns. Include column in import puts it back. You can skip a whole detected region with Skip this table and restore it later.
4. Exclude junk rows. Click a row number and Exclude row from import for totals rows, blank separators, or a second header copied into the middle of the sheet.
5. Copy if you need to inspect values. Click a cell or drag a range. Arrow keys move the selection. Shift+arrow extends it. Ctrl+C (Cmd+C on Mac) copies the selection. The grid is tiled so large sheets stay usable.
When both sheets look like the sample tables, confirm the review. From here, inference is the same as CSV.
What inference should produce
After CSV upload, or after you confirm Excel tables, the migration engine:
- Uses the header row for column names
- Infers types (
idas integer/serial,emailandstatusas text,totalas numeric,created_at/ordered_atas date or timestamp) - Maps
orders.customer_id→customers.idwhen names and values line up - Imports the rows into managed PostgreSQL for that project
A reasonable draft looks like this:
customers
id(primary key)emailcountrycreated_at
orders
id(primary key)customer_id→customers.idstatustotalordered_at
Open the ERD and confirm one edge from orders to customers. Open the sheet grid and confirm three customer rows and four order rows.
If customer_id landed as a plain integer with no foreign key, stay in the schema designer and say so in English: “orders.customer_id is a foreign key to customers.id”. Review the visual schema diff, then commit. AI-initiated schema changes are not applied until you review them.
When values do not match the inferred type
If some cells do not fit the proposed column type, you choose what happens per column before deploy. Nothing in the original file is rewritten.
Typical choices:
- A suggested cleanup, when the dirty examples share a pattern (trim spaces, keep the number before parentheses, strip footnote markers like
[1]) - Widen the type (integer to numeric if you have decimals; keep original text by changing the column to text)
- Import mismatches as empty (only those cells; the rest of the row is kept)
- Use a default value you enter
- Skip rows that contain a mismatch
- Omit the column from the import
If the column is required (NOT NULL), importing mismatches as empty is blocked until you make the column optional, supply a default, or skip those rows.
Worked cases on this sample:
idstored as1.0. Some CSV exports and Excel numeric cells write a decimal. Inference may pick numeric instead of integer. Prefer whole numbers in the file, or widen/fix the type in the mismatch review before you treat the import as final.totalwith a currency symbol ($49.00). The column may infer as text. Strip the symbol in the file, or choose a cleanup / type change in review, rather than editing every cell in the sheet grid later.- Blank
countryvs the string"NA". A blank cell typically becomes NULL."NA"is a real value. Do not write"null"in the file unless you want that literal. - Missing rows. If the sheet grid shows fewer than three customers or four orders, on CSV look for a malformed line (an unescaped comma inside an email, a missing column). On Excel, go back to table review and check that the outline still covers every data row and that you did not exclude a header by mistake.
You can still clean the file and upload again if you would rather fix the source than pick a policy.
Check the data, then query it
The sheet grid is live against the imported tables. Sort, filter, and edit cells there. Invalid edits get a red border. That is the right place to catch a total stored as text or a blank email.
Then use NLQ (or dictate with the microphone; voice goes into the same chat):
- “How many paid orders are there?”
- “Total of paid orders by country.”
- “List customers with a refunded order.”
On this sample, paid totals should be IN 61.50 (two orders) and US 88.00 (one order). Germany only has a refunded order, so it should not appear under a paid filter.
Those questions need the foreign key. If the import missed the relationship, “by country” cannot join orders to customers until you add it. Export the result with the CSV export toolbar if you need a file back out.
After the project is live
You can add or update data from chat with a new CSV or Excel file.
- Leave the instruction empty to append rows.
- Add an instruction when the file is not a blind append, for example “append these rows to orders” or “drop students.phone and add students.mobile”.
Excel still goes through table review first. Destructive schema changes (drop or rename) require confirmation before deploy.
If you already designed the schema in the conversational designer and only need records, CSV or Excel import is still the path for loading rows into those tables. Use it at project creation when you choose a migration source, or from chat after the project is live.
Practical rules that keep inference honest
- One header row. Extra titles above the headers confuse column detection. In Excel review, set the header row yourself if the detector picked a title.
- Stable identifiers. Do not reuse
idvalues across tables unless they are meant to be the same entity. - Name foreign keys after the parent.
customer_idis easier to detect thancust. - Do not mix units in one column.
"49.00 USD"will not infer as numeric. - Keep related tables in one pass. Upload both CSV files together, or keep both sheets in the same workbook, so relationships can be detected together.
- Confirm row counts in the sheet grid before you trust NLQ totals.
JSON, SQL dumps, and SQLite are still on the roadmap. CSV and Excel (.xlsx) are the supported import formats today.