Lawfare Academy ยท Complete Data Management and SQL edition 6
Manage a business fact from collection to a defensible decision
Data are observations; information requires a question
An amount of 50000 is not yet a usable sales fact. State its currency and scale, whether it is a quote, issued invoice or settled receipt, its identifier, time basis, source and correction status. In integer cents it may mean $500; in whole dollars it means $50,000. A database preserves representations of claims, not automatic truth. Information emerges when a defined transformation answers a defined question. A management recommendation adds further assumptions about costs, behavior and uncertainty. Keep those layers separate so that a convenient field name cannot substitute for evidence.
The existing Cedar model already distinguishes billing accounts, work orders, priced lines and payment events. Preserve those grains. This studio adds a lifecycle and system contract around them. A collection form should identify the originator and validation rule; storage should preserve identity and access authority; cleaning should retain the raw input and reason for a change; transformation should be versioned; a report should name its population and cutoff; later correction should remain traceable. Choosing a modern database cannot repair a missing business definition.
A conceptual model is a set of relationship claims
Before choosing SQL types, draw or describe the permitted entities and cardinalities. One billing account may have zero or many work orders; each accepted order must belong to one account in this stipulated process. Each order can contain multiple priced lines, identified by order and line number. A payment event and its allocations may be separate entities when one receipt can pay multiple orders. Optionality matters: allowing a draft order without an account is a policy different from requiring a known account before any order is saved. State which lifecycle states allow the exception and which transition must resolve it.
A conceptual entity model describes the domain. A logical relational model maps entities and relationships into tables, keys and constraints. A physical design selects engine-specific types, indexes, storage and access paths. An index may accelerate a lookup without changing the logical meaning of an order; splitting one payment into duplicate rows changes that meaning even if the report is faster. Evaluate correctness at the logical grain before optimizing the physical implementation. A many-to-many relationship generally needs an associative relation, such as payment_allocations(payment_id,order_id,allocated_cents), whose rows represent allocations rather than new receipts.
The catalog describes the schema: table and column names, types and declared constraints. A business dictionary must add meaning that the engine cannot infer, such as whether paid means authorized, captured or settled; whether a timestamp is local time or UTC; whether canceled orders remain in a denominator; and who owns a definition. A column can be technically non-null yet contain a plausible but wrong customer identifier. Catalog checks and stewardship complement each other rather than replace one another.
DBMS responsibilities and application responsibilities
A DBMS stores and retrieves data under its declared transaction, constraint and access behavior. It parses a query, selects an execution strategy and obtains the relevant records. SQLite is an embedded engine; its library compiles SQL into a program that is executed by a virtual machine. Its planner and storage layers implement mechanisms, not the business policy that a report should include only settled receipts. A server database adds a different connection and deployment architecture; its role features and concurrency rules must be checked for that engine rather than assumed from SQLite.
A spreadsheet or flat file can be appropriate for a bounded single-user dataset. A DBMS can centralize constraints, concurrent access and reproducible querying, but introduces administration, recovery, schema evolution and security responsibilities. Copying a shared spreadsheet into SQL without reconciling duplicate identities merely relocates the defect. Conversely, an isolated synthetic teaching file does not need a production cluster to demonstrate a three-row join. Select a system based on workload, integrity, recovery and authority requirements, not just row count or a product label.
Operational processing records individual events reliably. Analytical reporting combines selected events at a declared grain and cutoff. A reporting store may intentionally retain a historical snapshot or a denormalized representation for a defined purpose. It must explain refresh timing and reconciliation to sources; a daily extract is not a real-time balance simply because its chart updates in a browser. Preserve the original normalized transaction-price case: current catalog changes must not rewrite issued order-line prices.
Worked investigation: a small data-quality ledger
Use an independent synthetic raw receipt import with four rows. R 1 is 12500 cents for account A, R 2 is 7500 cents for account B, a second identical R 2 row repeats the same event, and R 3 is 4000 cents with account unresolved. The raw row sum is 31500 cents. A validated unique-event ledger retains R 1,R 2,R 3 once each, totaling 24000 cents. Known-account assigned receipts total 20000 cents; unresolved receipts total 4000 cents. These are three different measures: raw rows, unique events and resolved assignments.
Deduplicating R 2 is justified only because the external event identifier and payload establish the same receipt under a declared replay policy. Two genuine equal-value payments are not duplicates merely because they share amount and date. R 3's unknown account is not automatically zero revenue, a fictitious account 0 or a receipt to discard. If the intended measure is all unique settled receipts, include 24000 cents and disclose the unresolved allocation. If it is receipts allocated to known accounts, report 20000 and the separate 4000 suspense balance. A manager asking which account paid most needs the second population and its limitation.
Completeness, uniqueness, consistency, accuracy and timeliness answer different questions. Three of three unique receipts have amounts, so amount-field completeness is 100%. Only two of three have resolved accounts, so account-resolution completeness is 2/3. An event identifier uniquely represented once does not establish that its amount matches the bank. A raw duplicate rate of one extra row among four is 25%, whereas the fraction of distinct event identities affected by duplication is 1/3. Label the denominator. If a later authorized correction allocates R 3 to B, B becomes 11500 cents, A remains 12500 and unique total stays 24000. Preserve the original unresolved state and the correction evidence rather than rewriting the historical import as though it arrived complete.
Governance and roles that make the contract actionable
A business data owner approves meaning and permitted uses. A steward maintains definitions, quality exceptions and reconciliation. A database administrator manages engine configuration, recovery and access mechanisms. A data engineer builds ingestion and transformations; an analyst interprets the resulting measures. Small organizations may combine roles, but should still separate a proposed correction from authority to approve it. A successful query does not authorize access to private records. Use synthetic fixtures for practice and grant production access only through the actual organization's policy.
Quality controls should record the rule, detection time, affected identifiers, disposition, approving authority and reprocessing consequence. Avoid retaining unnecessary sensitive fields simply because storage is cheap. Access, retention, deletion and recovery have legal and operational dimensions requiring the applicable policy; this unit makes no specific retention-period claim. Florida is the contemporary state-law default when legal examples are later supplied, with federal obligations and explicit comparisons identified separately.
Optional practice and complete changed-fact models
Guided model: three receipt totals
Raw sum 12500+7500+7500+4000=31500 cents. Unique-event sum 12500+7500+4000=24000. Known-account sum 12500+7500=20000, with 4000 unresolved. Changed fact: the second 7500 row has distinct verified event IDR 4. It is a separate payment, so the unique total becomes 31500 rather than 24000. Equality of values alone does not authorize deduplication.
Independent model: a denominator and a correction
Amount completeness is 3/3 for unique events, account resolution 2/3. One extra raw duplicate among four rows is 25%; one affected event among three is 1/3. Changed fact: R 3 is validly assigned to B. B becomes 11500 cents and assignment completeness 3/3, while total receipts stay 24000. Retain the correction ledger and distinguish current resolved reporting from the original as-received snapshot.
Transfer model: a fast report with the wrong grain
A dashboard sums a receipt once per allocation and calls it total collections. An event allocated to two orders is counted twice. Aggregate allocated amounts at allocation grain or receipts at event grain according to the measure, and reconcile the two only under a valid full-allocation contract. Changed fact: one receipt is partially unallocated. The sum of allocations can legitimately be below total receipts; report the suspense difference instead of fabricating an allocation to force equality.
Unit rubric: 20 points
Award four points each for event/entity/relationship and time definitions; logical-versus-physical/system responsibilities; reproducible unique-event and assignment calculations; quality/governance/provenance controls; and changed-fact reasoning with a valid report population. Complete model keeps receipts distinct from allocations, produces 31500/24000/20000 and 4000 suspense under the original import, reports 2/3 resolution and preserves authorized corrections. A database constraint is necessary for some invariants but cannot prove every real-world fact.
Optional source summaries: OpenStax data-management focus was read for metadata, quality, governance and the relationship between managing data and analytical decisions. This studio supplies its own teaching and receipt ledger; no external chapter is required. SQLite architecture was read to confirm the distinction between SQL compilation, execution, planning and storage mechanisms. Those engine mechanisms do not supply business definitions or access authority. The examples above are original and use no real account or learner data.