🚧 Under construction — VoTechWorks is being built. A free tech program — complimentary, as our commitment to get America working.
voTechWorksGrade 13 · a vocational technology learning center, by urbanicity
newSchoolWorks.com › VoTechWorks › Technology & Design › Web & Software Development › SQL and PostgreSQL Database Development › Lesson 12
TEC-WEB46-04 · Lesson 12 · 22.5 clock hours · lab

Capstone Lab: Full Database Design, Implementation, and Documentation

Objective. Students will independently design, build, populate, query, and document a complete PostgreSQL database for an assigned business scenario, demonstrating all skills developed in the course.

⚠ Pending professional review

This lesson, its worked examples and its practice questions has not yet been verified by an industry-certified professional or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.

VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.

Capstone Lab: Full Database Design, Implementation, and Documentation

This capstone lab is your opportunity to demonstrate every skill developed in this course. Working independently, you will take a business scenario from a blank slate to a fully documented, production-quality PostgreSQL database. Read this page carefully before you open any tool.

Understanding the Assignment Phases

The lab has three phases that build on each other. Do not skip ahead — instructors grade each phase, and errors made early multiply into larger problems later.

Phase 1 – Requirements and Design. Read the scenario brief completely before writing a single line of SQL. Identify the entities (people, places, things, events) and the relationships between them. Write a short requirements document listing what data the system must store and what questions it must answer. Then draw a normalized ER diagram in draw.io, labeling primary keys, foreign keys, cardinality (one-to-many, many-to-many), and any weak entities. Check that your design reaches at least Third Normal Form (3NF): eliminate repeating groups, remove partial dependencies, and remove transitive dependencies. Have a peer or the instructor review the diagram before you write DDL.

Phase 2 – Implementation and Queries. Translate your ER diagram into a DDL script executed in psql or pgAdmin against PostgreSQL 16. Every table must have a primary key constraint. Foreign keys, NOT NULL, UNIQUE, and CHECK constraints must appear wherever the requirements document calls for them. Create at least one view that simplifies a common query and at least one function (PL/pgSQL or SQL-language) that encapsulates reusable logic, such as calculating totals or formatting output.

Populate the database with at least 200 rows of realistic seed data. You may write INSERT statements by hand or use a Python seed script — either approach is acceptable. Realistic means plausible names, dates, and amounts; avoid placeholder text such as "test1" or "aaa."

Next, answer the ten business questions in the scenario brief. Annotate each query with a comment block explaining what business question it answers and why you structured it that way. At least one query must use a Common Table Expression (CTE) and at least one must use an aggregation with a HAVING clause. Test every query to confirm it returns correct results before submission.

Phase 3 – Documentation and Defense. Write a two-page technical documentation report using the provided template. Cover these five areas: (1) schema design decisions — why you chose your table structure; (2) normalization rationale — which normal forms you applied and how; (3) index choices with EXPLAIN ANALYZE evidence — paste trimmed output showing the index being used; (4) role and privilege design — which database roles you created, what permissions they hold, and why; (5) backup procedure — the pg_dump command and schedule you would use in a production environment.

Finally, present your work in a 10-minute live defense. Spend roughly two minutes on the ER diagram, three minutes walking through key queries on screen, and five minutes on documentation and questions from the panel. Be ready to run any query live and explain any design choice.

Using EXPLAIN ANALYZE Safely

Running EXPLAIN ANALYZE executes the query against real data, which matters on large tables. In a production environment, never run EXPLAIN ANALYZE on a write operation without a transaction rollback wrapper. In this lab your database is local and contains seed data only, so the risk is low, but form the right habit now: wrap EXPLAIN ANALYZE on INSERT, UPDATE, or DELETE in BEGIN / ROLLBACK so no data changes are committed accidentally.

Backup with pg_dump

Your documentation must describe a backup procedure. The standard tool is pg_dump, which produces a consistent snapshot of a single database without locking other users out. A plain-text dump can be restored with psql; a custom-format dump uses pg_restore. Store dump files in a location separate from the database server — a dump on the same disk as the data does not protect you from disk failure. For your documentation, describe the format flag you would use, the target file path, and how often you would schedule the backup.

Rubric Overview

