Where data lives

Databases and storage

Almost every app keeps something: accounts, orders, messages, settings. A database is the program that stores that data safely, finds it again quickly, and keeps it correct when many people change it at the same time.

There are two big families. Relational databases keep data in tables that link to each other and are queried with SQL; document and key-value stores (NoSQL) keep flexible records instead. Most products need one main database, sometimes a cache or an analytics store beside it, and somewhere to put files.

25 terms · 5 comparisons · prices checked September 2026

25 terms, click any to open

The two families

Relational database

Concept
A database that keeps data in tables of rows and columns, like linked spreadsheets, and lets you ask questions across them in SQL.

Each table holds one kind of thing (users, orders, products) and every row has the same columns. Rows point at rows in other tables through keys, so an order stores a customer id instead of a copy of the customer, and a query can join the tables back together in one step.

The structure (the schema) is declared up front and enforced by the database, which is what makes relational databases good at keeping data consistent. PostgreSQL, MySQL, SQLite, SQL Server and Oracle are all relational.

Also called: SQL database, RDBMS

Open Relational database as a page

NoSQL

Concept
An umbrella name for databases that do not use relational tables, storing data as documents, key-value pairs, wide columns or graphs instead.

Document stores such as MongoDB and Firestore keep each record as a JSON-like document that can nest lists and objects. Key-value stores such as Redis map a key straight to a value. Wide-column and graph databases cover more specialised shapes of data.

NoSQL databases usually let each record have its own shape and are built to spread across many machines. The trade-off is that joins, strict schemas and guarantees across many records are weaker or left to the application, although most now offer transactions in some form.

Also called: non-relational database, document database

Open NoSQL as a page

Relational (SQL)

SQLite

DatabaseFree
A complete SQL database that lives in a single file inside your app, with no server to install or run.

SQLite is a library that an app links in. The whole database, tables, indexes and all, is one file on disk, and reading it is a function call rather than a trip over the network. It ships inside Android, iOS, every major browser and countless desktop apps, which makes it the most widely deployed database there is.

It speaks standard SQL, supports transactions and handles databases far larger than most apps will ever need. Its limit is concurrency: many readers can work at once, but only one writer at a time. Extensions add full-text search (FTS5), JSON functions and vector search (sqlite-vec), and services such as Turso host it for web apps.

Pros

  • Zero setup: no server, no user accounts, no port to open
  • Very fast reads, because there is no network hop
  • One file is easy to copy, back up and ship with an app
  • Public domain, so free for any use
  • Among the most thoroughly tested software in the world

Cons

  • One writer at a time, so heavy multi-user writes queue up
  • Lives on one machine; sharing it between servers needs extra tooling
  • Fewer data types, and no built-in users, roles or row-level permissions

Pick it when

  • Mobile, desktop and offline-first apps that keep data on the device
  • Small websites, prototypes and internal tools with modest write traffic
  • Local caches, test databases and single-user tools

Skip it when

  • Many users write at the same time through different servers
  • You need database-level roles and permissions for each user

What it costs · Free

Free and public domain. Hosted versions such as Turso have their own free tiers.

Approximate, checked September 2026.

Also called: sqlite3

Open SQLite as a pageOfficial site (opens in a new tab)

PostgreSQL

DatabaseOpen source
A powerful open-source relational database that runs as a server and handles everything from a small site to very large, busy products.

PostgreSQL stores data in tables, speaks rich SQL and keeps data correct under heavy concurrent use with transactions and strict constraints. Beyond the basics it has JSONB columns for document-style data, arrays, full-text search, window functions and row level security.

Its extension system is a big part of its appeal: PostGIS adds maps and geography, pgvector adds AI vector search, pg_cron adds scheduled jobs. Supabase, Neon, AWS RDS, Google Cloud SQL and Azure all offer it as a managed service, so you rarely have to run the server yourself.

Pros

  • Very reliable, with strong guarantees that data stays consistent
  • Handles relational and JSON data in the same database
  • Huge extension ecosystem (PostGIS, pgvector, pg_cron)
  • Permissive open-source licence, and every major cloud hosts it

