From Spreadsheet to Database: Types, Keys and CREATE TABLE in Minutes
Turn CSV or Excel files into a relational schema: choose column types, primary and foreign keys, generate SQL for your database and draw an ER diagram.

From Spreadsheet to Database: Types, Keys and CREATE TABLE in Minutes
Spreadsheets are great until several people need the same data, history matters, or the file reaches a million rows. Moving to a database starts with a schema. The Spreadsheet to SQL Schema tool drafts it from your files.
One file, one table
Give each entity its own file: customers, orders, products. A table should describe one kind of thing, with one row per item. If a spreadsheet repeats customer details on every order line, split it into two files first.
Choosing types
| Data | Good type |
|---|---|
| Whole numbers, IDs | INTEGER or BIGINT |
| Money | NUMERIC/DECIMAL, not floating point |
| Dates | DATE |
| Dates with times | TIMESTAMP / DATETIME |
| Yes/no | BOOLEAN or BIT |
| Text | VARCHAR(n) or TEXT |
The tool scans every value to suggest a type and the longest text length, adding headroom.
Primary keys
Every table needs a column, or set of columns, that uniquely identifies each row. The tool suggests a unique, never-blank column named id, *_id or code. If none exists, add a surrogate key such as an auto-increment ID.
Foreign keys
A foreign key links a row to a row in another table: orders.customer_id points to customers.customer_id. The tool detects these when the names match and every value exists in the other table, which also finds data problems: an order with a customer that does not exist breaks the link.
Dialects
PostgreSQL, MySQL, SQLite and SQL Server differ in quoting, boolean and date types. Choose your target and the SQL is written for it, with referenced tables created first.
Worked example
customers.csv and orders.csv become two tables. customer_id is the primary key of customers and a foreign key in orders; ordered_at is a TIMESTAMP, total a NUMERIC and paid a BOOLEAN. Five INSERT rows per table load the sample data.
Before going live
Add indexes for columns you search or join on, constraints for business rules, and a backup plan. Then load the full data and check row counts against the spreadsheets.
Work in small, saved steps
Every tool in this series keeps your work as a project in your own browser. Make a change, check the preview, and use undo (Ctrl+Z) or redo (Ctrl+Y) freely; nothing is lost while you experiment. Before a big change, save a named copy from the Projects menu, so you can return to it later or compare two versions side by side. Export the project file when you want to move it to another computer or keep a backup, and import it again whenever you need it.
Privacy by design
The processing happens in the page itself. Files you open are read by code running on your device, results are calculated locally, and nothing is sent to a server or stored in a cloud account. That makes the tool suitable for customer lists, financial data and other material you would not upload to an unknown website. If a component such as a file reader or a map outline is downloaded from a public CDN, only that open-source code or public data is fetched, never your own content.
Share the result clearly
When you pass the output to colleagues, say where the data came from, when it was exported, and which settings you used, so that someone else can repeat the work and get the same answer. Keep the original file unchanged and store the cleaned or calculated version separately. A short note with the assumptions, filters and date saves a lot of questions later and makes the result easier to trust.



