# Topic 25: Databases, Analytics, and Data Engineering

**Fictional Northstar case · self-paced · 45–90 minutes plus optional setup**

## Opening question
Can a correct chart still support a wrong conclusion?

## Explain
Databases organize records and enforce constraints; data pipelines move and transform them; analytics interprets results. Quality issues such as duplicates, missing values and inconsistent units can distort a technically correct query. A metric needs a definition and a suitable population. Dashboards should show context, uncertainty and source lineage rather than imply causality from a pattern.

## Supporting technologies
- **Tables and keys:** Unique identifiers and relations reduce ambiguity.
- **SQL and aggregation:** Filter and group a defined population.
- **Pipelines and quality:** Validate before transformation and reporting.
- **Interpretation:** Separate descriptive findings from causal claims.

## Scenario
Northstar wants mean restoration time from a synthetic ticket export with a duplicate and a missing value.

```text
id,restore_minutes
T01,20
T02,100
T02,100
T03,
```

## Hands-on procedure
1. Identify the duplicate key and missing measurement before calculating.
2. Write a rule for duplicate resolution and missing-value treatment; do not silently replace missing time with zero.
3. After documented deduplication, calculate the mean for valid measurements.
4. Write SQL or pseudocode selecting only validated rows and report sample size.
5. Build a small chart or table that exposes individual values and exclusions.
6. Explain why this dataset cannot establish the cause of slow restoration or justify a staffing conclusion.

## Expected reasoning and limits
After the stated deduplication there are two valid values, mean 60 minutes, and one missing value. Results depend on documented cleaning decisions; the sample is too small for broad performance conclusions.

## Best practices
- Define keys, units and metric boundaries.
- Retain raw synthetic input and transformation steps.
- Report missingness and exclusions.
- Use parameterized queries and appropriate access controls.

## Vendors, projects and learning
- [PostgreSQL](https://www.postgresql.org/docs/): Open-source relational database
- [Microsoft](https://learn.microsoft.com/en-us/power-bi/): Power BI learning
- [SQLite](https://www.sqlite.org/docs.html): Local embedded database

## Optional technical extension
Load the synthetic CSV into SQLite or a spreadsheet, enforce unique IDs in a cleaned table and reproduce the mean with a query. Do not upload real ticket exports.

## Career practice
Relevant role families to investigate: Junior data analyst, Reporting analyst, Data support technician. No current vacancy or hiring requirement is asserted.

Interview: How can duplicates change a service metric, and how would you document the correction?

## Sources
- [PostgreSQL tutorial](https://www.postgresql.org/docs/current/tutorial.html)

## Portfolio evidence
Use the [portfolio guide](../guides/portfolio.md). Submit original input, decisions, tests, actual results, limitations and source attribution. Clearly label modeled, planned and performed work.

## Suggested prerequisites
Topic 22
