Chapter 3: The Accounting Data Environment

Accounting Analytics: An Integrated Approach

In this chapter

Part I of V: Foundations of Accounting Analytics

Chapter 3 of 3 in this Part

  • 3.1 From Accounting Records to Database Tables
  • 3.2 The Relational Database Model
  • 3.3 Keys and Relationships
  • 3.4 Relationships and Cardinality
  • 3.5 Entity-Relationship Diagrams
  • 3.6 The Accounting Data Model
  • 3.7 Exploring the Charles River Schema by Table Group
  • Guided Tutorial 3.1
  • 3.9 The Accounting Core as the Integration Hub
  • Guided Tutorial 3.2
  • 3.11 Comparing Simple and Complex Table Groups
  • 3.12 Looking Ahead

Learning objectives

  1. Explain the structure of a relational database, describe how tables, rows, columns, and data types organize accounting information, and describe how the Charles River database file stores that information.
  2. Distinguish between primary keys and foreign keys and explain how they establish relationships between tables in an accounting database.
  3. Read and interpret an Entity-Relationship diagram using crow’s foot notation to identify tables, relationships, and cardinality.

Learning objectives (continued)

  1. Map familiar accounting structures such as the chart of accounts, general ledger, and sub-ledgers to their representations as related tables in a database.
  2. Compare simple and complex table groups within the Charles River database and trace how cross-group bridge keys connect operational activity to the posted general ledger.
  3. Explain why the source-document columns in GLEntry act as a logical reference to many possible tables rather than a declared foreign key, and use them to trace a transaction across table groups.

Where in the database does the answer live?

  • You are the staff accountant from Chapter 1, and the controller’s Furniture question is still open
  • She hands you the database diagram: dozens of tables in groups, joined by lines
  • Symbols at each end of a line show how many rows on each side can be associated
  • You cannot yet tell which tables hold furniture revenue, its cost, or how a sale reaches its postings

3.1 From Accounting Records to Database Tables

3.2 The Relational Database Model

A table stores one kind of thing

The Charles River Customer table shown as a grid with five real customers and the columns CustomerID, CustomerName, CustomerSegment, Region, CreditLimit, and PaymentTerms. Numbered markers identify the table name, one column (CustomerSegment), one row (customer 4, Edwards, Stanley and Rivera), the primary key column (CustomerID), and a single cell value (the Region of customer 12).
Figure 3.1 · Anatomy of a Database Table

Values are integers, reals, text or NULL

Table 3.1 · Common Data Types and How the Charles River Database Stores Them

Data Type How Charles River Stores It Charles River Example
INTEGER INTEGER SalesOrderID in SalesOrder (for example, 1697). AccountNumber in Account (for example, 4010).
DECIMAL / NUMERIC REAL (floating point) StandardCost and ListPrice in Item (for example, 229.66 and 382.45). Debit and Credit in GLEntry.
TEXT / VARCHAR TEXT CustomerName in Customer (for example, “Walters PLC”). OrderNumber in SalesOrder (for example, “SO-2024-001697”).
DATE TEXT in year-month-day form InvoiceDate in SalesInvoice (for example, 2025-03-05). CreatedDate in GLEntry, which also includes the time.
BOOLEAN INTEGER, with 1 for true and 0 for false IsApproved in Supplier. IsActive in Customer and Item.

Watch out: not every number is a quantity

  • Account numbers are stored as integers, so tools will happily add or average them
  • The result is meaningless: account numbers are identifiers, not amounts
  • Other systems store codes as text to prevent arithmetic and keep leading zeros

3.3 Keys and Relationships

Keys connect the tables

  • A primary key identifies each row: unique and never blank; every Charles River table uses one integer surrogate key
  • Unique indexes protect document numbers, but not the number on a supplier’s own invoice, which is how Chapter 2’s duplicates got in
  • A foreign key refers to the primary key of another table, or of the same table
  • Charles River’s foreign keys are logical, not declared, so referential integrity is tested, and Power BI relationships are defined and checked rather than imported

A foreign key points to a primary key

Two tables side by side. The SalesOrder table shows orders 62, 85, and 59 with their order numbers and a highlighted CustomerID foreign key. The Customer table shows customers 1 (Walters PLC) and 4 (Edwards, Stanley and Rivera) with a highlighted CustomerID primary key. Arrows connect each order's CustomerID to the matching customer. A relationship line between the tables shows one customer to zero or many sales orders.
Figure 3.2 · Primary Keys and Foreign Keys Illustrated

Check your understanding

What is each SalesOrderLine column?

  1. SalesOrderLineID
  2. SalesOrderID
  3. ItemID
  4. Quantity

