The real question
Database choice can feel like a big decision, but for small projects the pressure is usually overstated. A weather logger, a home inventory or a small web app has modest data and modest traffic. What matters more is how your data is shaped, how you will ask questions of it, and how much effort you want to spend on running it.
Table-based (SQL) databases
A relational database stores data in tables made of rows and columns, much like a spreadsheet with strict rules. Each column has a defined type, and tables can refer to one another. You query the data using SQL, a standard language for asking things like “all readings from this sensor in the last day, sorted by time”.
Strengths that matter to small projects:
- Structure helps you. Because the layout is declared up front, the database can reject nonsense, such as text where a number belongs.
- Relationships are natural. If you have devices, rooms and readings, you can store each once and link them, instead of copying the same details everywhere.
- Powerful queries. Filtering, grouping and summarising are built in, which suits the kind of questions that come up with data analysis tools and simple reports.
- Transactions. Related changes can be applied together or not at all, which protects against half-finished updates.
- Maturity. There are well-known options, including lightweight ones that live in a single file with no server to run, which is attractive for a small device.
The cost is that changing the structure later takes some care, and you do need to design the tables before you begin.
Flexible (NoSQL) stores
“NoSQL” is a broad label rather than one technology. It covers several designs:
- Document stores keep self-contained records, often in a JSON-like format, where each record can have different fields.
- Key-value stores map a name to a value, and are simple and fast for things like caching or settings.
- Wide-column and graph stores suit specialised layouts and relationships, and are less likely to matter for a first project.
- Time-series databases are designed around timestamped data, which sensor projects produce in quantity.
The common appeal is flexibility. If your records vary, or your structure is still changing as you experiment, a document store lets you save data without declaring a full layout first. Some designs also make it easier to spread data across many machines, which is a concern for very large systems and rarely for a hobby build.
The costs are that the database may enforce fewer rules, so your code takes on more responsibility for keeping the data consistent, and that combining information across records can be harder than a relational join. Features and guarantees vary widely between products, so check the documentation of whichever one you consider instead of assuming.
How to decide for a small project
Start from the data, not from the label:
- Is the data naturally tabular? Regular readings with a timestamp, a source and a value fit a table very well.
- Do the records vary a lot? Notes, configuration blobs and loosely structured messages may fit a document store better.
- Will you need to combine and summarise? Averages per day or counts per category favour SQL’s query abilities.
- How much do you want to run? A single-file database avoids installing and maintaining a server, which suits a small board or a home server. A separate database server adds flexibility but also upkeep.
- What do your tools expect? Some frameworks and libraries have strong defaults for one kind. Going with the grain saves effort.
For many hobby projects, a simple relational database is a safe default because it is widely documented and its habits transfer to other projects. That is a general tendency, not a rule. If your data is truly free-form, a document store may be simpler.
Common mistakes
- Choosing for scale you do not have. A project logging a few readings a minute does not need infrastructure designed for huge systems. Pick the simplest thing that works and move later if you must.
- Skipping backups. Whatever you choose, plan for losing the device. A backup strategy matters more than the engine, and a database file sitting on one SD card is a fragile place to keep years of data. Keeping copies on a home NAS is one common approach.
- Leaving the database open. Many database servers are meant to be reached only from trusted places. Using default credentials or exposing the port to the internet is a well-known way to lose data. Keep it on the local network, use proper passwords and limit access.
- Storing secrets or personal data carelessly. If a database holds anything sensitive, think about data encryption and who can read the files.
- Mixing everything in one blob. Even in a flexible store, deciding on consistent field names will save pain later.
Changing your mind
Because small projects change, it helps to keep data access in one part of your code. If your storage logic lives in a few functions, swapping the database later is a contained job. Exporting to a plain format such as CSV or JSON now and then also gives you a way out that does not depend on any product.
The best database for a small project is usually the one you understand, can back up and can keep running without much attention.