Lawfare Academy

ORIGINAL METHOD STUDIO · VOLUNTARY

From business records to a reproducible SQL answer

General computer-science and finance readings do not teach a complete database workflow or spreadsheet-control process.

Complete study routes → · Method studios → · Substantive readiness audit → · Independent review packet →

Preparation: Be able to identify an invoice, its customer, its service date and its settlement date. Review DATA201 relational keys and TECH101 spreadsheet references.

Download the runnable fictional SQLite record and queries. Use a new disposable database. The file creates its own tables, demonstrates the bad join and then reconciles the correct customer balances.

Define the grain before calculating

A dataset must have a stated unit of observation. One row per invoice is different from one row per payment or invoice line. A business question such as unpaid sales at month-end needs invoice identity, earned amounts, settlement dates and an explicit cutoff. Do not begin by summing whatever numeric column happens to be available. Write the question in ordinary language, identify which events count and specify exclusions such as voids or payments after the cutoff. Then inspect uniqueness, missing values, date formats and currency. These checks establish what the rows mean; a valid SQL statement cannot repair a confused grain.

Why a join can manufacture revenue

Suppose invoice 101 for $1,000 has two payment rows, $300 and $200. Joining the invoice directly to payments repeats its $1,000 amount twice. Summing that joined amount produces $2,000 even though only one sale exists. Aggregate payments to one row per invoice before joining, or structure the query so the invoice total is not repeated. A DISTINCT amount is not a general repair: two different genuine invoices may have the same amount. Join on stable identifiers, verify cardinality and reconcile counts and totals before and after the join. Missing payment rows should normally preserve the invoice through a left join when the question concerns unpaid invoices.

A reproducible query

For illustrative tables invoices(invoice_id,customer_id,amount,service_date) and payments(invoice_id,amount,payment_date), first derive a paid-by-invoice table filtered to the reporting date. Join that aggregate to invoices earned by the cutoff, replace an absent paid amount with zero and calculate amount minus paid. The conceptual sequence is FILTER payments → GROUP BY invoice_id → LEFT JOIN invoices → FILTER service date → AGGREGATE customer balances. Document whether overpayments, refunds and unapplied receipts are handled separately. SQL dialects differ in date and parameter syntax; use the actual engine documentation and a disposable synthetic dataset, not production records, to develop the query.

Independent checks and spreadsheet transfer

The resulting receivable schedule should reconcile to the same opening balance plus earned credit sales minus settlements and adjustments. Independently inspect a few complete invoices, including no payment, multiple payments and a cutoff-date payment. In a spreadsheet, use a clearly separated input table and calculated output. A pivot table or grouped SUMIFS can implement the same aggregation, but copied formulas need tested absolute and relative references. Keep a control total, input provenance and a refresh date. Do not type a desired reconciliation difference into a plug cell. A difference is evidence to investigate, not a number to hide.

What a correct answer does not establish

An accounting total can reconcile while customer allocation is wrong, because one misassigned payment offsets another. Add identity-level checks, not only grand totals. A query can also be correct for the extracted data but incomplete because an entire source system was omitted. Review coverage, authorized access and the reporting boundary. Present the query, cutoff, exclusions and unresolved exceptions with the result so another person can reproduce it. A screenshot of the final number is weaker evidence than an auditable calculation and a controlled extract.

Work the integrated problem

At April 30, invoice 101 is $1,000 to customer A with April payments $300 and $200. Invoice 102 is $800 to A, paid $800 on May 2. Invoice 103 is $500 to B with no payments. All services were earned in April, there is no opening receivable, and there are no other transactions.

Build the April customer balances; show why a direct join followed by SUM(invoice amount) fails and specify an independent reconciliation.

Compare the complete reasoning

April sales total $2,300 and April settlements $500, so receivables are $1,800. A owes $500 on 101 and $800 on 102, total $1,300; B owes $500. The May 2 settlement is excluded from April cash. A left join that leaves one row for each unpaid invoice and two rows for 101 produces repeated invoice amounts of 1,000+1,000+800+500=$3,300, overstating sales by $1,000. Aggregate payments first, retain all three invoices and reconcile 0+2,300−500=1,800.

