๐Ÿ—ƒ๏ธ
๐Ÿ—ƒ๏ธ Working with Data ยท DATA-201 ยท Session 1 of 6

Where Data Lives

Almost every app is really about data โ€” storing it and getting it back. The first thing to understand is your options for where data lives, and when to reach for each.

โฑ 8 min read๐Ÿ“… Updated 2026-08-05๐Ÿ“Š Tables, charts & examples

Scratch almost any useful application and you find data underneath: users, posts, orders, settings, messages. A huge part of real development is persisting data (so it survives the program ending) and retrieving it (so you can use it). Before the how, you need the map: what your options are for where data lives, and when to reach for each. This session frames the whole subject.

The storage spectrum

Data can live in a few places, trading simplicity for power as you move along the spectrum.

WhereGood forTrade-off
In memory (variables)Data while the program runsGone when it stops
A file (JSON/CSV)Small amounts, simple appsSlow/awkward to search at scale
A small storeRecords that persist, simplyNot built for huge data
A databaseLots of data, fast queriesMore to set up and learn

The key distinction is <b>persistence</b>: in-memory data vanishes when the program ends, while files and databases keep it. For small projects, a file or a tiny store is perfect; as data grows and you need fast searching, relationships and reliability, you move to a database. Start simple, upgrade when you feel the limits.

Match the tool to the data

The right choice depends on how much data you have and what you need to do with it.

๐ŸŽฏ
Don't reach for a database until a file isn't enough. Beginners often think 'real apps need a database' and add heavy machinery for a project holding a hundred records - that's over-engineering. A JSON file (or a small store like larzstore) comfortably handles small-to-moderate data and is far simpler. You move to a database when you genuinely need what it offers: lots of data, fast searching and filtering, relationships between things, and many users reading and writing at once safely. Recognising when you've outgrown a file is the real skill - start with the simplest thing that works.

The foundation of most apps

  • Most apps are about data - persisting it and retrieving it.
  • In-memory data vanishes on exit; files and databases persist it.
  • Start simple - a file or small store handles small-to-moderate data well.
  • Move to a database when you need scale, fast queries, relationships, or many users.

๐ŸŽฏ Key takeaways

  • Most useful apps are fundamentally about storing data so it lasts and retrieving it to use.
  • In-memory data disappears when the program ends; files and databases persist it.
  • Start simple - a JSON file or small store handles small-to-moderate data well and is far simpler than a database.
  • Move to a database when you genuinely need scale, fast queries, relationships, or safe multi-user access.

Frequently asked

When should I use a file, and when do I actually need a database?

Use a file when your data is small-to-moderate, your access patterns are simple, and one program (or one user at a time) is reading and writing it; reach for a database when you outgrow those conditions in specific, recognisable ways. A file (like JSON or CSV, or a small file-backed store) is perfectly good and much simpler when: you have a modest amount of data (hundreds or low thousands of simple records, not millions); you mostly load it, work with it, and save it, without needing to constantly search or filter huge amounts efficiently; and you don't have many users or processes writing to it simultaneously. For a personal tool, a small app, a prototype, or storing settings and modest collections, a file is often the right, sensible choice, and adding a database would be unnecessary complexity - a common over-engineering mistake beginners make because they think real apps must have databases. You genuinely need a database when you hit what files handle poorly: large amounts of data (where loading it all into memory or scanning it becomes slow); the need to search, filter, and sort efficiently across lots of records (databases are built and optimised for exactly this, with indexes making queries fast); relationships between different kinds of data (users and their orders and those orders' items) that you need to query across; and, importantly, concurrent access - many users or processes reading and writing at the same time safely, which files handle badly (simultaneous writes can corrupt a file) but databases are designed for. Reliability and integrity features (transactions, ensuring data stays consistent) also come with databases. So the decision isn't about prestige ('real apps use databases') but about need: start with a file because it's simpler, and move to a database when you feel a specific limit - too much data, too-slow searching, real relationships to query, or multiple simultaneous users. Recognising that transition point is the skill. Many successful small applications run happily on files or lightweight stores, and many large ones need robust databases; match the tool to your actual data volume, query needs, and concurrency, rather than reaching for the heavy option by default. When in doubt for a small project, begin with a file, and let real limits - not assumptions - tell you when it's time to upgrade.

If in-memory data disappears when the program ends, how do apps remember anything?

They remember by saving their data to persistent storage - a file or a database - and loading it back when they start, which is exactly the persistence this subject is about. Here's the key distinction: while a program runs, its data lives in memory (RAM) in variables, lists, dictionaries, and objects - fast to work with, but volatile, meaning it's completely gone the moment the program stops or the computer loses power (as you learned in how computers work, RAM doesn't survive a shutdown). So if an app only kept data in memory, it would forget everything every time it closed - useless for anything that needs to remember. The solution is to persist the data: at appropriate moments (when something changes, or when the program is about to end), the app writes its data out to somewhere permanent - a file on disk, or a database - where it survives independently of the program running. Then, when the app starts up again, it reads that data back from the file or database into memory, restoring its state, and carries on as if it never stopped. That save-and-load cycle is how every app that remembers things works: your notes app saves your notes to storage and loads them when you reopen it; a game saves your progress and restores it; a web app stores users and their data in a database that persists whether the app is running or not. The pattern you saw in earlier projects - load data at start, save it after changes, using files - is exactly this persistence in action, and larzstore packages it up (records that automatically save to a JSON file). Databases do the same job at larger scale and with more power. So apps don't remember by keeping things in memory (they can't); they remember by continually moving data between fast-but-temporary memory (where they work with it) and slow-but-permanent storage (where it lasts). Understanding this cycle - work in memory, persist to storage, load back on start - demystifies how applications maintain state across runs, and it's the foundation of everything in working with data. The whole craft is about doing that persistence and retrieval well: reliably, efficiently, and in a way that scales as your data grows.

Session 1 of 6 complete

Next up: Storing and Loading Data

Continue to Session 2 โ†’

Related lessons

More in this course

Course home → · Browse all courses →