Cons

  • Needs a running server, plus care for backups, upgrades and tuning
  • Each connection costs memory, so serverless apps usually need a connection pooler
  • More to learn than SQLite for a small project

Pick it when

  • Almost any web or mobile backend with users, orders or accounts
  • Data with clear relationships that must stay correct
  • You want one database that can grow with the product

Skip it when

  • The data lives on a single device (SQLite fits better)
  • The main job is analytics over billions of events (look at ClickHouse)

What it costs · Open source

Free to run yourself. Managed hosting runs from free tiers (Supabase, Neon) to roughly $15 to $60 a month for a small dedicated server.

Approximate, checked September 2026.

Also called: Postgres, psql

Open PostgreSQL as a pageOfficial site (opens in a new tab)

MySQL and MariaDB

DatabaseOpen source
One of the most used relational databases on the web, behind WordPress and a large share of PHP sites. MariaDB is a community fork that works almost the same way.

MySQL is a relational database server owned by Oracle, with a free, open-source Community Edition. It is fast for typical web reads and writes, easy to host, and supported by practically every shared host and cloud. MariaDB was forked from it by its original authors and stays largely compatible.

Compared with PostgreSQL it has historically been simpler to get running, with a smaller feature set: fewer data types, fewer extensions and a less strict default mode. Tools such as PlanetScale and Vitess spread it across many machines.

Pros

  • Available on almost every host, including cheap shared hosting
  • Fast for everyday web workloads, and very well understood
  • Huge community, tutorials and admin tools such as phpMyAdmin

Cons

  • Fewer advanced features and extensions than PostgreSQL
  • Oracle's ownership pushes some teams towards MariaDB or PostgreSQL
  • Looser defaults have historically let bad data slip in

Pick it when

  • WordPress, Laravel or other PHP stacks that expect it
  • Your host only offers MySQL
  • Scaling out with PlanetScale or Vitess

Skip it when

  • You need PostGIS, pgvector or row level security built in

What it costs · Open source

Community Edition and MariaDB are free. Managed hosting costs about the same as PostgreSQL.

Approximate, checked September 2026.

Also called: MySQL, MariaDB

Open MySQL and MariaDB as a pageOfficial site (opens in a new tab)

Document and key-value

MongoDB

DatabaseFree tier
A popular document database that stores each record as a JSON-like document instead of a row in a table.

In MongoDB a collection holds documents (stored as BSON, a binary form of JSON), and each document can contain nested objects and lists. A customer can carry their addresses inside the same document, so reading them needs no join. Queries, indexes and aggregation pipelines work on those document fields.

Documents in one collection do not have to share a shape, which makes early development quick. Multi-document transactions exist, but the design pushes you to keep related data together. MongoDB Atlas is the company's managed cloud; the Community Server is free to run yourself under the SSPL licence.

Pros

  • Flexible documents fit data that is naturally nested
  • Quick to start, with no schema to design up front
  • Scales across machines with sharding
  • Atlas adds hosted search, vector search and backups

Cons

  • Without schema validation, inconsistent data creeps in
  • Joining collections is clumsier than SQL joins
  • The SSPL licence is not accepted as open source by everyone

Pick it when

  • Content, catalogues or event data with varied, nested shapes
  • A JavaScript team that wants to think in JSON end to end

Skip it when

  • Highly relational data (orders, invoices, stock) that must stay consistent
  • You want standard SQL and its tooling

What it costs · Free tier

Community Server is free. MongoDB Atlas has a free 512 MB cluster, Flex clusters from about $8 a month (capped at $30), and dedicated clusters from roughly $60 a month.

MongoDB pricing (opens in a new tab)Approximate, checked September 2026.

Also called: Mongo

Open MongoDB as a pageOfficial site (opens in a new tab)

Cloud Firestore

DatabaseFree tier
Google's hosted document database, part of Firebase, that syncs data to phones and browsers in real time and keeps working offline.

Firestore stores documents in collections, and apps talk to it directly through the Firebase SDKs rather than through a server of your own. Listeners push every change to connected clients instantly, and the SDKs cache data so an app keeps working without a connection and syncs when it comes back.

