PostgreSQL
Run, configure and use PostgreSQL, a powerful open source relational database and our default pick.
Beginner · about 10 hours · difficulty 2/5
Learn first: Writing SQL Queries
PostgreSQL is our recommended relational database. It is open source, standards-compliant, extremely reliable and has features that let one database cover many needs: JSONB columns, full-text search, arrays, geospatial data (PostGIS), and extensions such as pgvector for embeddings.
What to learn
- Install it locally (or run it in Docker) and use
psql:\l,\c,\dt,\d table. - Roles and permissions: create an application user that owns only its database, never connect your app as the superuser.
- Data types worth knowing:
text,integer/bigint,numericfor money,timestamptzfor time,uuid,jsonb,boolean. - Connection strings, SSL mode and how your driver connects.
- Backups with
pg_dumpand restoring withpg_restore, and why managed services (RDS, Cloud SQL, Neon, Supabase) are popular.
Why PostgreSQL
It handles workloads from a hobby app to large production systems, and skills transfer directly to managed Postgres offerings everywhere.
Pitfalls
- Using
timestampwithout time zone and then fighting time zone bugs. Prefertimestamptz. - Using floating point for money.
- Never testing restores. A backup you have not restored is a hope, not a backup.
You are ready to move on when you can create a database and app role, load a schema, take a dump and restore it into a fresh instance.
Key concepts
- psql command-line client
- Roles and privileges
- Data types: timestamptz, numeric, jsonb
- pg_dump and pg_restore
- Extensions (PostGIS, pgvector)
- Managed Postgres services
- Full-text search in Postgres
Other options for this step
- MySQL, SQLite and Other Engines: Know the other common relational engines and how they differ from PostgreSQL, in case your job uses one.
Mini project
Run PostgreSQL in Docker, create an app role with limited privileges, load your library schema, and script a nightly pg_dump that you verify by restoring into a second container.
Check yourself
Why should your application not connect to PostgreSQL as the postgres superuser?
Free resources
- PostgreSQL documentation (PostgreSQL)
- PostgreSQL Tutorial (postgresqltutorial.com)