🚧 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 › Data Science & Analytics › SQL and PostgreSQL for Data Analytics › Lesson 9
TEC-DATA85-04 · Lesson 9 · 12 clock hours · lab

Capstone Integration: Civic Data Analytics Project

Objective. Students apply all course skills—schema design, querying, optimization, and tool integration—to a realistic civic dataset, producing a documented SQL codebase and a short oral defense.

⚠ 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 Integration: Civic Data Analytics Project

This capstone lesson brings together every skill you have built in this course—schema design, SQL querying, query optimization, and tool integration—and applies them to real public data. Working with civic datasets is a practical rehearsal for professional data analytics: the data is messy, the schema does not yet exist, and the questions you answer can have genuine public value.

Choosing Your Dataset

Your first task is to select one dataset from the provided list of US open-data portals (such as data.gov or a local city data portal). Good candidates include city 311 service requests, county property tax assessments, and transit ridership logs. Choose a dataset that is large enough to be interesting—at least several thousand rows—but small enough to load and query in a reasonable time on your workstation. Download the data as CSV or JSON, inspect it in a spreadsheet or text editor, and note its columns, data types, and any obvious quality issues before you write a single line of SQL.

Designing a Normalized Schema

Raw civic data almost always arrives as a flat file. Your job is to decompose it into a normalized relational schema. Aim for at least Third Normal Form (3NF): every non-key column depends on the whole primary key and nothing but the primary key. Identify natural entities—for example, a 311 dataset might yield a `service_requests` fact table plus separate lookup tables for `departments`, `request_types`, and `neighborhoods`. Assign surrogate integer primary keys where natural keys are absent or unreliable. Use foreign key constraints to enforce referential integrity. Draw an entity-relationship (ER) diagram before you write DDL; this diagram will appear in your oral defense.

When you choose data types, be precise. Store dates as `DATE` or `TIMESTAMPTZ`, dollar amounts as `NUMERIC(12,2)`, and short codes as `VARCHAR` with a reasonable length limit. Avoid storing everything as `TEXT`; specific types enable better indexing and catch bad data at load time.

Loading and Cleaning the Data

Use PostgreSQL's `\COPY` command or a Python script (with `psycopg2` or `pandas` and `SQLAlchemy`) to load your cleaned CSV into the staging table first. Then use `INSERT … SELECT` statements to populate your normalized tables from the staging table, transforming and deduplicating as you go. Document every transformation decision: if you drop rows, state why; if you normalize a text field (for example, converting "N/A" to `NULL`), record that in your README.

Writing Analytical Queries

You must write a minimum of twelve analytical queries. Spread them across difficulty levels:

Test every query: verify that the result makes sense against a small hand-checked sample. A query that runs without error but returns nonsense is still wrong.

Query Optimization and EXPLAIN ANALYZE

Add at least one index to your schema that improves a slow query. Run `EXPLAIN ANALYZE` on the query before and after adding the index, and save both output blocks. Include these in your README with a plain-English sentence explaining what changed (for example, a sequential scan became an index scan and execution time dropped from X ms to Y ms). Index foreign key columns and columns that appear frequently in `WHERE` or `JOIN ON` clauses. Be aware that indexes speed up reads but add overhead to writes; explain this trade-off briefly in your README.

Data Privacy and Responsible Handling

Public open data is not always fully anonymized. Before you begin analysis, scan your dataset for personally identifiable information (PII)—names, street addresses to the unit level, phone numbers, email addresses, dates of birth, or government ID numbers. Even though the data is publicly posted, handling PII carelessly in a work product is a professional and, in some contexts, a legal concern.

In your README, write a short data-privacy note: identify any PII columns you found, explain how you handled them (for example, excluded from queries, stored but not displayed in output visuals, or aggregated to a level that does not identify individuals), and note whether the dataset's portal terms of use permit the intended use. This habit maps directly to real workplace expectations and to the data ethics content tested by CompTIA Data+ and the Google Data Analytics certificate.

Creating an Output Visual

Produce at least one output visual using Python (matplotlib, seaborn, or plotly) or Power BI connected to your PostgreSQL database. The visual should answer a meaningful question from your dataset—not simply confirm a count. Label axes, include a title, and cite the data source. This visual does not need to be elaborate, but it must be honest: do not truncate axes or omit context in ways that mislead.

The Technical README

Your README (one to two pages, using the instructor-provided template) must cover: an ER diagram or table listing of your schema; a rationale for at least two schema design decisions; plain-English explanations of three representative queries; the EXPLAIN ANALYZE before-and-after evidence; and your data-privacy note. Write for a reader who is technically literate but unfamiliar with your specific project.