Access is controlled by security rules that Google checks on every read and write. Billing is per operation: you pay for document reads, writes and deletes plus storage, so a screen that reads thousands of documents on every visit gets expensive. Queries are deliberately limited so that they always stay fast.

Pros

  • Real-time sync and offline support built into the SDKs
  • No servers to run, and it scales automatically
  • Works hand in hand with Firebase Auth, Functions and Hosting
  • Generous free daily quota for small apps

Cons

  • Per-read pricing can surprise you as traffic grows
  • Limited queries: no joins, and some filters need composite indexes
  • Data and rules are tied to Google Cloud, which makes leaving harder

Pick it when

  • Chat, live dashboards and collaborative apps that need instant updates
  • Mobile apps that must work offline
  • Small teams that want no backend servers at all

Skip it when

  • Reporting, complex filters or relational data, where SQL fits better
  • Read-heavy pages where per-read billing would add up

What it costs · Free tier

Free daily quota (1 GiB stored, 50,000 reads, 20,000 writes and 20,000 deletes a day). Beyond that, pay per operation on the Blaze plan, typically a few cents per 100,000 reads.

Cloud Firestore pricing (opens in a new tab)Approximate, checked September 2026.

Also called: Firestore, Firebase database

Open Cloud Firestore as a pageOfficial site (opens in a new tab)

Redis

DatabaseOpen source
An in-memory key-value store that answers in well under a millisecond, used for caching, sessions, rate limits, queues and live counters.

Redis keeps data in memory and maps keys to values: strings, lists, sets, sorted sets, hashes and streams. Because nothing waits on a disk, reads and writes are extremely fast, which makes it the usual choice for a cache in front of a slower database, for session storage and for counting things such as requests per minute.

It can save to disk, but it is usually a fast helper beside a main database rather than the only copy of important data. A 2024 licence change led to Valkey, a fully open-source fork under the Linux Foundation, and Redis later added an AGPL option. Upstash and Redis Cloud host it for you.

Pros

  • Extremely fast, with rich data structures
  • Simple to use for caching, sessions and rate limiting
  • Built-in pub/sub, streams and keys that expire on their own

Cons

  • Memory costs more than disk, so large datasets get expensive
  • Not a replacement for a durable main database
  • Licence changes mean checking which flavour (Redis or Valkey) you run

Pick it when

  • Caching slow queries or API responses
  • Rate limits, sessions, leaderboards and short-lived data
  • Simple job queues and real-time counters

Skip it when

  • It would be the only copy of data you cannot afford to lose

What it costs · Open source

Free to run yourself. Redis Cloud has a free 30 MB database and paid plans from about $5 a month; Upstash bills per request.

Redis pricing (opens in a new tab)Approximate, checked September 2026.

Also called: Valkey, key-value store, cache

Open Redis as a pageOfficial site (opens in a new tab)

ClickHouse

DatabaseOpen source
An open-source columnar database built to add up, count and group billions of rows in a fraction of a second, for analytics and logs.

Ordinary databases store a table row by row, which suits looking up one order. ClickHouse stores it column by column and compresses each column, so a question such as page views per day for a year reads only the two columns it needs. That design makes aggregate queries over huge event tables very fast.

It is built for inserting data in batches and querying it, not for updating single rows many times a second, so it usually sits beside a normal database: the app writes orders to PostgreSQL and streams events to ClickHouse. You can run it yourself for free or use ClickHouse Cloud.

Pros

  • Very fast aggregations over billions of rows
  • Excellent compression keeps storage cheap
  • Speaks SQL, so analysts need no new language

Cons

  • Poor fit for frequent single-row updates and deletes
  • Joins and transactions are more limited than in PostgreSQL
  • Running your own cluster takes real operational skill

Pick it when

  • Web analytics, product events, logs and metrics
  • Dashboards that group and count very large tables

Skip it when

  • Your main app data (users, orders, carts)
  • The data fits comfortably in PostgreSQL, which handles modest analytics too

What it costs · Open source