Keys and attributes in SalesOrderLine

  1. The primary key, a surrogate key
  2. A foreign key to SalesOrder
  3. A foreign key to Item: a cross-group bridge key into Master Data
  4. Neither: an attribute of the line

3.4 Relationships and Cardinality

Relationships come in three cardinalities

Three panels. One-to-one: WorkOrder connects to WorkOrderClose with exactly one on the WorkOrder side and zero or one on the WorkOrderClose side. One-to-many: Customer connects to SalesOrder with exactly one on the Customer side and zero or many on the SalesOrder side. Many-to-many: SalesOrder and Item are connected through the SalesOrderLine junction table, with one or many lines per order and zero or many lines per item.
Figure 3.3 · The Three Types of Cardinality

The many side multiplies rows in a join

  • Optionality: must a row take part? Every order has a customer, but some customers have no orders
  • A join that keeps only matching rows can omit the customers who never ordered
  • Joining customers to orders to lines repeats a customer once per line
  • Summing order-line amounts by line is right; counting customers by line overstates them

Check your understanding

What is the cardinality of each relationship?

  1. Customer and SalesOrder
  2. WorkOrder and WorkOrderClose
  3. SalesOrder and Item
  4. CashReceipt and SalesInvoice

Each pair has its cardinality

  1. One to zero or many: a customer can have no orders
  2. One to zero or one: a work order is closed at most once
  3. Many-to-many, through the junction table SalesOrderLine
  4. Many-to-many, through CashReceiptApplication: one check can pay several invoices

3.5 Entity-Relationship Diagrams

An ER diagram is the map of a database

  • Each table is a rectangle: a header with its name, then its columns, keys marked PK and FK
  • A gray header marks a table from another table group
  • Solid lines link a primary key to a foreign key; heavier amber lines cross into another group
  • A dashed amber line is the source-document trace, which is not a foreign key at all

Crow’s foot symbols show how many rows on each side