The Oral Defense

In a ten-minute session with your instructor and one peer, you will walk through your ER diagram and three queries of your choosing, then answer at least three follow-up questions. Be ready to explain why you chose a particular join type, what a window function partition achieves, or what would happen if you dropped an index. Speak clearly, refer to your diagram, and if you do not know an answer, say so and reason through it aloud—demonstrating how you think is as important as the answer itself.

Passing Standard

You must earn 80% of rubric points across schema correctness, query correctness, documentation completeness, and oral question responses. Any query that returns incorrect results must be corrected before a pass is recorded. Approach each section deliberately: correctness is non-negotiable.

Key terms10

Third Normal Form (3NF)A relational database design standard in which every non-key column depends on the primary key and nothing else, eliminating transitive dependencies and reducing data redundancy.
Common Table Expression (CTE)A temporary named result set defined with a WITH clause at the start of a SQL statement, used to break complex queries into readable, reusable steps without creating a permanent object.
Window FunctionA SQL function that performs a calculation across a set of rows related to the current row, defined by an OVER clause, without collapsing the rows into a single output row the way GROUP BY does.
EXPLAIN ANALYZEA PostgreSQL command that executes a query and returns the query planner's execution plan together with actual runtime statistics, used to identify performance bottlenecks such as sequential scans.
Referential IntegrityA database constraint enforced by foreign keys that ensures every value in a child table's foreign key column corresponds to an existing value in the parent table's primary key column.
Personally Identifiable Information (PII)Any data that can be used on its own or combined with other data to identify a specific individual, such as full name, street address, phone number, or government ID number.
Surrogate KeyAn artificially generated primary key, typically a sequential integer or UUID, used when no reliable natural key exists in the data.
Sequential ScanA query execution strategy in which PostgreSQL reads every row in a table from start to finish; efficient for small tables or queries returning most rows, but slow on large tables when only a few rows match.
Entity-Relationship (ER) DiagramA visual diagram showing the tables in a database, their columns, primary and foreign keys, and the relationships between tables, used to communicate schema design.
Staging TableA temporary or intermediate table used to hold raw imported data before it is transformed and loaded into the final normalized tables of a database.
In class: Project build: each student selects one dataset from a provided list of US open-data portals (e.g., city 311 service requests, county property assessments, transit ridership), designs and loads a normalized schema, and writes a minimum of twelve analytical queries ranging from simple aggregations to CTEs and window functions. · Documentation sprint: students write a one-to-two page technical README covering schema decisions, key query explanations, one index added with before-and-after EXPLAIN ANALYZE evidence, and a brief data-privacy note identifying any PII present and how it was handled. · Oral defense: each student presents their schema diagram and three queries to the instructor and one peer in a ten-minute session, answering questions about design choices and query logic.
Materials: US open-data portals (data.gov, local city data portals), PostgreSQL 16 / pgAdmin 4, Python or Power BI for at least one output visual, README template (instructor-provided), oral defense rubric
Check: Oral defense rubric scored by instructor: schema correctness (normalized, keyed), query correctness (all twelve return expected results), documentation completeness, and ability to answer at least three follow-up questions; pass requires 80% of rubric points; any query returning incorrect results must be corrected before a pass is recorded.

Practice check8

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

Data Analysis and Querying
1. A student loads a flat CSV of 311 service requests and finds that the department name is repeated in every row. Which normalization step directly eliminates this redundancy?
Data Analysis and Querying
2. Which SQL clause is used to define a Common Table Expression (CTE)?
Database Optimization
3. A student runs EXPLAIN ANALYZE on a query filtering by request_date and sees a 'Seq Scan' with high actual time. What is the most appropriate next step?
Data Governance and Ethics
4. A student's civic dataset contains a column called 'complainant_phone'. Which action best reflects responsible data handling for the capstone README privacy note?
Data Analysis and Querying
5. Which window function would correctly assign a rank to each neighborhood by total service requests, with no gaps in rank numbers when ties occur?
Data Analysis and Querying
6. A student wants to calculate a running total of daily transit ridership ordered by date within each route. Which SQL construct is most appropriate?
Data Analysis and Querying
7. For the oral defense, a student is asked why they chose a LEFT JOIN instead of an INNER JOIN when linking service requests to neighborhoods. Which answer best demonstrates conceptual understanding?
Database Optimization
8. According to CompTIA Data+ objectives, which of the following best describes the trade-off a data analyst should communicate when recommending a new index on a frequently queried column?
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.