Thuta Learning
IntermediateData & Databasesbeginner

SQLite and Embedded Databases

What you'll walk away with

  • Explain the core ideas behind SQLite and Embedded Databases
  • Read the diagram/table and identify the shape of the data model, schema, or architecture
  • Explain how this concept or system choice applies to a real project

Build the mental model

SQLite is an embedded relational database - instead of a separate server process, it's a library linked directly into your application, reading and writing a single file on disk.

Application

Your application code calls into the SQLite library

SQLite Library

Runs in-process and handles the queries

Database File

Reads and writes an ordinary file on disk directly - no server involved

  • mobile app local storage
  • desktop applications
  • small command-line tools
  • local development and automated tests
  • edge / offline-first scenarios

A server database like PostgreSQL or MySQL runs as its own long-lived process, and applications connect to it as clients over the network - built for multi-user, production-scale workloads.

Resist Absolute Claims

Avoid claims like "SQLite can't handle real workloads" - modern SQLite architectures have grown genuinely sophisticated, and the right choice depends on your concurrency and deployment needs.

Embedded Database
A database that runs as a library linked directly into your application, reading and writing data in the same process, without a separate server process.
text
EMBEDDED VS SERVER DATABASE MODEL
---------------------------------
EMBEDDED (SQLite)
Application -> SQLite Library -> Database File
              (in-process, single file, no server)

SERVER (PostgreSQL / MySQL)
Application -> Network -> Database Server -> Disk
              (separate process, many clients connect)

Connect it to a real scenario

Reach for SQLite when your application owns its own local storage without needing concurrent access - a mobile local cache, desktop settings, or a test suite.

Reach for a server database like PostgreSQL or MySQL once multiple independent apps, services, or users need concurrent network access to the same data.

Some projects sit in between - it's fine to start with SQLite and migrate later once real concurrent access becomes a requirement.

The runnable example below takes an application's needs and suggests an embedded or server-based starting point.

Try the working example

javascript
function suggestDatabaseArchitecture(profile) {
  const {
    isMobileOrDesktopApp,
    needsMultipleConcurrentWriters,
    needsNetworkAccess,
    isSimpleLocalTool,
  } = profile;

  if (needsMultipleConcurrentWriters || needsNetworkAccess) {
    return "Server-based database (e.g., PostgreSQL/MySQL) - a reasonable starting point.";
  }
  if (isMobileOrDesktopApp || isSimpleLocalTool) {
    return "Embedded database (e.g., SQLite) - a reasonable starting point.";
  }
  return "Depends on further requirements - consider concurrency and deployment model.";
}

console.log("Mobile note-taking app:", suggestDatabaseArchitecture({
  isMobileOrDesktopApp: true, needsMultipleConcurrentWriters: false,
  needsNetworkAccess: false, isSimpleLocalTool: false,
}));

console.log("Multi-user SaaS backend:", suggestDatabaseArchitecture({
  isMobileOrDesktopApp: false, needsMultipleConcurrentWriters: true,
  needsNetworkAccess: true, isSimpleLocalTool: false,
}));

console.log("Local CLI test fixture:", suggestDatabaseArchitecture({
  isMobileOrDesktopApp: false, needsMultipleConcurrentWriters: false,
  needsNetworkAccess: false, isSimpleLocalTool: true,
}));
You should see
Mobile note-taking app: Embedded database (e.g., SQLite) - a reasonable starting point.
Multi-user SaaS backend: Server-based database (e.g., PostgreSQL/MySQL) - a reasonable starting point.
Local CLI test fixture: Embedded database (e.g., SQLite) - a reasonable starting point.

Both the mobile app and the local test fixture get an embedded suggestion, while the SaaS backend needing concurrent writers and network access gets a server-based one.

5-minute try-it

Extend suggestDatabaseArchitecture with an isReadHeavyAnalytics flag that, when true, also suggests a server-based database.

One important caution

Treating "SQLite can't handle real workloads" as a blanket rule

Choosing SQLite even when multiple processes or machines need concurrent write access to the same data

SQLite: About SQLiteHow Databases Work

Easy traps

  • Treating "SQLite can't handle real workloads" as a blanket rule
  • Choosing SQLite even when multiple processes or machines need concurrent write access to the same data
  • This course teaches database concepts and the product landscape at a framework-neutral level -- for hands-on SQL syntax or PostgreSQL/MongoDB/Redis depth, continue to the SQL, PostgreSQL, MongoDB, or Redis tutorials.

Exercise

Extend suggestDatabaseArchitecture with an isReadHeavyAnalytics flag that, when true, also suggests a server-based database.

You'll know it worked when: Mobile note-taking app: Embedded database (e.g., SQLite) - a reasonable starting point. Multi-user SaaS backend: Server-based database (e.g., PostgreSQL/MySQL) - a reasonable starting point. Local CLI test fixture: Embedded database (e.g., SQLite) - a reasonable starting point. Both the mobile app and the local test fixture get an embedded suggestion, while the SaaS backend needing concurrent writers and network access gets a server-based one.

SQLite and Embedded Databases | Thuta Learning