A reference table of the four crow's foot endpoint symbols. Exactly one (two bars): each SalesOrderLine belongs to exactly one SalesOrder. Zero or one (circle and bar): a WorkOrder has zero or one WorkOrderClose record. One or many (bar and crow's foot): a SalesOrder has one or more SalesOrderLines. Zero or many (circle and crow's foot): a Customer has zero or more SalesOrders. A note explains that each end of a line describes the table it touches.
Figure 3.4 · Reading Crow’s Foot Notation

3.6 The Accounting Data Model

The chart of accounts refers to itself

A portion of the real Charles River Account table with the columns AccountID, AccountNumber, AccountName, AccountType, AccountSubType, and ParentAccountID, including 1000 Assets, 1010 Cash and Cash Equivalents, 1020 Accounts Receivable, 1100 Fixed Assets, 1110 Furniture and Fixtures, 4000 Revenue, 4010 Sales Revenue - Furniture, and 4080 Sales Revenue - Design Services. Highlighted cells show that the ParentAccountID of Furniture and Fixtures (11) is the AccountID of Fixed Assets. Below the table, a tree shows the resulting hierarchy, beside a note that explains the self-reference and the Header subtype.
Figure 3.5 · The Chart of Accounts as a Database Table

Sub-ledgers post through the source-document trace

The Account table connects to the GLEntry table with a solid line: exactly one account to zero or many ledger entries. Dashed amber lines run from four source tables at the bottom (SalesInvoice from Order-to-Cash, PurchaseInvoice from Procure-to-Pay, PayrollPayment from Payroll and Time, and JournalEntry from the Accounting Core) to GLEntry, representing the source-document trace. A note explains that, for the sources shown, SourceDocumentType names the source table and SourceDocumentID holds the key of the row in that table (payroll summary postings carry a code instead), so the link is a logical one that analysts test, and that a few ledger rows typed PayrollPayment point to payments that do not exist.
Figure 3.6 · The Relationship Between the General Ledger and Sub-Ledgers

3.7 Exploring the Charles River Schema by Table Group

Master Data is small but shared everywhere

  • Item, Warehouse and Employee: reference data used across the database
  • Each item records the inventory, revenue and cost accounts it posts to
  • ItemID and the employee keys are cross-group bridge keys
  • Employee’s ManagerID points to another employee in the same table

Order-to-Cash chains header and line tables

  • Customer, then sales orders and their lines, shipments, invoices and receipts
  • Each document has a header table and a line table
  • SalesOrderLine and CashReceiptApplication are junction tables
  • Beyond the core path: pricing, design services, commissions and returns

Manufacturing separates the plan from the run

An ER diagram of the Manufacturing group: BillOfMaterial and BillOfMaterialLine linked to Item (Master Data) through ParentItemID and ComponentItemID, WorkOrder at the center linked to WorkOrderOperation, MaterialIssue and MaterialIssueLine, ProductionCompletion and ProductionCompletionLine, and WorkOrderClose. WorkOrder to WorkOrderClose is exactly one to zero or one, ProductionCompletion to ProductionCompletionLine is exactly one to exactly one, and links to Item are drawn in amber.
Figure 3.8 · Focused Entity-Relationship Diagram for the Charles River Manufacturing Group

Guided Tutorial 3.1: Reading the Charles River O2C Entity-Relationship Diagram

Read the O2C diagram in six steps

  1. Count the tables
  2. Identify the primary key of each table
  3. Identify the foreign keys in the SalesOrderLine table
  4. Read the relationship between Customer and SalesOrder
  5. Recognize a junction table
  6. Trace the fulfillment path

The O2C core path

An ER diagram of the O2C core path in three columns. The center column runs from Customer down through SalesOrder, Shipment, SalesInvoice, and CashReceiptApplication. The right column holds Item (Master Data, with a gray header), SalesOrderLine, ShipmentLine, and SalesInvoiceLine, each line table beside its header table, and CashReceipt sits at the bottom left beside CashReceiptApplication. Crow's foot lines show the relationships, including Customer to SalesOrder (one to zero or many), SalesOrder to SalesOrderLine (one to one or many), Item to SalesOrderLine as a heavier amber cross-group link, ShipmentLine to SalesInvoiceLine (zero or one on both ends), and CashReceipt and SalesInvoice to the CashReceiptApplication junction table. A legend explains the line styles.
Figure 3.7 · Entity-Relationship Diagram for the Charles River O2C Core Path

Orders, lines and shipments

Detail of: An ER diagram of the O2C core path in three columns. The center column runs from Customer down through SalesOrder, Shipment, SalesInvoice, and CashReceiptApplication. The right column holds Item (Master Data, with a gray header), SalesOrderLine, ShipmentLine, and SalesInvoiceLine, each line table beside its header table, and CashReceipt sits at the bottom left beside CashReceiptApplication. Crow's foot lines show the relationships, including Customer to SalesOrder (one to zero or many), SalesOrder to SalesOrderLine (one to one or many), Item to SalesOrderLine as a heavier amber cross-group link, ShipmentLine to SalesInvoiceLine (zero or one on both ends), and CashReceipt and SalesInvoice to the CashReceiptApplication junction table. A legend explains the line styles.
Figure 3.7 · Entity-Relationship Diagram for the Charles River O2C Core Path (detail)

Invoices and their settlement

Detail of: An ER diagram of the O2C core path in three columns. The center column runs from Customer down through SalesOrder, Shipment, SalesInvoice, and CashReceiptApplication. The right column holds Item (Master Data, with a gray header), SalesOrderLine, ShipmentLine, and SalesInvoiceLine, each line table beside its header table, and CashReceipt sits at the bottom left beside CashReceiptApplication. Crow's foot lines show the relationships, including Customer to SalesOrder (one to zero or many), SalesOrder to SalesOrderLine (one to one or many), Item to SalesOrderLine as a heavier amber cross-group link, ShipmentLine to SalesInvoiceLine (zero or one on both ends), and CashReceipt and SalesInvoice to the CashReceiptApplication junction table. A legend explains the line styles.
Figure 3.7 · Entity-Relationship Diagram for the Charles River O2C Core Path (detail)

Checkpoint

  • How many foreign keys does the diagram show for the SalesOrderLine table?
  • Which tables serve as junction tables?
  • What is the cardinality of the relationship between Customer and SalesOrder?

3.9 The Accounting Core as the Integration Hub

Every business cycle posts to GLEntry

  • Order-to-Cash posts through invoices, shipments, receipts and their applications
  • Procure-to-Pay through goods receipts, supplier invoices and payments
  • Manufacturing through material issues, completions and work order closes; payroll through summaries, payments and remittances
  • JournalEntry holds the manual entries, such as accruals and adjustments

The Accounting Core and its connections

An ER diagram of Account, GLEntry, and JournalEntry. Account has a self-reference for its parent account and connects to GLEntry with a solid line. JournalEntry has a self-reference for reversing entries, links to Employee (Master Data) through its created-by and approved-by columns, and connects to GLEntry through a dashed amber source-document trace. CostCenter (Organizational Planning) links to GLEntry. Dashed amber lines connect five source tables at the bottom (SalesInvoice, Shipment, PurchaseInvoice, MaterialIssue, and PayrollPayment) to GLEntry.
Figure 3.9 · Entity-Relationship Diagram for the Charles River Accounting Core and Source Document Connections

GLEntry is keyed to accounts and cost centers

Detail of: An ER diagram of Account, GLEntry, and JournalEntry. Account has a self-reference for its parent account and connects to GLEntry with a solid line. JournalEntry has a self-reference for reversing entries, links to Employee (Master Data) through its created-by and approved-by columns, and connects to GLEntry through a dashed amber source-document trace. CostCenter (Organizational Planning) links to GLEntry. Dashed amber lines connect five source tables at the bottom (SalesInvoice, Shipment, PurchaseInvoice, MaterialIssue, and PayrollPayment) to GLEntry.
Figure 3.9 · Entity-Relationship Diagram for the Charles River Accounting Core and Source Document Connections (detail)

Each source document reaches GLEntry by the trace

Detail of: An ER diagram of Account, GLEntry, and JournalEntry. Account has a self-reference for its parent account and connects to GLEntry with a solid line. JournalEntry has a self-reference for reversing entries, links to Employee (Master Data) through its created-by and approved-by columns, and connects to GLEntry through a dashed amber source-document trace. CostCenter (Organizational Planning) links to GLEntry. Dashed amber lines connect five source tables at the bottom (SalesInvoice, Shipment, PurchaseInvoice, MaterialIssue, and PayrollPayment) to GLEntry.
Figure 3.9 · Entity-Relationship Diagram for the Charles River Accounting Core and Source Document Connections (detail)

Watch out: the trace is not a foreign key

  • A foreign key refers to one table; SourceDocumentID refers to a different table on each row
  • So the link has to be tested rather than trusted
  • At Charles River, a few ledger rows typed PayrollPayment point to payments that do not exist

Guided Tutorial 3.2: Tracing a Sale from Sales Order to General Ledger

Trace one sale in seven steps

  1. Find the invoice
  2. Read the invoice line
  3. Follow the foreign keys
  4. Find the invoice’s ledger postings
  5. Translate the AccountIDs into account numbers
  6. Find the shipment’s postings
  7. Trace the payment

One sale, from order to ledger

A step-by-step trace of invoice SI-2025-007947. Steps 1 to 4 follow sales order SO-2024-001697 for customer 135, Sullivan-Mcdonald, through sales order line 6522 (item FUR-DSK-0075, Alder Desk), shipment line 10449 on shipment SH-2025-003603, and invoice line 10645 (2 units at $344.21). Step 5 shows the invoice's four GLEntry rows found through SourceDocumentType SalesInvoice and SourceDocumentID 7947: Dr Accounts Receivable $787.48, Cr Sales Revenue - Furniture $688.42, Cr Freight Revenue $51.00, and Cr Sales Tax Payable $48.06. Step 6 looks up AccountID 42, account 4010, a revenue account. Card A shows the shipment's COGS and inventory postings of $459.32, and card B shows the cash application of $787.48 from receipt CR-2025-003043.
Figure 3.10 · Annotated Charles River Cross-Group Traced Path

Keys lead from the order to its shipment

Detail of: A step-by-step trace of invoice SI-2025-007947. Steps 1 to 4 follow sales order SO-2024-001697 for customer 135, Sullivan-Mcdonald, through sales order line 6522 (item FUR-DSK-0075, Alder Desk), shipment line 10449 on shipment SH-2025-003603, and invoice line 10645 (2 units at $344.21). Step 5 shows the invoice's four GLEntry rows found through SourceDocumentType SalesInvoice and SourceDocumentID 7947: Dr Accounts Receivable $787.48, Cr Sales Revenue - Furniture $688.42, Cr Freight Revenue $51.00, and Cr Sales Tax Payable $48.06. Step 6 looks up AccountID 42, account 4010, a revenue account. Card A shows the shipment's COGS and inventory postings of $459.32, and card B shows the cash application of $787.48 from receipt CR-2025-003043.
Figure 3.10 · Annotated Charles River Cross-Group Traced Path (detail)

The trace leads from the invoice to the ledger

Detail of: A step-by-step trace of invoice SI-2025-007947. Steps 1 to 4 follow sales order SO-2024-001697 for customer 135, Sullivan-Mcdonald, through sales order line 6522 (item FUR-DSK-0075, Alder Desk), shipment line 10449 on shipment SH-2025-003603, and invoice line 10645 (2 units at $344.21). Step 5 shows the invoice's four GLEntry rows found through SourceDocumentType SalesInvoice and SourceDocumentID 7947: Dr Accounts Receivable $787.48, Cr Sales Revenue - Furniture $688.42, Cr Freight Revenue $51.00, and Cr Sales Tax Payable $48.06. Step 6 looks up AccountID 42, account 4010, a revenue account. Card A shows the shipment's COGS and inventory postings of $459.32, and card B shows the cash application of $787.48 from receipt CR-2025-003043.
Figure 3.10 · Annotated Charles River Cross-Group Traced Path (detail)

Checkpoint

You should be able to:

  • show that the invoice’s ledger postings balance and that the debit to Accounts Receivable equals the invoice’s GrandTotal of $787.48;
  • identify SourceDocumentType and SourceDocumentID as the columns that trace a GLEntry row back to its source document;
  • explain why the same sale produces postings from several different documents: the shipment, the invoice, the cash receipt, and its application;
  • translate an AccountID in GLEntry into an account number through the Account table;
  • optionally, find a fifth document by filtering the SalesCommissionAccrual worksheet for SalesInvoiceLineID 10645 and finding that record’s rows in GLEntry, which accrue the sales commission on the line.

3.11 Comparing Simple and Complex Table Groups

Three patterns run across the table groups

  • A group grows with the process it records: a few reference tables, or a whole revenue cycle
  • The same relational principles apply at every scale
  • Cross-group bridge keys, such as ItemID, AccountID and EmployeeID, tie the database together

Three groups, three sizes

Table 3.2 · Comparison of Three Charles River Table Groups

Feature Master Data Order-to-Cash Accounting Core
Key tables Item, Warehouse, Employee Customer, SalesOrder, SalesOrderLine, Shipment, ShipmentLine, SalesInvoice, SalesInvoiceLine, CashReceipt, CashReceiptApplication, and the pricing, service, commission, and returns tables Account, JournalEntry, GLEntry
Complexity profile Small and relatively static. Referenced by every other group. The largest group, with deep relationship chains and sub-paths for pricing, services, commissions, and returns. Simple in structure but deep in scope. GLEntry is the largest table in the database and the integration point for all other groups.

Check your understanding

What connects each pair?

  1. The items a customer ordered
  2. A journal entry and the employee who approved it
  3. A ledger entry and its cost center
  4. A ledger posting and the invoice behind it

Each connection has its key

  1. ItemID, a bridge key from Order-to-Cash to Master Data
  2. An employee key under its role name, the approver on JournalEntry
  3. CostCenterID, a bridge to Organizational Planning
  4. The source-document columns: a logical reference, not a key

3.12 Looking Ahead

Back to the controller’s question

  • Furniture revenue is posted to the ledger from sales invoice lines
  • Its cost is posted from the shipments
  • The Item table’s ItemGroup tells you which products are Furniture
  • Next, the Part I case: frame the question, test the data, reconcile the sub-ledger to the ledger

Summary

  • Relational databases store tables of rows and columns with defined types
  • Primary keys identify rows; foreign keys connect tables, tested rather than enforced at Charles River
  • Cardinality and optionality decide how joins behave, and ER diagrams make them visible
  • The chart of accounts, the ledger and the sub-ledgers are related tables
  • Bridge keys tie the table groups together, and GLEntry integrates them

Key terms

Cardinality · Column · Composite key · Cross-group bridge key · Crow’s foot notation · Data dictionary · Data type · Entity-Relationship (ER) diagram · Foreign key · Header and line tables · Junction table · Many-to-many relationship · One-to-many relationship · One-to-one relationship · Optionality · Primary key · Referential integrity · Relational database · Row · Self-referencing relationship · Source-to-ledger traceability · Surrogate key · Table · Table group · Unique constraint

Practice and next steps

  • Financial Accounting
    • Exercise 3.1: Tracing a Purchase Transaction Through the Charles River Database
    • Exercise 3.2: Mapping the Charles River O2C Group to the Revenue Cycle
  • Managerial Accounting
    • Exercise 3.3: Mapping the Charles River Manufacturing Group
    • Exercise 3.4: Mapping the Keys Behind a Budget-Versus-Actual Report
  • Auditing
    • Exercise 3.5: Planning a Data Extraction Strategy for the Charles River Audit
    • Exercise 3.6: Assessing Referential Integrity Across the Charles River Database

Next: Comprehensive Case: Getting the Data Ready for the Furniture Margin Question

About these slides

These slides accompany Accounting Analytics: An Integrated Approach, licensed under CC BY-SA 4.0. Every figure and table comes from the chapter:

https://aa.accountinganalyticshub.com/chapters/03-accounting-data-environment/chapter.html