Free to self-host. ClickHouse Cloud has a free trial, then Basic from about $67 a month and Scale from about $500 a month.

ClickHouse pricing (opens in a new tab)Approximate, checked September 2026.

Also called: OLAP database, columnar database

Open ClickHouse as a pageOfficial site (opens in a new tab)

In the browser

IndexedDB

APIFree
A database built into every modern browser, so a web app can keep large amounts of structured data on the visitor's device and work offline.

IndexedDB stores JavaScript objects (files and blobs included) in object stores with indexes, inside the browser and separately for each website. It holds far more than localStorage, often hundreds of megabytes or more depending on the browser and free disk space, and it never freezes the page because every operation is asynchronous.

Its raw API is event-based and clumsy, so most apps use a wrapper such as Dexie.js or idb. Data stays in that one browser on that one device; syncing it anywhere else is up to the app. Browsers may clear it when storage runs low unless the site asks for persistent storage.

What it costs · Free

Free; it is part of the browser.

Approximate, checked September 2026.

Also called: browser database

Open IndexedDB as a pageOfficial site (opens in a new tab)

Dexie.js

LibraryOpen source
A small library that makes IndexedDB pleasant to use, with simple queries and live results that update the screen when data changes.

Dexie wraps the browser's IndexedDB in a promise-based API: declare tables and indexes once, then query with calls such as where('age').above(18). Its liveQuery and React hooks re-run a query whenever the data underneath changes, which suits offline-first apps.

The library is open source. Dexie Cloud is an optional service from the same team that adds sync between devices, sign-in and sharing.

What it costs · Open source

Dexie.js is free (Apache 2.0). Dexie Cloud sync starts free and is priced per user as an app grows.

Dexie.js pricing (opens in a new tab)Approximate, checked September 2026.

Also called: Dexie

Open Dexie.js as a pageOfficial site (opens in a new tab)

Talking to a database

ORM

Concept
A library that lets code work with database rows as ordinary objects in its own language, instead of writing SQL strings by hand.

An ORM maps tables to classes or types, so user.posts can fetch a user's posts and a save call writes changes back. Most also manage migrations and give typed results. Examples: Prisma and Drizzle in TypeScript, SQLAlchemy and Django's ORM in Python, Hibernate in Java, Room on Android.

The convenience has a cost: generated queries can be slow or wasteful (the classic N+1 problem, one query per item in a list), and complex reports are often easier in plain SQL. Query builders sit in between, keeping the shape of SQL with type safety.

Also called: object-relational mapper, query builder

Open ORM as a page

Prisma

LibraryOpen source
A TypeScript ORM where you describe your data in one schema file and get a fully typed database client and migrations generated from it.

You write models in schema.prisma, run a command, and Prisma generates a client whose every query and result is typed, so a misspelt field fails at compile time. Prisma Migrate turns schema changes into SQL migration files. It supports PostgreSQL, MySQL, SQLite, SQL Server, CockroachDB and MongoDB.

The ORM is open source. The company also sells Prisma Postgres (a hosted database), connection pooling and caching, and app hosting, all optional.

Pros

  • Excellent type safety and editor autocomplete
  • One readable schema file as the source of truth
  • Mature migrations and a visual data browser (Prisma Studio)

Cons

  • Its own schema language and query API to learn instead of SQL
  • Some complex queries still need raw SQL
  • Historically heavier than thin query builders on serverless and edge runtimes

Pick it when

  • TypeScript backends that want strong types with little effort
  • Teams that prefer a declarative schema to hand-written SQL

Skip it when

  • You want queries that read like SQL (Drizzle or plain SQL)
  • Tiny serverless functions where bundle size matters

What it costs · Open source

Prisma ORM is free. Prisma Postgres has a free tier (about 100,000 operations and 500 MB a month) and paid plans from about $10 a month.

Prisma pricing (opens in a new tab)Approximate, checked September 2026.

Also called: Prisma ORM

Open Prisma as a pageOfficial site (opens in a new tab)

Drizzle ORM

LibraryOpen source
A lightweight TypeScript ORM whose queries look like SQL, with full type safety and no heavy runtime.