The rubric awards points in five areas: DDL correctness (25%), query correctness (25%), normalization and ER diagram (20%), documentation quality (15%), and oral defense (15%). The passing threshold is 80% of total rubric points, and every query must return correct results when the instructor runs your script on a fresh database. That last condition means your DDL script must be idempotent-friendly — use DROP TABLE IF EXISTS or CREATE TABLE IF NOT EXISTS so the instructor can run it cleanly.

Professional Habits That Matter

Comment your DDL. Every table should have a COMMENT ON TABLE statement or at least inline comments explaining non-obvious columns. Use consistent naming conventions (snake_case is the PostgreSQL community standard). Keep your Git repository organized with separate files for DDL, seed data, queries, and the function/view definitions. These habits are not graded here, but employers will notice them in your portfolio.

Key terms8

DDL (Data Definition Language)SQL statements — primarily CREATE, ALTER, and DROP — that define the structure of database objects such as tables, indexes, views, and constraints.
Third Normal Form (3NF)A database normalization level that eliminates repeating groups (1NF), partial dependencies on a composite key (2NF), and transitive dependencies on non-key attributes (3NF), reducing data redundancy and update anomalies.
Common Table Expression (CTE)A temporary named result set defined with the WITH keyword at the start of a SQL statement, making complex queries easier to read and maintain.
EXPLAIN ANALYZEA PostgreSQL command that both plans and executes a query, returning the actual execution plan with real row counts and timing, used to identify performance bottlenecks and confirm index usage.
pg_dumpA PostgreSQL command-line utility that creates a consistent, portable backup of a single database in plain-text SQL or several binary formats, without requiring the database to be offline.
HAVING clauseA SQL clause that filters the results of a GROUP BY aggregation, applied after grouping takes place — unlike WHERE, which filters individual rows before grouping.
Role and privilege designThe process of creating named database roles in PostgreSQL, granting them specific privileges (SELECT, INSERT, EXECUTE, etc.) on specific objects, and assigning users to roles to enforce least-privilege access control.
Seed dataRealistic sample records inserted into a database during development or testing to allow meaningful queries and application testing before real users generate data.
In class: Receive an assigned business scenario (e.g., a community events booking system); produce a written requirements document, a normalized ER diagram, and a complete DDL script creating all tables, constraints, and at least one view and one function. · Populate the database with at least 200 rows of realistic seed data (using INSERT scripts or a Python/PHP seed script), then write and annotate 10 queries answering specific business questions provided in the scenario brief, including at least one CTE and one aggregation with HAVING. · Write a two-page technical documentation report covering: schema design decisions, normalization rationale, index choices with EXPLAIN evidence, role and privilege design, and backup procedure; present findings in a 10-minute live defense to the instructor and two peers.
Materials: Scenario brief (instructor-provided), PostgreSQL 16, psql, pgAdmin, draw.io, VS Code, documentation template, EXPLAIN ANALYZE, pg_dump
Check: Rubric scores DDL correctness (25%), query correctness (25%), normalization and ER diagram (20%), documentation quality (15%), and oral defense (15%); pass = 80% of total rubric points earned and all queries return correct results when run by instructor.

Practice check8

Answer each question, then check it. Nothing is recorded; this is your own practice.

Database implementation and SQL scripting
1. You finish your DDL script and want the instructor to be able to run it on a fresh database without errors from pre-existing objects. Which approach best supports that goal?
SQL query writing
2. A business question asks: 'Which event categories had more than 50 bookings last month?' Which SQL clause is required to filter groups by a count?
Database performance and indexing
3. Your EXPLAIN ANALYZE output shows a Sequential Scan on a 50,000-row orders table every time a query filters by customer_id. What is the most appropriate corrective action?
SQL query writing
4. You need to write a query that first calculates the total revenue per event, then selects only events where that total exceeds a threshold. Which SQL feature best improves readability for this two-step logic?
Database security and access control
5. In your role and privilege design, you create a reporting role that should only read data. Which PostgreSQL privilege should you grant to that role on the events table?
Database backup and recovery
6. Which pg_dump flag produces a custom-format backup file that must be restored with pg_restore rather than psql?
Database design and normalization
7. Your ER diagram shows a many-to-many relationship between Attendees and Events. How should this relationship be correctly implemented in your DDL?
Database design and normalization
8. During your oral defense, the instructor asks why you added a UNIQUE constraint to the email column in your Attendees table. What is the best answer?
Record this lesson on my transcript. Sign in with your key and enrollment email to record lessons (enroll free if you have no key). This page stays open to read and practise.