Choosing the Right Database
There is no best database, only a good match. Ask:
- Is the data structured, with clear relationships and rules? Relational (PostgreSQL, MySQL, SQLite).
- Does it need strong transactions (money, stock, bookings)? Relational.
- Is it a simple lookup by key, very fast (sessions, caches)? Key-value.
- Are records varied and nested, changing often? Document.
- Is the main question "how are things connected" (friends of friends)? Graph.
- Is it a single-user app or small tool? SQLite: a whole database in one file, no server.
Most projects start with one relational database and add others only when a real need appears.
Examplepython
Quick check
Which database fits a mobile notes app that needs no server?
Your turn: write the code
Print the best fit for each need from: relational, key-value, document, graph, one per line, in this order: bank transfers, fast cache by key, social connections, product pages with varying fields.
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.