Tables are defined in TypeScript files, and queries use functions that mirror SQL (select, from, where, join), so anyone who knows SQL can read them. Types flow from the table definitions into every result. drizzle-kit generates and runs migrations from those definitions.

It has no separate engine and very few dependencies, so it runs well in serverless and edge environments such as Cloudflare Workers and Vercel Edge. It supports PostgreSQL, MySQL and SQLite, including hosted flavours such as Neon, Turso and PlanetScale.

Pros

  • Queries read like SQL, so there is little new to learn
  • Small and fast, good on edge and serverless runtimes
  • Strong types without a code generation step

Cons

  • Younger than Prisma, with fewer guides and integrations
  • You need to know SQL to use it well

Pick it when

  • TypeScript apps on serverless or edge runtimes
  • Developers who like SQL and want types on top of it

Skip it when

  • A team that would rather not think in SQL at all

What it costs · Open source

Free (Apache 2.0).

Approximate, checked September 2026.

Also called: Drizzle, drizzle-kit

Open Drizzle ORM as a pageOfficial site (opens in a new tab)

sqlx

LibraryOpen source
A Rust library for talking to SQL databases that checks your queries against the real database while the code compiles.

sqlx is asynchronous (it runs on Tokio) and supports PostgreSQL, MySQL and SQLite. Its query macros connect to a development database, or read a saved snapshot, at build time and confirm that each query is valid and that the Rust types match the columns, so a renamed column breaks the build instead of the app.

It is not an ORM: you write plain SQL and get typed rows back. It also ships a migration runner.

What it costs · Open source

Free (MIT or Apache 2.0).

Approximate, checked September 2026.

Also called: SQLx

Open sqlx as a pageOfficial site (opens in a new tab)

better-sqlite3

LibraryOpen source
The most popular way to use SQLite from Node.js, with a simple synchronous API that is also very fast.

better-sqlite3 binds the SQLite C library into Node. Queries run synchronously, which sounds wrong for Node but suits SQLite, because each call finishes in microseconds and there is no network to wait on. It supports transactions, prepared statements and loading extensions such as sqlite-vec.

As a native module it has to match the Node version and platform it runs on, and it cannot run on edge runtimes. Newer Node versions also include a built-in node:sqlite module.

What it costs · Open source

Free (MIT).

Approximate, checked September 2026.

Open better-sqlite3 as a pageOfficial site (opens in a new tab)

PostgREST

ToolOpen source
A small server that turns a PostgreSQL database straight into a REST API, so apps can read and write tables over HTTP without a custom backend.

Point PostgREST at a database and every table, view and function becomes an endpoint: a request such as GET /orders?status=eq.paid returns JSON. It passes the caller's role to PostgreSQL, so permissions come from database roles and row level security rather than from code in the API.

Supabase uses PostgREST for its automatic API, which is why its client library can query tables directly. The flip side is that a table without proper policies can be read by anyone holding the public key.

What it costs · Open source

Free (MIT).

Approximate, checked September 2026.

Open PostgREST as a pageOfficial site (opens in a new tab)

Keeping data correct

Migrations

Concept
Numbered scripts that change a database's structure step by step, so every copy of the database (yours, a teammate's, production) ends up the same.

Instead of editing tables by hand, each change (add a column, create an index, rename a table) goes into a migration file that is committed with the code. A tool records which migrations a database has already run and applies only the new ones, in order.

Prisma Migrate, drizzle-kit, the Supabase CLI, Django, Laravel, Flyway and Liquibase all work this way. A migration that rewrites a big table can lock it, so large changes are usually split into several safe steps.

Also called: schema migrations, database migrations

Open Migrations as a page

Indexes

Concept
A sorted lookup structure a database keeps beside a table, like the index at the back of a book, so it can find rows without reading every one.

Without an index, finding orders by customer means scanning the whole table. With an index on customer_id the database jumps straight to the matching rows. A composite index covers several columns in a set order, and a unique index doubles as a rule that no two rows may share a value.

Indexes are not free: each one takes storage and slows inserts and updates a little. The EXPLAIN command shows whether a query actually uses one. Adding the right index is often the single biggest speed-up for a slow page.

