A Smooth Path From Spreadsheet to Database
Many first databases begin life as a spreadsheet. This page describes a hypothetical move done smoothly, step by step, for a volunteer group's contact list. It is a model of good practice, not a real story.
Step 1: freeze a copy
The group saves a dated copy of the spreadsheet before changing anything. Every later step can be repeated from this copy if something goes wrong.
Step 2: look at the data honestly
Scrolling through, they notice:
- some people appear twice with slightly different spellings
- phone numbers are written in several formats
- one column, "Groups", contains comma-separated lists like
"garden, kitchen" - a few rows have no email
Writing these down now saves surprises later.
Step 3: design the tables
Instead of copying the spreadsheet's shape, they design for the questions they ask:
| Table | Columns |
|---|---|
| people | id, name, email, phone |
| groups | id, name |
| memberships | person_id, group_id |
The comma-separated "Groups" column becomes the memberships linking table, so "who is in the kitchen group?" is a simple query.
Step 4: clean before importing
In a copy of the spreadsheet, they:
- merge obvious duplicate people
- trim extra spaces from names and emails
- pick one phone format
- split the "Groups" lists into separate rows on a new sheet
Cleaning in the spreadsheet is fine at this stage; it is a familiar tool.
Step 5: import
They export each sheet as CSV and import it into SQLite using a visual tool such as DB Browser for SQLite. Then they fill the linking table by matching names to ids.
Step 6: check the numbers
| Check | How |
|---|---|
| Same number of people as the cleaned sheet | SELECT COUNT(*) FROM people; |
| No duplicate emails | SELECT email, COUNT(*) FROM people GROUP BY email HAVING COUNT(*) > 1; |
| Everyone in at least one group, if expected | A LEFT JOIN from people to memberships with IS NULL |
| Spot-check five random people | Compare with the spreadsheet by eye |
Step 7: add rules so the mess cannot return
emailUNIQUE, so the same person cannot be added twicenameNOT NULL- foreign keys on
memberships, so it cannot point to people or groups that do not exist
Step 8: switch over clearly
They agree a date after which the database is the only place to update contacts, and mark the old spreadsheet as read-only and archived. Running both in parallel for long is how data drifts apart again.
What made it smooth
| Good choice | Problem it avoided |
|---|---|
| Frozen copy first | Losing original data |
| Listing problems before designing | Surprises during import |
| Designing for questions, not copying the grid | Awkward queries forever |
| Cleaning before import | Importing the mess |
| Checks after import | Silent data loss |
| Rules after import | The same problems returning |
| One clear switch-over date | Two sources of truth |
For the cost-and-benefit side of this decision, see moving from a spreadsheet to a database, and use the normalisation self-check on your design.
A free learning page for beginners. Practise on a test database, never on real customer data, and check the official documentation for your database version.
Illustrative example: the organisations, people, projects and results described on this page are hypothetical. They do not describe a real client or engagement, and no consulting services are offered here.