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:

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:

TableColumns
peopleid, name, email, phone
groupsid, name
membershipsperson_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:

  1. merge obvious duplicate people
  2. trim extra spaces from names and emails
  3. pick one phone format
  4. 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

CheckHow
Same number of people as the cleaned sheetSELECT COUNT(*) FROM people;
No duplicate emailsSELECT email, COUNT(*) FROM people GROUP BY email HAVING COUNT(*) > 1;
Everyone in at least one group, if expectedA LEFT JOIN from people to memberships with IS NULL
Spot-check five random peopleCompare with the spreadsheet by eye

Step 7: add rules so the mess cannot return

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 choiceProblem it avoided
Frozen copy firstLosing original data
Listing problems before designingSurprises during import
Designing for questions, not copying the gridAwkward queries forever
Cleaning before importImporting the mess
Checks after importSilent data loss
Rules after importThe same problems returning
One clear switch-over dateTwo 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.