Also called: database index, B-tree, composite index

Open Indexes as a page

Transactions and ACID

Concept
A way to group several database changes so that all of them happen or none do, which is how money, stock and orders stay correct.

Placing an order might insert the order, reduce stock and record a payment. Inside a transaction, a failure halfway rolls everything back, so stock is never reduced for an order that does not exist. ACID names the guarantees: atomic (all or nothing), consistent (rules hold), isolated (concurrent work does not mix) and durable (committed means saved).

Isolation levels decide how much concurrent transactions can see of each other's work. Relational databases are built around transactions; many NoSQL stores offer them in narrower forms.

Also called: ACID, database transaction, rollback

Open Transactions and ACID as a page

Row Level Security (RLS)

Concept
A PostgreSQL feature that decides, row by row, which records each user may see or change, enforced inside the database itself.

With RLS switched on, every query against a table is filtered by policies such as 'a user can read orders whose user_id is their own id'. Because the rule lives in the database, it holds on every path in: the app, an admin script or an automatic API.

It matters most on platforms such as Supabase, where apps query tables directly with a public key. A table with RLS switched off, or with a policy that simply says true, is open to anyone who has that key, so every table's policies deserve a review.

Also called: RLS, row-level security, policies

Open Row Level Security (RLS) as a page

Triggers and database functions

Concept
Code that runs inside the database, either automatically when rows change (a trigger) or when an app calls it by name (a function).

A trigger can stamp updated_at on every edit, write an audit row, or create follow-up records when an order arrives. A database function bundles several steps, such as checking and reducing stock, into one call that runs as a single transaction, which avoids race conditions between two buyers.

In PostgreSQL these are usually written in SQL or PL/pgSQL, and Supabase exposes functions to apps as RPC calls. Logic that lives in the database is powerful but easy to forget, so it belongs in migrations and deserves documentation.

Also called: stored procedures, RPC, PL/pgSQL

Open Triggers and database functions as a page

pg_cron

ToolOpen source
A PostgreSQL extension that runs SQL on a schedule, such as a nightly clean-up, inside the database itself.

pg_cron uses the same schedule syntax as Unix cron, so '0 1 * * *' runs a job at 1 a.m. every day. Jobs are plain SQL or calls to database functions, and their history is kept in a table. Supabase, AWS RDS, Google Cloud SQL and Azure support it.

It suits work that only touches the database (archiving, rollups, expiring rows). Jobs that call outside services are usually better in a queue or a scheduled function. Schedules run in UTC unless configured otherwise, which matters for daily jobs in other time zones.

What it costs · Open source

Free (PostgreSQL licence).

Approximate, checked September 2026.

Also called: pg cron

Open pg_cron as a pageOfficial site (opens in a new tab)

Files

Object storage

Concept
Cheap, practically unlimited storage for files such as images, videos and backups, kept in buckets and fetched by URL rather than stored in the database.

Each file is an object with a key (its path), the bytes and some metadata, inside a bucket. Apps usually upload through signed URLs, so the browser sends the file straight to storage, and serve files publicly or through short-lived links. The database keeps only the key.

Amazon S3 set the standard API and most others speak it too: Cloudflare R2, Google Cloud Storage, Backblaze B2, Supabase Storage. Prices are per gigabyte stored plus, on many providers, per gigabyte downloaded (egress), which is where bills tend to grow.

Also called: S3, buckets, blob storage, file storage

Open Object storage as a page

Side by side

Differences

How the options in this area compare on the questions that usually decide the choice.

Both are relational and both speak SQL. The real difference is where they run: SQLite is a file inside your app, PostgreSQL is a server your app connects to.

CompareSQLitePostgreSQL
What it isA library; the database is one fileA database server you connect to
SetupNone, it ships with the appInstall a server or use a managed host
Many users writing at onceOne writer at a timeBuilt for heavy concurrent writes
Where it runsOn the device or one serverAnywhere, shared by many app servers
Users and permissionsNone built inRoles and row level security
ExtrasFTS5 search, JSON, sqlite-vecJSONB, PostGIS, pgvector, pg_cron
CostFreeFree to run; managed plans from free tiers up
Typical homePhones, desktop apps, small sitesWeb and mobile backends of any size

