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.

#TopicDescriptionLink
1Data ModelingNormalized DDL with primary/foreign keys, CHECK constraints, and ON DELETE RESTRICT.View
2SQL FundamentalsJoins, GROUP BY/HAVING, CTEs, and RANK() OVER windowing.View

Phase 2: Performance and Concurrency

Index design, execution plan inspection, explicit transactions, and idempotent upserts.

#TopicDescriptionLink
3Indexing & PlansComposite, partial, and expression indexes verified with EXPLAIN (ANALYZE, BUFFERS).View
4TransactionsGuarded 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.

#TopicDescriptionLink
5Access ControlNon-superuser role grants and tenant-scoped Row-Level Security (RLS) policy.View
6MonitoringSystem catalog queries against pg_stat_activity and pg_stat_user_tables.View