Working on a Shared Database in a Club Team Project
When several people work on the same app, they also share its database. That can go wrong in surprising ways: someone renames a column and everyone else's code breaks. This guide covers simple habits that keep a club team project running smoothly.
Agree on the tables first
Before anyone writes code, sketch the tables together on paper or a whiteboard: names, columns and how they connect. Decide naming rules too, for example lowercase with underscores, and table names in plural. Write the decisions down in the project's README.
Keep the schema in files, not just in someone's head
The schema is the structure of your database: tables, columns, keys. Store the SQL that creates it in your project's code, so everyone can build the same database.
-- schema.sql
CREATE TABLE members (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
email TEXT UNIQUE
);
Use migrations for changes
A migration is a small file that changes the schema one step at a time, such as "add a phone column to members". Migrations are numbered or dated so everyone applies them in the same order.
-- 002_add_phone_to_members.sql
ALTER TABLE members ADD COLUMN phone TEXT;
Many frameworks have migration tools built in. For a small club project, numbered SQL files in a folder work fine.
Share seed data
Seed data is a small set of made-up rows that everyone loads for testing. It means everyone sees the same results and can reproduce each other's bugs.
-- seed.sql
INSERT INTO members (name, email) VALUES ('Test Member', 'test@example.com');
Never use real members' personal details as seed data.
Keep test and live data apart
| Database | Who uses it | What goes in it |
|---|---|---|
| Your local copy | You, while coding | Seed data you can delete any time |
| A shared test database (optional) | The team, for trying features | Made-up data |
| The live database | The real app and its users | Real data; changes only through migrations |
Only one or two trusted people should have access to the live database, and changes should go through migrations that the team has reviewed.
Team rules that save trouble
- Do not edit the live database by hand. Write a migration instead.
- Never rename or delete a column without telling the team. Other code may depend on it.
- Keep the connection string out of git. Use a
.envfile and share a.env.examplewith fake values. - Back up before big changes. For SQLite, copy the file. For server databases, use the database's backup tool.
- Review each other's SQL. A second pair of eyes catches missing
WHEREclauses and unsafe string building.
When something breaks
Stay calm and ask: what changed most recently? Check the latest migration and the latest commits. If the live data was damaged, restore from the backup and work out what happened before trying again.
Next step
If your team is just starting, our page on club projects and hackathons with a database has project ideas that fit a few tables.
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.