DBA Demo Examples
Runnable SQL scripts covering schema design, analytical queries, indexing, concurrency, access control, and catalog diagnostics. Scripts target PostgreSQL 14+; the schema and query scripts also run in SQLite 3.35+. Click View to inspect any script in the code viewer.
For official documentation, interactive SQL sandboxes, and classic database references, see References.
Phase 1: Schema and Queries
Table constraints, relational integrity, CTEs, and window functions.
| # | Topic | Description | Link |
|---|---|---|---|
| 1 | Data Modeling | Normalized DDL with primary/foreign keys, CHECK constraints, and ON DELETE RESTRICT. | View |
| 2 | SQL Fundamentals | Joins, GROUP BY/HAVING, CTEs, and RANK() OVER windowing. | View |
Phase 2: Performance and Concurrency
Index design, execution plan inspection, explicit transactions, and idempotent upserts.
| # | Topic | Description | Link |
|---|---|---|---|
| 3 | Indexing & Plans | Composite, partial, and expression indexes verified with EXPLAIN (ANALYZE, BUFFERS). | View |
| 4 | Transactions | Guarded state update inside BEGIN ... COMMIT and atomic ON CONFLICT DO UPDATE. | View |
Phase 3: Security and Operations
Least-privilege roles, Row-Level Security policies, and live catalog diagnostics.