| BQ001 | What is a database? | Organized persistent data managed so it can be stored, queried, changed, protected, and recovered. | Separates the data itself from the software managing it. | “PostgreSQL.” PostgreSQL is a DBMS, not the data collection itself. | Database vs DBMS? | 00 — Start Here |
| BQ002 | What is a DBMS? | Software that manages databases, concurrency, queries, security, storage, and recovery. | The DBMS owns mechanisms around the data. | “A table.” A table is one database object. | What makes an RDBMS relational? | 01 — Database Fundamentals |
| BQ003 | What is PostgreSQL? | An open-source relational DBMS implementing SQL plus PostgreSQL extensions. | Distinguishes product from language and data. | “A programming language.” | SQL vs PostgreSQL? | 00 — Start Here |
| BQ004 | What is SQL? | A declarative language for defining, querying, and modifying relational data. | You state what result/state change is needed; the DB plans how. | “A database.” | What does declarative mean? | 03 — SQL Overview |
| BQ005 | What is a table? | A relation-like structure of typed columns and rows representing facts. | Gives a concrete SQL implementation of relational data. | “A spreadsheet.” Similar shape, different constraints/query/concurrency semantics. | Row vs column? | 01 — Database Fundamentals |
| BQ006 | What is a row? | One tuple/record instance in a table. | A row carries values for the table’s attributes. | “A column value.” | What identifies a row? | 01 — Database Fundamentals |
| BQ007 | What is a column? | A named typed attribute of rows in a table. | Type and constraints define valid values/meaning. | “A record.” | Why do types matter? | 09 — SQL Data Types |
| BQ008 | What is a schema in PostgreSQL? | A namespace inside one database containing objects such as tables/views/functions. | It organizes names and privileges; it is not a separate database. | “The table definition only.” | What is search_path? | 07 — Schemas and Search Path |
| BQ009 | What is a PostgreSQL cluster? | One PostgreSQL server/data-directory environment containing multiple databases and cluster-wide roles. | Clarifies hierarchy above a database. | “A Kubernetes cluster.” | Can ordinary SQL join across databases in one cluster? | 05 — Databases, Schemas, Objects |
| BQ010 | What is a primary key? | The chosen unique, non-null identifier for rows. | It expresses entity identity and creates supporting uniqueness. | “Any indexed column.” | Natural vs surrogate key? | 43 — Primary Keys |
| BQ011 | What is a foreign key? | A constraint requiring referencing values to match a referenced unique/candidate key, subject to nullability/action rules. | It enforces referential integrity across writers. | “A join column.” A join can exist without FK enforcement. | Does PostgreSQL auto-index the child FK? | 44 — Foreign Keys |
| BQ012 | What is a candidate key? | A minimal set of attributes that uniquely identifies a row. | A table can have multiple candidate keys; one becomes primary. | “Only the primary key.” | What is a superkey? | 02 — Relational Model |
| BQ013 | What is a constraint? | A database-enforced invariant such as NOT NULL, CHECK, UNIQUE, PK, FK, or EXCLUDE. | Constraints protect data regardless of caller. | “Application validation.” | Why keep app validation too? | 42 — Constraints |
| BQ014 | What does NOT NULL mean? | The column cannot contain SQL NULL. | It declares required presence at the schema level. | “Cannot be empty string.” Empty string is a value. | NULL vs empty string? | 19 — NULL |
| BQ015 | What does UNIQUE do? | Enforces uniqueness according to PostgreSQL’s unique/null semantics. | It represents candidate-key-like invariants. | “Makes queries fast.” It may use an index, but correctness is primary. | What about NULL values? | 42 — Constraints |
| BQ016 | What does CHECK do? | Requires its Boolean condition not be FALSE for each row. | UNKNOWN can pass, so NOT NULL may also be needed. | “CHECK always rejects NULL.” | Why can NULL pass a check? | 42 — Constraints |
| BQ017 | What is NULL? | A marker for missing/unknown/not-applicable information according to the model. | SQL uses three-valued logic around NULL. | “Empty” or “zero.” | Why is x = NULL wrong? | 19 — NULL |
| BQ018 | What are SQL’s three truth values? | TRUE, FALSE, UNKNOWN. | Comparisons involving NULL commonly yield UNKNOWN. | “TRUE and FALSE only.” | What does WHERE do with UNKNOWN? | 19 — NULL |
| BQ019 | How do you test for NULL? | IS NULL / IS NOT NULL. | Equality with NULL does not produce TRUE. | = NULL. | What is IS DISTINCT FROM? | 19 — NULL |
| BQ020 | What does SELECT do? | Produces a result relation from expressions and input relations. | Projection/query composition is central SQL behavior. | “Fetches rows physically in table order.” | Is result order guaranteed? | 24 — SELECT Fundamentals |
| BQ021 | What does FROM do? | Defines input relations/table expressions for a query. | Logical processing begins by forming input row sources. | “Filters rows.” | What can appear in FROM besides tables? | 38 — Table Expressions |
| BQ022 | What does WHERE do? | Keeps rows whose predicate evaluates TRUE. | FALSE and UNKNOWN are filtered out. | “Runs after SELECT physically.” | WHERE vs HAVING? | 26 — Filtering |
| BQ023 | What does ORDER BY do? | Defines result ordering by one or more expressions. | Without it, row order is not guaranteed. | “Rows are always PK order.” | Why add a tie-breaker? | 27 — Ordering and Pagination |
| BQ024 | What does LIMIT do? | Restricts the number of output rows after ordering/logical processing. | Without deterministic ORDER BY, which rows appear can vary. | “Makes any query fast.” | LIMIT vs keyset pagination? | 27 — Ordering and Pagination |
| BQ025 | What does DISTINCT do? | Removes duplicate result rows. | It changes result semantics and can require hash/sort work. | “Fixes duplicate joins.” | Why are duplicates appearing? | 24 — SELECT Fundamentals |
| BQ026 | What is an alias? | A temporary name for a table/expression/result column in a query. | Improves disambiguation/readability. | “Renames the stored column.” | Table alias in self join? | 03 — SQL Overview |
| BQ027 | What is an expression in SQL? | A construct producing a value, e.g. column, literal, function, operator, CASE, subquery. | SELECT/WHERE/ORDER BY are built from expressions. | “Only arithmetic.” | Give a conditional expression. | 25 — Expressions and Operators |
| BQ028 | What is an aggregate function? | A function reducing many input rows to a value per group/query, such as COUNT/SUM/AVG. | Aggregation changes result grain. | “A window function.” Windows retain rows. | Aggregate vs window? | 28 — Aggregate Functions |
| BQ029 | COUNT(*) vs COUNT(column)? | COUNT(*) counts rows; COUNT(column) counts non-null values. | NULL semantics make them different. | “They are always identical.” | Count only paid orders? | 28 — Aggregate Functions |
| BQ030 | What does GROUP BY do? | Partitions input rows by key so aggregates compute per group. | Result grain becomes one row/group unless grouping sets expand it. | “Sorts rows.” | GROUP BY vs ORDER BY? | 29 — GROUP BY and HAVING |
| BQ031 | WHERE vs HAVING? | WHERE filters rows before grouping; HAVING filters groups after grouping. | Predicate placement changes semantics and work. | “They are interchangeable.” | Where should status='paid' usually go? | 29 — GROUP BY and HAVING |
| BQ032 | What is an INNER JOIN? | Returns row combinations satisfying the join condition. | Unmatched rows on either side are omitted. | “Returns every row from left.” | INNER vs LEFT? | 30 — Joins |
| BQ033 | What is a LEFT JOIN? | Preserves all left rows; unmatched right columns are NULL. | Enables optional relationships/no-match reporting. | “Same as INNER JOIN.” | What can WHERE on right table do? | 30 — Joins |
| BQ034 | What is a CROSS JOIN? | Cartesian product of every left row with every right row. | Row count multiplies unless one side is tiny. | “Join without duplicates.” | 100×50 rows yields how many? | 30 — Joins |
| BQ035 | What is a self join? | Joining a table to itself under different aliases/roles. | Useful for manager/employee or related-row comparisons. | “Recursive CTE only.” | Show employee-manager relation. | 30 — Joins |
| BQ036 | ON vs WHERE in LEFT JOIN? | ON controls right-side matching while preserving left rows; a WHERE predicate on right columns can remove null-extended rows. | Predicate placement can turn outer behavior into inner behavior. | “No difference.” | How keep customers with no paid orders? | 30 — Joins |
| BQ037 | What is a subquery? | A query nested inside another SQL statement/expression. | It can return scalar, row, table, or existence information. | “Always slow.” | Correlated vs uncorrelated? | 31 — Subqueries |
| BQ038 | What does EXISTS mean? | TRUE if the subquery returns at least one row. | It expresses semi-join/existence intent without multiplication. | “Counts every matching row first.” | EXISTS vs JOIN? | 31 — Subqueries |
| BQ039 | Why can NOT IN be dangerous with NULL? | A NULL in the comparison set can make the predicate UNKNOWN instead of TRUE. | Three-valued logic affects universal inequality. | “NOT IN ignores NULL.” | Safer anti-join? | 26 — Filtering |
| BQ040 | What is UNION? | Combines compatible query results and removes duplicates. | It is a set operation, not a join. | “Joins columns side by side.” | UNION vs UNION ALL? | 33 — Set Operations |
| BQ041 | UNION vs UNION ALL? | UNION removes duplicates; UNION ALL preserves them and avoids deduplication work. | Choose based on semantics. | “ALL is always slower.” | When prefer ALL? | 33 — Set Operations |
| BQ042 | What is CASE? | A conditional expression returning one value based on predicates. | It is expression-level branching in SQL. | “A procedural loop.” | CASE with NULL? | 36 — Conditional Expressions |
| BQ043 | What does COALESCE do? | Returns the first non-null argument. | Useful for explicit fallback semantics. | “Changes stored NULL permanently.” | When is converting NULL to 0 wrong? | 36 — Conditional Expressions |
| BQ044 | What is an index? | An auxiliary maintained access structure used for selected operators/orderings/constraints. | It can reduce data scanned but costs writes/storage/cache. | “A thing that always makes queries faster.” | Why might planner ignore it? | 50 — Index Fundamentals |
| BQ045 | What is PostgreSQL’s default index type? | B-tree. | B-tree supports equality, ranges, ordering, uniqueness. | “Hash.” | When consider GIN? | 51 — B-Tree Indexes |
| BQ046 | Why not index every column? | Indexes add storage, WAL, cache pressure, write/vacuum maintenance and can reduce HOT opportunities. | Index value is workload-specific. | “More indexes can only help.” | How validate an index? | 50 — Index Fundamentals |
| BQ047 | What is a composite index? | An index with multiple key columns in a deliberate order. | It can support combined filters/orderings; order matters. | “Several separate indexes combined automatically in the same way.” | What drives column order? | 57 — Advanced Index Design |
| BQ048 | What is a transaction? | A unit of database work that commits atomically or rolls back. | It defines a consistency/isolation boundary. | “A batch of SQL for performance only.” | BEGIN/COMMIT/ROLLBACK? | 58 — Transactions |
| BQ049 | What does COMMIT do? | Makes a successful transaction’s changes committed/durable according to configuration. | It ends the transaction boundary. | “Saves only the last statement.” | What happens on connection loss before commit? | 58 — Transactions |
| BQ050 | What does ROLLBACK do? | Aborts uncommitted transaction changes. | Preserves atomicity after failure/decision. | “Deletes committed history.” | What is a savepoint? | 58 — Transactions |
| BQ051 | What is ACID? | Atomicity, Consistency, Isolation, Durability. | Each property is provided by mechanisms plus correct schema/application design. | Four memorized words with no mechanisms. | Which mechanisms support durability? | 59 — ACID |
| BQ052 | What is atomicity? | Transaction changes commit as a unit or not at all. | Prevents partial committed state. | “Every statement runs instantly.” | How do savepoints differ? | 59 — ACID |
| BQ053 | What is consistency in ACID? | Transactions preserve declared/application invariants from valid state to valid state. | PostgreSQL cannot enforce rules you never encode. | “All replicas instantly match.” | Role of constraints? | 59 — ACID |
| BQ054 | What is isolation? | Rules for how concurrent transactions observe/interfere with each other. | Correctness requires reasoning about overlap. | “Transactions run one at a time.” | Default PG isolation? | 63 — Transaction Isolation |
| BQ055 | What is durability? | A committed transaction survives crashes according to configured guarantees, primarily through WAL/recovery. | Commit acknowledgement is linked to persisted log state. | “Data page is immediately written to table file.” | What is WAL? | 59 — ACID |
| BQ056 | What is PostgreSQL’s default isolation level? | Read Committed. | Each statement gets a fresh appropriate snapshot. | “Serializable.” | Can two SELECTs see different committed data? | 63 — Transaction Isolation |
| BQ057 | What is a race condition in DB code? | Outcome depends incorrectly on concurrent timing/interleaving. | Read-then-write patterns can violate invariants. | “Only a multithreaded app problem.” | How prevent duplicate signup race? | 61 — Concurrency Fundamentals |
| BQ058 | Why use a UNIQUE constraint for duplicate signup? | It atomically arbitrates concurrent inserts at the database boundary. | Pre-checks can both observe absence. | “SELECT first, then INSERT is enough.” | How handle conflict? | 67 — Concurrency Patterns |
| BQ059 | What does SELECT FOR UPDATE do? | Locks selected rows against conflicting modifications until transaction end. | Supports multi-step current-state decisions. | “Makes SELECT faster.” | When prefer atomic UPDATE instead? | 64 — Locking |
| BQ060 | What is a deadlock? | A cycle where transactions each wait for locks held by another. | No participant can progress without aborting one. | “Any slow lock wait.” | How reduce deadlocks? | 65 — Deadlocks |
| BQ061 | What is MVCC? | Multi-Version Concurrency Control: snapshots and tuple versions let many reads/writes coexist with visibility rules. | Readers often avoid blocking writers. | “Every update is just an in-memory copy.” | Why does VACUUM exist? | 62 — MVCC |
| BQ062 | What is a dead tuple? | An obsolete tuple version no longer needed by future/current relevant snapshots once visibility permits cleanup. | Updates/deletes leave old versions under MVCC. | “A corrupt row.” | Who reclaims it? | 75 — VACUUM |
| BQ063 | What does VACUUM do? | Reclaims dead tuple space for reuse, maintains visibility/freeze metadata, and helps prevent XID wraparound. | It is required by PostgreSQL MVCC lifecycle. | “Shrinks the file to the OS every time.” | VACUUM vs VACUUM FULL? | 75 — VACUUM |
| BQ064 | What is autovacuum? | PostgreSQL’s automatic vacuum/analyze maintenance system using launcher/workers and thresholds. | Keeps MVCC cleanup/statistics/freeze healthy. | “Optional cleanup that can safely be disabled.” | Why tune huge tables? | 76 — Autovacuum |
| BQ065 | What is WAL? | Write-Ahead Log: change/recovery records written before corresponding data pages. | Enables durability, crash recovery, replication, PITR. | “A query log.” | What is an LSN? | 82 — WAL |
| BQ066 | What is a checkpoint? | A recovery point coordinating dirty-page flushing and bounding recovery work. | WAL remains central; checkpoint is not “save everything instantly.” | “A backup.” | Why can frequent checkpoints hurt? | 83 — Checkpoints |
| BQ067 | What is a backup? | A recoverable copy/state from which database data can be restored. | Logical and physical backups serve different recovery needs. | “A replica.” | Why is a replica not a backup? | 85 — Backups |
| BQ068 | What is RPO? | Maximum acceptable data loss in a recovery scenario. | It drives backup/WAL/replication strategy. | “Recovery duration.” That is RTO. | Example RPO of 5 minutes? | 86 — Restore and DR |
| BQ069 | What is RTO? | Maximum acceptable time to restore service after failure. | It drives restore/failover process and capacity. | “How much data can be lost.” | How test it? | 86 — Restore and DR |
| BQ070 | What is streaming replication? | Physical WAL streaming from primary to standby for recovery/read/HA use. | Standby replays physical changes. | “Logical table copy only.” | Sync vs async? | 88 — Streaming Replication |
| BQ071 | What is replication lag? | Difference between primary progress and standby receive/write/flush/replay progress. | Lag can cause stale reads and RPO risk. | “Only network latency.” | Which lag stage matters for reads? | 88 — Streaming Replication |
| BQ072 | Authentication vs authorization? | Authentication proves identity; authorization determines permitted actions. | PostgreSQL uses both connection auth and roles/privileges. | “Same thing.” | Where is auth configured? | 92 — Security Fundamentals |
| BQ073 | What is a PostgreSQL role? | A cluster-wide identity/group principal that can own objects and receive privileges; LOGIN makes it directly authenticatable. | Roles unify users/groups concept. | “Only an application user row.” | Role membership? | 93 — Roles and Privileges |
| BQ074 | What does GRANT do? | Gives specified privileges or role membership. | Least privilege should grant only required capabilities. | “Transfers ownership automatically.” | GRANT vs ownership? | 93 — Roles and Privileges |
| BQ075 | What is SQL injection? | Untrusted input changes SQL program structure because code and values were concatenated unsafely. | Parameterization separates values from SQL syntax. | “Bad characters in a string.” | How do bind parameters help? | 97 — SQL Injection |
| BQ076 | Why parameterize queries? | Values are sent separately and encoded as data, not executable SQL text. | It is the primary injection defense for values. | “It validates authorization too.” | Can identifiers be parameters? | 97 — SQL Injection |
| BQ077 | What is EXPLAIN? | Shows PostgreSQL’s chosen execution plan and estimates without executing the query by default. | It exposes planner decisions. | “Returns query results with timing.” | What does ANALYZE add? | 70 — EXPLAIN |
| BQ078 | What is EXPLAIN ANALYZE? | Executes the statement and reports actual rows/timing/loops alongside estimates. | Lets you compare planner model to reality. | “Safe on DELETE because it only explains.” | Why dangerous on DML? | 70 — EXPLAIN |
| BQ079 | What is a sequential scan? | A plan node scanning table pages and testing rows. | It can be optimal when many rows are needed or table is small. | “Always bad; add an index.” | When is it cheaper than index scan? | 71 — Plan Nodes |
| BQ080 | What is the main PostgreSQL performance workflow? | Measure workload, inspect EXPLAIN ANALYZE/BUFFERS, compare estimates/actuals, identify root cause, change query/index/schema/config, measure again. | Performance tuning is evidence-driven and workload-specific. | “Add an index to every WHERE column.” | What if query is waiting on a lock? | 74 — Query Performance |