Change the facts

A $100 April payment was allocated to invoice 103 in the extract, but the bank confirms it belongs to invoice 101. What changes?

Compare the changed-condition reasoning

The total receivable remains $1,800 if this is solely a reassignment of an already included payment; A falls by $100 and B rises by $100. If the new payment was omitted entirely from the original $500 cash figure, total receivables instead fall to $1,700. Resolve which fact actually changed. Identity and completeness are separate controls.

Study the supporting methods

BCcampus · Database Design, 2nd Edition

BCcampus; Adrienne Watt and Nelson Eng. Adds a database-specific progression in modeling, relational structure, constraints, dependencies, normalization and SQL. Some examples use a particular database product; adapt syntax to the actual engine.

  1. Read chapters 1–6 for purpose, models and database context; diagram one authorized or fictional business workflow.
  2. Read chapters 7–10 for relations, keys, entity relationships and constraints; define each table's grain.
  3. Read chapters 11–12 for functional dependencies and normalization; explain an update anomaly and its repair.
  4. Read chapters 13–14 for development and users; define ownership, permissions and requirements.
  5. Read chapters 15–16 for SQL and manipulation; reproduce results on a synthetic dataset and reconcile totals.
  6. Use appendices B and C for design and SQL practice; compare the provided solution only after attempting the work.
Source check and limits

2026-10-24: Publisher contents retrieved; chapter list and SQL solution appendix present. Each chapter's factual assertions were not independently reviewed.

MIT OpenCourseWare · Data, Models, and Decisions (2014)

MIT OpenCourseWare; Robert Freund, Cynthia Rudin and Juan Pablo Vielma Centeno. Graduate-level method development in uncertainty, regression, simulation and optimization. Use freely posted materials; linked textbooks or third-party cases may require separate access. No affiliation or credit transfer.

  1. Start with the syllabus and probability topics; list the decision, uncertainty and information timing.
  2. Work the simulation material and available problem sets; validate a small case analytically first.
  3. Use regression assignments to practice model interpretation and validation with the available data.
  4. Work linear-optimization formulation; identify variables, objective, constraints and units.
  5. Study discrete optimization and compare an integer plan with the continuous relaxation.
  6. Use a case-learning module to write an action recommendation with assumptions, sensitivity and limits.
Source check and limits

2026-10-24: Official course page retrieved; assignments and case-learning resources listed. No claim that the external course's assigned commercial textbook is free.

Information Systems for Business and Beyond (2019)

David Bourgeois and contributing authors. Adds a business information-systems framework. The 2019 treatment is historical, especially its trends and platform examples; current AI capabilities and obligations require fresh primary sources and evaluation.

  1. Read chapters 1–3 for system components and technical choices; map the work rather than a product demo.
  2. Read chapters 4–5 for data and communication; identify authoritative records and interfaces.
  3. Read chapter 6 for security concepts; define access, recovery and incident ownership.
  4. Read chapters 7–9 for strategy, processes and people; examine the organizational bottleneck.
  5. Read chapter 10 for development; compare requirements, deployment, integration and vendor exit.
  6. Read chapters 11–13 critically for broader effects and historical trends; separate durable concepts from obsolete examples.
Source check and limits

2026-10-24: Author's book site and contents retrieved, including systems, data, security, processes, development and wider organizational effects.

U.S. GAO · 2025 Green Book

U.S. Government Accountability Office. A federal internal-control framework used here for comparative design analysis. It is not asserted to govern every private business or to certify an Academy control design.

  1. Read the framework's purpose and objectives and distinguish federal requirements from a private-business exercise.
  2. Examine the control environment and allocation of accountability.
  3. Use risk assessment to connect objectives, events and consequences.
  4. Evaluate control activities and evidence against the stated objective.
  5. Trace information, communication and monitoring, including exception response.
  6. Design a fictional control and explain limitations, override risk and the evidence needed to test it.
Source check and limits

2026-10-24: Official GAO page retrieved and federal-agency scope verified. Effective-date information is identified on that source.

Return to the course

Fictional original examples and explicit simplifying assumptions. This studio is not a complete textbook or independent approval of any linked course.