---
title: "Cracking PostgreSQL Interview Questions"
description: "Interview preparation for the transactional side of PostgreSQL, organized around five areas: data modeling, indexes, views, roles and functions."
url: "https://swe.quest/articles/cracking-postgresql-interview-questions-e9efeda89524a92a"
canonical: "https://supabase.com/blog/cracking-postgres-interview"
source: "Supabase"
published: "2021-02-27"
difficulty: "medium"
kind: "How-to"
reading_minutes: 6
tags: ["postgres","sql","databases","identity-auth","engineering-culture"]
---

# Cracking PostgreSQL Interview Questions

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2021-02-27, 6 min read, How-to. Original: [https://supabase.com/blog/cracking-postgres-interview](https://supabase.com/blog/cracking-postgres-interview)

## Summary

Interview preparation for the transactional side of PostgreSQL, organized around five areas: data modeling, indexes, views, roles and functions. It covers modeling 1-1, 1-M and M-M relationships with foreign keys and join tables, and using rich types like JSONB, enums and timestamptz. On performance and access control it explains B-tree and other index types, comparing plans with EXPLAIN ANALYZE, auto-updatable views, GRANTs to PUBLIC, and row level security policies. It also shows PL/pgSQL trigger functions for auto-updating timestamps, advises thinking in sets rather than loops, and introduces CTEs, all with short SQL examples.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [SQL](https://swe.quest/tags/sql.md) (Languages)
- [Databases](https://swe.quest/tags/databases.md) (Data & databases)
- [Identity & auth](https://swe.quest/tags/identity-auth.md) (Security)
- [Engineering culture](https://swe.quest/tags/engineering-culture.md) (Engineering organization)

## Prerequisites

- basic SQL ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- relational database concepts ([easy posts on Databases](https://swe.quest/tags/databases.md?difficulty=easy))

## Keywords

PostgreSQL, PL/pgSQL, Row Level Security, EXPLAIN ANALYZE, JSONB, Supabase

## Related posts

- [PostgREST v10: EXPLAIN and Improved Relationship Detection](https://swe.quest/articles/postgrest-v10-explain-and-improved-relationship-detection-44878c605b0df57d.md): Supabase · 2022-08-19 · Medium · 7 min read · PostgreSQL, API design, Performance engineering
  PostgREST v10 adds HTTP-level EXPLAIN support: requests with the \`application/vnd.pgrst.plan\` media type, or supabase-js's \`explain()\` transform, return the PostgreSQL execution plan for reads, writes and RPC, which helps verify that RLS policies are applied and gives you the pg\_stat\_statements query identifier.
- [Higher-level CRUD Abstraction for Postgres RLS](https://swe.quest/articles/higher-level-crud-abstraction-for-postgres-rls-90207e4bb081ead2.md): Neon · 2024-11-13 · Medium · 3 min read · PostgreSQL, Identity & auth, TypeScript
  Postgres Row-Level Security requires separate USING and WITH CHECK policies per operation, which gets repetitive for CRUD apps.
- [SQL or NoSQL? Why not use both (with PostgreSQL)?](https://swe.quest/articles/sql-or-nosql-why-not-use-both-with-postgresql-98c239e2ff7e761c.md): Supabase · 2022-11-24 · Medium · 12 min read · PostgreSQL, SQL, Databases
  PostgreSQL's JSONB columns let an app store nested, variable-length data (here, a daily food, water and exercise log) as a single row instead of spreading it across several normalized tables, while keeping SQL available for analysis.
- [What is new in PostgREST v11.1?](https://swe.quest/articles/what-is-new-in-postgrest-v11-1-2bc974a578068114.md): Supabase · 2023-07-12 · Medium · 5 min read · PostgreSQL, API design, Consistency models, SQL
  PostgREST 11.1 lets impersonated JWT roles (anon, authenticated, service\_role) carry Postgres settings via ALTER ROLE ...
- [Postgres Roles: What to Know Before You Begin](https://swe.quest/articles/postgres-roles-what-to-know-before-you-begin-a6df1c63fd1f0301.md): Neon · 2024-07-12 · Medium · 12 min read · PostgreSQL, Identity & auth, Schema migrations
  Postgres has no separate users and groups, only roles: a role with LOGIN behaves like a user, and a role without it acts as a group whose privileges pass to its members through inheritance.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