How to choose

  • Pick SQLite for data that lives on one device, for prototypes, and for small sites with few writers.
  • Pick PostgreSQL when many users write from many places, or when you need roles and row-level rules.
  • Starting on SQLite and moving to PostgreSQL later is common, because both speak SQL.

The two most popular open-source relational databases. Either will run a typical web app well; the differences show up at the edges.

ComparePostgreSQLMySQL
FeaturesVery rich: JSONB, arrays, extensionsSolid core, fewer advanced features
StrictnessStrict about data by defaultStricter now, looser historically
ExtensionsPostGIS, pgvector, pg_cron and moreFew; features arrive with new versions
Row-level permissionsRow level security built inNot built in
HostingEvery cloud, Supabase, NeonEvery cloud, shared hosts, PlanetScale
Home turfModern JavaScript and Python stacksWordPress, PHP and Laravel
LicencePostgreSQL licence (permissive)GPL, owned by Oracle

How to choose

  • Pick PostgreSQL for new projects that may need JSON, geography, vector search or row-level rules.
  • Pick MySQL (or MariaDB) for WordPress and PHP stacks, or when your host offers nothing else.

SQL vs NoSQL: PostgreSQL vs MongoDB vs Firestore

Open as a page: SQL vs NoSQL: PostgreSQL vs MongoDB vs Firestore

Tables or documents is a choice that shapes how you model everything. Here is a SQL database next to the two document databases it is most often weighed against.

ComparePostgreSQLMongoDBFirestore
Data shapeTables with a fixed schemaFlexible JSON-like documentsDocuments in collections
RelationshipsJoins across tablesEmbed data, or look it upCopy data around; no joins
ConsistencyStrong, with full transactionsStrong per document, transactions availableStrong, with limited transactions
Live updatesThrough add-ons such as Supabase RealtimeChange streamsBuilt in, pushed to every client
Works offline on devicesNoNoYes, in the SDKs
Query powerFull SQL, good for reportsRich queries and aggregationsSimple queries only
You pay forServer size or planCluster size or planEach read, write and delete
Best forMost apps with users and ordersVaried, nested dataLive, offline-first mobile apps

How to choose

  • Pick PostgreSQL when data has relationships and must stay correct, which covers most business apps.
  • Pick MongoDB when records are naturally nested and vary in shape.
  • Pick Firestore for mobile or live apps that need instant sync and offline support without running servers.

PostgreSQL is built for running an app (many small reads and writes); ClickHouse is built for analysing one (a few enormous reads). Plenty of products use both.

ComparePostgreSQLClickHouse
Built forTransactions (OLTP)Analytics (OLAP)
StorageRow by rowColumn by column, compressed
Typical queryFetch or update one orderCount events per day over a year
Updates and deletesCheap and frequentExpensive, best avoided
Adding up billions of rowsSlow without extra workSeconds or less
TransactionsFull ACIDLimited

How to choose

  • Keep users, orders and anything that changes in PostgreSQL.
  • Send events, logs and metrics to ClickHouse once analytics queries start slowing PostgreSQL down.

The two most used TypeScript ORMs. Both give you typed queries and migrations; they differ in how close they stay to SQL.

ComparePrismaDrizzle
Schema lives inschema.prisma, its own languageTypeScript files
Query styleObject API: findMany, includeSQL-like: select, where, join
TypesGenerated by a build stepInferred directly, nothing to generate
WeightHeavier, though improvingVery light
Edge and serverlessSupported, with more setupWorks out of the box
MigrationsPrisma Migratedrizzle-kit
Easiest forPeople who would rather avoid SQLPeople who already know SQL

How to choose

  • Pick Prisma for the smoothest typed experience and one readable schema.
  • Pick Drizzle for edge runtimes, small bundles, or queries that look like SQL.

Crafted in the dark. Shipped to the world.

Tell us what you are building. You get a private project space with a proposal and a line-by-line quote within a day.