DATA201 · COURSE STUDY COMPANION
Data Management and SQL for Business
Work through the mechanisms, connect all six units, then change the facts. Read alongside the original lessons, worked clinics and assigned textbook chapters.
Depth audit → · Study sequences → · Company simulation → · Independent review package →
Course overview → · Original six clinics →
- Data models and business meaning
- Keys and relational integrity
- Filtering and aggregation
- Joins and duplicate counting
- Transactions and controls
- Business queries and validation
DEVELOP THE MECHANISM
Data models and business meaning — deeper explanation
DEVELOPED LESSON CHAPTER
The governing relationship
A data model describes entities, events and relationships before tables are created. Define row grain and business meaning: a customer places orders; an order has lines; an invoice may receive several payments. Separate facts from derived totals and define units and time zones. A well-formed schema cannot repair a vague definition of an active customer, so record the rule before using that measure in management decisions.
Develop the reasoning
Model entities and events according to their business meaning before creating a report. A customer, order, invoice, line and payment are related but not interchangeable records. Define the grain of each table, key, date and status. One invoice can have many payments and one order may generate multiple invoices; assuming a one-to-one relationship can silently lose or duplicate money. Derived summaries should retain a traceable path to source events.
Use the method and test its limits
Separate data structure from metric definitions. A technically valid active_customer field can mean purchased this month, logged in recently or holds an unexpired agreement. Those definitions answer different questions. Record units, currency, time zone, missingness and correction rules before comparing periods. Distinguish a historical event from a current state: overwriting a customer's address need not rewrite where an older shipment was delivered. The goal is a model supporting consistent decisions and auditability, not merely a set of tables that can be joined without syntax errors.
A further distinction that changes the decision
Historical and current attributes should not be conflated. A customer's present segment may differ from the segment when an earlier sale occurred. Decide whether the report asks for historical classification or today's view of past activity. Overwriting attributes without this distinction can create apparent historical growth or migration that reflects data maintenance rather than real behavior.
Work a new multistep problem — optional
A customer has two orders. The first creates two invoices; one invoice receives two payments, the other none. The second order has not yet been invoiced.
Identify appropriate entities and relationships and explain why one row per customer cannot safely store all events in fixed numbered columns.
Study the worked reasoning
Use customer, order, invoice and payment identities with one-to-many links where the facts require them. Keep the uninvoiced order and unpaid invoice rather than infer their absence from payment records. Repeated numbered invoice/payment columns limit history and make aggregation and missingness ambiguous. Define whether invoice lines need a separate table.
Change a condition
A single payment can settle portions of two invoices.
Study the changed-condition answer
Introduce an allocation relationship between payments and invoices with allocated amounts and reconciliation. A direct one-invoice foreign key on payment no longer expresses the actual relationship. Validate that allocations do not exceed or misstate the payment and eligible invoice balances.
Read the full connected study route and specialist method studios →
Read this explanation in the complete course companion →
Apply the six units to a cumulative problem →
DEVELOP THE MECHANISM
Keys and relational integrity — deeper explanation
DEVELOPED LESSON CHAPTER
The governing relationship
A primary key uniquely identifies a record; a foreign key links it to a referenced entity. Uniqueness, referential integrity and required fields constrain invalid states. A name is rarely a safe identity key because names can change or collide. A surrogate ID does not itself prevent duplicate business events; define legitimate natural uniqueness where appropriate. Preserve corrections and authorization instead of silently changing historical records to make reports match.
Develop the reasoning
Keys express identity, and constraints protect relationships the system can enforce. A primary key must identify one record; a foreign key references a valid related record under actual schema rules. A person's name is not a reliable universal identity because names collide and change. A surrogate ID solves record labeling but does not by itself prevent the same real invoice being entered twice with different IDs. Identify natural business uniqueness and its scope, such as supplier plus invoice number.
Use the method and test its limits
Integrity includes more than referential existence. A referenced customer can exist while the transaction uses the wrong currency, inactive status or date. Decide which rules belong in validated application logic, database constraints and reconciliation, with appropriate transaction behavior. Deletion and correction policies should preserve relevant history and authority rather than make the report look tidy. Test valid duplicates, invalid duplicates, missing references and concurrent entry. A constraint is useful because it prevents a defined invalid state, not because every table has acquired more technical columns.
A further distinction that changes the decision
Constraint failures should be investigated rather than bypassed to meet a reporting deadline. A rejected duplicate may reveal a genuine second event, a reused identifier or a repeated import. Preserve the exception, inspect source evidence and correct the model or record accordingly. Disabling checks without resolving meaning can make a report complete-looking but unreliable.
Work a new multistep problem — optional
Two suppliers both issue invoice number 101. One supplier's invoice is accidentally entered twice with different internal row IDs. A system declares invoice_number globally unique or, alternatively, relies only on row_id.
Explain why each proposed uniqueness rule fails and suggest a better business-key check.
Study the worked reasoning
Global invoice-number uniqueness rejects legitimate invoices from different suppliers. Row-ID uniqueness allows the same supplier invoice to be duplicated. Subject to actual invoice conventions, uniqueness on supplier_id plus invoice_number can detect the stated duplicate while preserving both suppliers' invoice 101. Verify credit-note and revision rules rather than assume that key fits every system.
Change a condition
The supplier legitimately reuses invoice numbers each fiscal year.
Study the changed-condition answer
The natural uniqueness scope needs the relevant year or another verified identifier. Document that meaning and retain stable internal identity; do not guess a global rule from the first few records.
Read the full connected study route and specialist method studios →
Read this explanation in the complete course companion →
Apply the six units to a cumulative problem →
DEVELOP THE MECHANISM
Filtering and aggregation — deeper explanation
DEVELOPED LESSON CHAPTER
The governing relationship
Filtering chooses records before aggregation, while grouping determines the population represented by each result. Distinguish WHERE from HAVING: the former filters rows, the latter groups after aggregation. COUNT(*) counts rows; COUNT(column) excludes nulls in that column. Null represents missing or unknown rather than numeric zero. State how missing values affect denominators before comparing rates across teams or periods.
Develop the reasoning
Filtering and aggregation operate at different levels. A row filter selects events before grouping; a group filter selects aggregate results afterward. In SQL terms, WHERE and HAVING answer those distinct questions. COUNT(*) counts rows, while COUNT(column) excludes null values in that column. SUM and AVG also require an explicit understanding of missingness and population. A syntactically successful query cannot decide whether missing revenue means zero, unknown or invalid data.
Use the method and test its limits
State the output grain and denominator before writing the query. Monthly total collections differs from monthly earned revenue; average invoice amount differs from average customer revenue. Define cancellation, refunds, reversals and the date used. Apply only justified exclusions and report material missing groups. Validate a small dataset by hand and compare totals before and after filters. A query using the right function on the wrong population may produce an exact answer to a question no manager intended to ask.
A further distinction that changes the decision
Group filters need a clear comparison base. Selecting customers with annual sales above a threshold after aggregation differs from filtering only large individual invoices before summing. The latter can omit smaller legitimate purchases and misclassify customers. Translate the business phrase into a precise row or group condition before coding it.
Work a new multistep problem — optional
A table contains four invoice amounts: 100, 200, NULL and 0. All four rows are valid invoice records, but the NULL amount is genuinely unknown.
Calculate COUNT(*), COUNT(amount), SUM(amount) and AVG(amount) under standard SQL aggregate null behavior, and explain the reporting limit.
Study the worked reasoning
COUNT(*) is four; COUNT(amount) three; SUM(amount) $300; AVG(amount) $100 over the three known values. Replacing NULL with zero would produce a $75 four-row mean but falsely assert the missing amount is zero. The known-value result is not a verified average over all invoice amounts.
Change a condition
The unknown amount is later verified as $500.
Study the changed-condition answer
Total becomes $800 and the four-invoice mean $200. Retain provenance of the correction rather than portray the previous known-value mean as a measured full-population amount.
Read the full connected study route and specialist method studios →
Read this explanation in the complete course companion →
Apply the six units to a cumulative problem →
DEVELOP THE MECHANISM
Joins and duplicate counting — deeper explanation
DEVELOPED LESSON CHAPTER
The governing relationship
A join combines matching records and can multiply rows. Joining an invoice header to three lines repeats the header three times; joining payments as another one-to-many relation can multiply further. Aggregate each fact table to a compatible grain before combining totals. DISTINCT amount is not a general repair because separate legitimate events can have identical amounts. Reconcile counts and totals using keys and known cases, including unmatched records.
Develop the reasoning
A join changes row multiplicity according to relationship cardinality. Combining one invoice header with three lines repeats the header three times; joining two payments can create six line-payment combinations. Those combinations may be legitimate detail but are not six invoices or six full payments. Define the grain needed in the result and aggregate independent fact tables to compatible keys before joining monetary totals.
Use the method and test its limits
Distinctness must follow event identity, not equal values. Two real invoices can each be $600, so SUM(DISTINCT amount) can discard valid sales. An inner join also removes unmatched records, which may exclude exactly the unpaid invoices a receivables report needs. A left join can preserve headers, but filters placed afterward can unintentionally remove null-side rows. Validate matched and unmatched counts, one-to-many relationships and known examples. Reconcile both detail and totals instead of applying a deduplication trick until the final number looks plausible.
A further distinction that changes the decision
Join validation should include unmatched records on both sides. An orphan payment can indicate missing invoice data, miskeying or a valid deposit requiring another representation. Dropping it silently may make invoice totals reconcile while lose cash. Record the exception and determine the real event before forcing every row into a convenient relationship.
Work a new multistep problem — optional
Invoice J is $1,200, has four lines and receives two payments of $300 and $500. Invoice K is $700, has one line and no payments.
Explain the row multiplication and produce correct paid and outstanding totals.
Study the worked reasoning
Joining J's raw lines and payments gives eight combinations, repeating the header and each payment. Aggregate payments by invoice first, then left join to unique headers. J paid is $800 and outstanding $400; K paid zero and outstanding $700 under these facts. Total outstanding is $1,100. Do not sum repeated header amounts or drop K through an inner join.
Change a condition
J receives a third legitimate payment of $300.
Study the changed-condition answer
Paid becomes $1,100 and outstanding $100; total outstanding becomes $800. DISTINCT payment amount would discard a real repeated $300 payment. Retain payment IDs and reversals and aggregate legitimate events.
Read the full connected study route and specialist method studios →
Read this explanation in the complete course companion →
Apply the six units to a cumulative problem →
DEVELOP THE MECHANISM
Transactions and controls — deeper explanation
DEVELOPED LESSON CHAPTER
The governing relationship
Transactions protect a defined multi-step operation under the database's actual isolation and constraint behavior. Atomicity means all required changes commit together or none do; it does not mean every business rule was correctly expressed. Separate read access from authority to change records, parameterize inputs and retain an appropriate audit trail. Concurrency tests should examine conflicting updates rather than assuming a single-user happy-path result establishes safe behavior.
Develop the reasoning
Transactions group a defined set of database changes so partial completion does not leave a prohibited state. For a transfer, removing value from one account and adding it to another must be considered together. Atomicity does not prove the business logic is correct, while consistency depends on expressed rules and correct operations. Isolation behavior determines what concurrent work can observe and change; do not assume a successful single-user run establishes safe concurrent behavior.
Use the method and test its limits
Controls also address authority and evidence. Separate read permissions from rights to approve or alter financial events, validate inputs and retain an appropriate audit trail. Parameterized queries protect the code-data boundary but do not decide who is authorized to perform an action. Test duplicate submission, concurrent updates, failure midway through an operation and recovery. Use actual database semantics and qualified technical review for implementation details rather than assign universal behavior to a vague transaction label. Reconcile external settlement when database records represent only one part of a real-world process.
A further distinction that changes the decision
Database completion and real-world completion can differ. A recorded payment instruction may be accepted internally while the external transfer fails or is duplicated. Define states and reconciliation to the authoritative settlement evidence. Transaction atomicity within one database does not automatically make every connected system or physical event atomic too.
Work a new multistep problem — optional
A stock balance is ten units. Two users simultaneously read ten and each approves a sale of seven, then each writes a remaining balance of three. The naive final stored balance is three.
Identify the business failure and required properties of a safe operation without assuming a particular database implementation.
Study the worked reasoning
Fourteen units were promised against ten, while the stored balance hides the conflict. The decrement and nonnegative-stock validation must operate correctly under concurrent updates, using the chosen database's actual transaction/locking or conditional-update semantics. Reconcile committed sales with stock and make duplicate requests identifiable. A final nonnegative value alone did not preserve the intended rule.
Change a condition
The same request is retried after a network timeout.
Study the changed-condition answer
A stable operation identity or equivalent idempotency design is needed so the retry does not create a second sale unintentionally. Distinguish a new authorized sale from an uncertain retry and verify the committed result before repeating side effects.
Read the full connected study route and specialist method studios →
Read this explanation in the complete course companion →
Apply the six units to a cumulative problem →
DEVELOP THE MECHANISM
Business queries and validation — deeper explanation
DEVELOPED LESSON CHAPTER
The governing relationship
A business query needs a specification, known-answer examples and reconciliation. Define the date field, inclusion rules, status and unit. Test zero records, missing relationships, duplicates and multiple payments. Compare an independent calculation and explain any excluded population. The query may be syntactically valid yet answer the wrong question, such as counting lines instead of customers or invoiced sales instead of collected cash.
Develop the reasoning
A business query is a specification implemented in code. State the population, time field, grain, status, currency, missingness and output before writing SQL. “Revenue this month” can otherwise mean invoices issued, services accepted, cash received or booked orders. Those quantities can all be useful but answer different questions. Define expected outputs for a small known dataset and verify the edge cases that could change the decision.
Use the method and test its limits
Validation should include zero records, unmatched relationships, repeated amounts, multiple payments, cancellations and period crossings. Compare independent hand calculations and reconcile to authoritative records rather than only compare two reports sharing the same query. Document any material excluded population and preserve transformations and versions. A query that runs faster can still answer the wrong question more efficiently. Tie its output to an actual decision and state whether uncertainty or missing source evidence prevents the stronger claim a user wants to make.
A further distinction that changes the decision
A known-answer test should target meaning, not merely reproduce the same query in another form. Hand-build a small dataset with deliberate period crossings and missing relationships, specify the correct result from the business rules, then compare. Two reports sharing a faulty filter can agree exactly while both answer the wrong question.
Work a new multistep problem — optional
Service A is completed December 28 and billed $1,000 on January 3; payment arrives January 20. Service B is completed and billed $600 January 10 but remains unpaid at January end. Assume simplified accrual recognition follows service completion.
Calculate January billed amount, cash collections and earned revenue and explain why one date filter cannot answer all three.
Study the worked reasoning
January bills total $1,600; cash collections $1,000; earned January revenue $600. Service A belongs to December performance under the stated assumption despite January billing and payment. Use the relevant event date and reconcile receivables rather than relabel an invoice-date query as every financial measure.
Change a condition
Service B receives a $200 deposit in December before performance.
Study the changed-condition answer
January earned revenue remains $600, while the deposit affects the opening customer-obligation and cash positions. Do not count the December receipt again as January collection or remove earned January service merely because part was paid earlier.
Read the full connected study route and specialist method studios →
Read this explanation in the complete course companion →
Apply the six units to a cumulative problem →
CUMULATIVE PROBLEM · ALL WORK OPTIONAL
Connect the units: Data Management and SQL for Business
Work from these facts
Invoice headers: I1 $900, I2 $600. Lines: three for I1, two for I2. Payments: I1 $500 and $300; I2 $600. Describe a query returning one row per invoice with amount, paid and outstanding, including unpaid invoices.
Before opening the answer, identify the decision and feasible baseline, show each relevant calculation or evidence link, compare a strong alternative and state the condition that could reverse your recommendation. Do not assume a missing quantity, permission or future payment has been verified.
Compare the worked analysis
Aggregate payments first by invoice_id with SUM(amount), then LEFT JOIN that result to validated invoice headers. Use COALESCE(paid,0) for the reporting total only after deciding that no payment rows means zero payment. Outstanding is header amount minus total paid: I1 $100 and I2 $0. Do not join raw lines and raw payments then sum headers; for I1 that creates six combinations. Validate invoice uniqueness, payment reversals and statuses before assuming the simplified query fits real records.
Change the facts and test transfer
Add an unpaid I3=$600. A left join must retain it with $600 outstanding. Explain why an inner join or DISTINCT invoice amount gives the wrong result.
Compare the changed-fact reasoning
A payment aggregate left-joined to headers retains I3 with zero paid and $600 outstanding, giving $700 total outstanding. An inner join drops the unpaid invoice. DISTINCT invoice amount collapses different $600 invoices. Null handling must follow the business meaning, not merely make a query run.
Self-review: distinguish facts from assumptions; use correct units and dates; reconcile the calculation; explain the mechanism; compare a feasible alternative; identify the limits of the conclusion. If a changed condition defeats the original method, revise the method as well as the number.
Scope of this revision
These are AI-assisted editorial corrections to on-site teaching and analytical practice. They do not establish university equivalence, accreditation, independent faculty approval or demonstrated learner proficiency. The assigned readings remain part of the curriculum. Independent subject review and learner testing are pending; all practice and capstones remain voluntary.