Skip to content

Systems and records

Dataset relational integrity at delivery: links that resolve but lie

By SourceX Editorial · Updated

10 sections

Short answer

Dataset relational integrity at delivery means every link resolves to the right kind of record, agrees with other paths to that record, respects time and assembles the cases the buyer expects. Orphan checks test only the first. In a public SAP document flow export of 167,766 rows that loads without a warning, zero-padding short keys created 68 new matches, and every one pointed at a document of a different category.

System export

Dataset relational integrity

This page covers dataset relational integrity at delivery: links that resolve but lie.Illustrative

Key takeaways

  • A file that parses and a key that resolves prove less than a buyer needs: the link must also hit the right kind of record, agree with other paths, respect time and close a case.
  • In pm4py's copy of an SAP document flow table, 1,347 of 110,538 document numbers carry two or more category codes, so a number alone is not a key.
  • Zero-padding 145 short predecessor numbers found a match for 68, and none of the 68 shared a category with its match: normalization manufactured false links.
  • 7,689 successor keys equal their row's own creation date, so those rows cannot name a single document.
  • The largest connected case shrinks from 14,737 documents to 4,510 under two key decisions, so the case rule belongs in the delivery manifest.

What does dataset relational integrity mean at delivery?

Dataset relational integrity at delivery means every link in the delivered files does four things: it resolves to a record that exists, points at the right kind of record, agrees with any other path to the same record and respects time. Together, those links must assemble the cases the buyer will train or evaluate on. An orphan check tests only the first of the four.

In business task data the links are the task. A support model needs each message tied to its ticket, each attachment to its message and each resolution to the case it closed. A finance agent needs each invoice tied to the delivery and order it bills. When a link points at the wrong record, the file still opens, every join still returns rows, and the model learns from a case that never happened.

The site's existing referential integrity audit covers orphans, cleared links, merged IDs and their causes. This page starts where that one stops, with links that resolve and are still wrong, and it measures them on a public export rather than an invented one.

Does a clean load and a matching checksum settle anything about relationships?

No. A checksum proves the bytes match what the supplier hashed, and a clean parse proves the syntax; neither looks at what a key points to. The strongest objection to relationship testing is that an export from a production system must already be consistent, because the system enforced its own rules. The public file used here is a direct test of that objection.

The file is a copy of SAP's VBFA table shipped as test data in pm4py, the open-source process mining library (repository process-intelligence-solutions/pm4py, commit 9521745, path tests/input_data/ocel/VBFA.zip). SAP's documentation describes VBFA as the sales and distribution document flow: each record links a preceding document to a subsequent one and carries the category of each, and SAP's process mining content for order to cash says the relationships between documents are found in this table. The repository's test-data folder carries no note on where the copy came from, so this page treats it as an example export, not as any company's records.

At file level it is clean. It holds 167,766 rows of 16 fields each under one header, with no exact duplicate rows and no byte-order mark. Every line ends in CRLF, the record separator RFC 4180 describes for CSV. Every creation date and time parses as a real timestamp, from November 1994 to November 2021. A loader accepts it without a warning, and a checksum computed on receipt would match. The checks below are where it stops being clean.

Eight relationship checks and what each found in the export

Six of the eight checks found something a buyer would need explained before accepting the file, and none of the six is visible to a file-level test; the other two found one disagreement and a timestamp artifact. Each check is a single rule the script applies to every row; the results are counts, not samples.

Category codes are SAP's own. SAP's documentation uses C for orders; J and M are read here as deliveries and billing documents, the order-to-cash sequence SAP's process mining content describes, and that reading should be confirmed against the source system's code list before anyone relies on it. The matrix below gives each rule, its result and the decision it forces.

Eight relationship checks and what each found in the export
CheckRule the script appliesResult in the VBFA exportWhat it decides
1. Link key is uniqueNo two rows share predecessor number and item, successor number and item, and successor category1 key appears twice, five days apart in June 1995, with quantities 1 and 10 and currency codes DEM and PTEWhich row is the real event, or whether numbers were reused
2. Number is a keyEach document number carries one category code across both columns1,347 of 110,538 numbers carry two or more codes; none of the 1,347 carries two codes that differ only by case; 6,653 groups of numbers differ only by letter case, so compare case-sensitivelyJoin on number plus category, never on number alone
3. Padding is safeShort all-digit numbers, zero-padded to 10 characters, match only same-category documents145 short numbers; 68 gain a padded match; 0 of the 68 share a category with itNormalizing would add 68 false links
4. Key holds an identifierA key column holds no values of another type7,689 successor keys are 8-digit valid dates equal to the row's own creation dateThose rows cannot name a single document
5. Upstream link presentEach category-J document that leads somewhere also has an incoming link5,340 of 15,777 have none in the fileA source rule to confirm, not yet a defect
6. Paths agreeWhen an M document links to an order and a J document, that J document's own order links include one of the M document's orders1 of 8,961 disagreesOne case to investigate; the pattern holds
7. Time runs forwardA J document's first M link is not earlier than its first order link4 of 8,933 fail by timestamp and 0 by calendar day; all 4 M links carry 00:00:00Treat midnight as date-only before testing order
8. Cases closeConnected documents form bounded casesLargest connected group: 14,737, 9,499 or 4,510 documents, depending on the key ruleShip an explicit case rule

Keys that look valid and are not: categories, padding and dates

In this file a document number is not an identifier; the pair of number and category is. Of the 110,538 distinct number strings, 1,347 appear with two or more category codes, most often Q together with X (523 numbers). A buyer who joins on the number alone, which is what most loaders do with a column that looks like a document number, ties unrelated documents together.

Padding shows how a sensible fix can make that worse. 145 distinct predecessor numbers are all digits but shorter than ten characters, a three- or five-digit value where most of the file uses ten. None matches a successor exactly. Left-padded with zeros, 68 suddenly match a document elsewhere in the file, and in all 68 the matched document carries a different category: 67 predecessors coded 2 or l now meet documents coded Q. The existing audit guide is right to normalize keys in one documented step; this file adds two conditions, that the step keeps the category in the key and that it reports how many matches it creates and whether their categories agree.

Another 7,689 rows carry a successor key of exactly eight digits. All 455 distinct values are valid calendar dates, and in every one of the 7,689 rows the key equals that row's own creation date; in 7,140 the successor item number also equals the creation time. These rows are categories Q (6,755) and R (934). Whatever the source system meant to store, the delivered column does not identify one document for these rows, and a type-inferring loader would quietly turn the keys into dates.

Keep keys as text. The pandas documentation tells users to read columns as str or object to preserve values rather than interpret them, and pm4py's own example script for this file reads every column as a string. The duplicated link key from check 1 is the last trap in this family: the same delivery item and billing item appear twice, with different quantities, amounts and currency codes. Two events share one key, so either numbers were reused or a key column is missing from the export.

Do the paths agree, and does time run forward?

Mostly yes, and the exceptions show why each check needs a written rule for its edge cases. The flow table stores more than the immediate step: an M document can link both to the order and to the J document it follows. That redundancy is a free consistency test. Of 8,961 M documents linked to both, exactly one links to a J document whose own order links share none of the M document's orders. One in nearly nine thousand is small, but it is one training case whose order, delivery and invoice disagree about what happened.

The time check looked worse than it was. For 8,933 J documents with both an order link and an M link, four have a first M link timestamped before their first order link. All four fall on 19 September 1997, all four M links carry the time 00:00:00 and all four order links carry afternoon times. By calendar day there are no violations. Midnight behaves like a missing time here: 709 rows carry 000000, 78 of them on order-to-J or J-to-M links.

A chronology check that compares full timestamps without a date-only rule reports false time travel; one that drops times altogether misses same-day disorder. Write the rule into the manifest: compare by day when either side's time is 000000, by full timestamp otherwise, and state the clock, since these times carry no zone.

Where does one case end in a linked export?

Where the manifest says it does; the links alone will not tell you. Treat every row as an edge and every connected group of documents as a case, and the largest case in this file holds 14,737 documents when nodes are bare numbers, 9,499 when nodes are number and category pairs, and 4,510 when the date-valued keys are dropped as well. The second-largest group is 1,128, 1,050 and 1,050 documents under the same three rules.

The remaining giants are not errors. Some documents legitimately touch many others: under the strictest rule one category-7 document links to 401 distinct documents, and two category-8 documents link to 205 and 180. A document that legitimately spans hundreds of orders, as a shipment or a contract does in many systems, merges them into one connected group. SAP's process mining content assigns a case ID to related preceding and subsequent documents as an explicit processing step, which is the point: a case is a rule applied to the links, and the buyer needs that rule written down, for example one case per order with everything downstream of it.

The same reasoning applies to check 5. Of the 15,777 category-J documents that lead to another document, 5,340 have no incoming link in the file. If the source system allows that kind of document without an order, they are complete cases that start later in the chain; if it does not, they are orphans, perhaps created by the extract's date window. The file cannot say which. The supplier can, and the answer belongs in the manifest's exceptions.

Horizontal bars of the largest connected case in one SAP document flow export under three key rules, 14,737 documents for bare numbers, 9,499 for number and category and 4,510 after dropping date-valued keys, beside two counts: 68 of 68 padded matches cross category, and 1,347 numbers carry two or more categories.
One link table, three case sizes. Counts from this article's script on pm4py's VBFA test file, commit 9521745.

The relationship manifest to sign with the delivery

Declare every relationship as a row with its full key, allowed target types, key format, time rule, case rule and the counts measured at export, so the buyer can rerun the same checks on arrival and compare numbers rather than impressions.

The W3C metadata vocabulary for tabular data offers a machine-readable home for part of this: a foreignKeys property whose columnReference names the referencing columns and whose reference names the target table and columns. A declared foreign key says only that values match, so declare composite keys that include the category, and carry the rest of the fields in the manifest below. Example values come from the VBFA run; the allowed-type example is illustrative.

The relationship manifest to sign with the delivery
Manifest fieldWhat it declaresExampleFeeds check
Relationship and directionChild, parent and which way the link pointsDelivery item to billing item, predecessor to successorAll
Full keyEvery column needed to name one recordNumber, item and category; never number alone1, 2, 3
Allowed target typesWhich categories each link may point toBilling links may point only to orders or deliveries (illustrative)2, 6
Key formatType, length, padding and case rule, stated as textText; codes case-sensitive; short values listed, not padded3, 4
Time ruleClock, zone and date-only handlingLocal system time; 000000 treated as date-only7
Case ruleHow links become casesOne case per order and everything downstream5, 8
Counts at exportRows, distinct keys and each check's result, with file and script hashes167,766 rows; 1,347 multi-category numbers; 68 padded collisionsAll
Known exceptionsBreaks the supplier accepts, with reasons5,340 J documents without an order link, if the source allows them5

Acceptance rule, reproducibility checklist and limits

Accept a delivery only when the buyer's own rerun of the manifest's checks, in the buyer's consumption format, reproduces the supplier's counts exactly and every non-zero count has a line in the exceptions. Hold it when a count differs or an exception is unexplained. Send it back when the supplier cannot state a case rule, because without one no case count can be reproduced.

The limits of this evidence are real. It is one public file of undocumented origin, tested at document level; item-level agreement, quantities along links and anything needing other SAP tables were not measured, and the names for codes J and M rest on the reading stated earlier. The counts describe this export, not any company's records. The next evidence to collect is the same script run on a real delivery in the buyer's own tool, and on a second export of the same scope, to see whether the counts hold between runs.

Work through the checklist below at the acceptance gate; each line names an artifact or a count, so a second reviewer can repeat it.

Checklist · 8 items

  1. Pin the delivery: file names, byte sizes and SHA-256 hashes in the manifest, plus the version of the script that produced the supplier's counts.
  2. Load every key column as text in your own tool and format, and compare row counts with the manifest before running any join.
  3. Test uniqueness on the full compound key and list every duplicate with all of its rows.
  4. Count numbers that carry more than one type code; if any do, put the type into every join.
  5. Before normalizing a key, count the matches normalization would add and confirm each matched pair shares a type.
  6. Scan every key column for values of another type, such as dates, times or amounts, and settle their meaning with the supplier.
  7. Run path agreement wherever two routes reach the same record, and chronology with the manifest's date-only rule.
  8. Build cases with the declared rule and compare the case count and the largest case with the manifest.

0 of 8 ticked. Tick each item as you go.

Putting relationship tests into a SourceX data request

SourceX sources datasets on request rather than from stock, and its request form asks for scope, volume, format, timeline, licensing and de-identification requirements, with a field for additional specifications. That field is where the manifest template and the checks above belong, written as acceptance tests: the relationships that must hold, the full key for each, the case rule and the counts you expect to reproduce.

SourceX's FAQ says AI developers receive datasets with documented rights, permitted uses and delivery requirements. A relationship manifest turns the delivery requirements into something a script can confirm. It also keeps one boundary visible: these checks decide whether delivered records are usable for your task, not whether they may be licensed, which is a separate rights question settled before anything is delivered.

Methods note: file, script, counting rules and gaps

Data: process-intelligence-solutions/pm4py on GitHub, branch release, commit 9521745bdbe17cc574f417a850ff6d78b1ffbfcf (committed 2026-10-19), file tests/input_data/ocel/VBFA.zip (SHA-256 e809da46886a93bd4bc5afae423bc2f892ce94e38194fb23b7a6b9394fda5d92). Its single member, also named VBFA.zip, is CSV text of 15,458,263 bytes (SHA-256 b80c8ea8c4b42c94e20547b614156b1c40f74fcebf18cf5866f3200dd186f8d7). Read on 2026-10-28 by a script that runs no repository code (bin/xs0926_vbfa_checks.py in the writer's scratch folder, with its printed output beside it, and its rerun xs0926_vbfa_checks_v2.py, which adds the letter-case count).

Counting rules: every field is kept as its exact string, compared case-sensitively; a byte-order mark would be removed (none was present). Check 1 keys on predecessor number, predecessor item, successor number, successor item and successor category. Check 2 counts distinct number strings over both columns, each with the category from its own column. Check 3 takes predecessor values made only of digits and shorter than ten characters and left-pads them with zeros to ten. Check 4 takes successor values of exactly eight digits that parse as a calendar date. Check 5 counts distinct number and category pairs seen as predecessors and never as successors. Checks 6 and 7 work at document level, ignoring item numbers; check 7 compares the earliest creation date plus time of each link type as 14-digit local-time strings, strictly earlier, and separately by date alone. Check 8 joins rows as undirected edges with union-find under the three node rules named in the text.

Not measured: item-level agreement, quantities and amounts along links, and anything that needs order, delivery or billing header tables, which are not in the file. A reviewer can recompute check 3 from the text alone: 68 padded matches, 0 sharing a category, so all 68 would be false links.

Frequently asked questions

What is relational integrity in a delivered dataset?

It is the property that every link between records in a delivery resolves to an existing record of the right type, agrees with other paths to the same record, respects time order and assembles the cases the buyer expects. Orphan checks cover only the first part.

Is a foreign key check enough to accept a delivery?

No. A foreign key check confirms that each value has a match somewhere. In the public SAP export tested here, zero-padding short keys produced 68 new matches and every one pointed at a document of a different category, so a matching value can still be a wrong link.

Should identifiers be loaded as text or as numbers?

As text. Numeric loading drops leading zeros and can turn date-like keys into dates; pandas documents reading columns as str or object to keep values uninterpreted. Normalize only in one documented step that keeps the record type in the key and reports the matches it adds.

How do you decide where one case ends in linked business records?

With a stated rule, such as one case per order and everything downstream of it. Connected groups alone can merge hundreds of orders through a shared shipment or contract; in the export tested here the largest group held 14,737 documents when linked by bare numbers.

What should a delivery manifest say about relationships?

For each link: direction, full key, allowed target types, key format, time rule and case rule, plus the counts measured at export with file and script hashes, and the exceptions the supplier accepts. The buyer reruns the same checks and compares counts before accepting.

Sources

  • pm4py ships a copy of SAP's VBFA document flow table as test data; at commit 9521745 it holds 167,766 CSV rows of 16 fields, which this article's script checked. Source
  • pm4py's own example script for the VBFA file reads every column as a string (dtype str). Source
  • SAP documents VBFA as the SD document flow, linking a preceding document to a subsequent one with the category of each. Source
  • SAP's order-to-cash process mining content says relationships between documents are found in VBFA and assigns related documents a case ID in a processing step. Source
  • SAP's sales and distribution monitor guide refers to orders as the document category where VBTYP is C. Source
  • RFC 4180 describes each CSV record as a separate line delimited by a CRLF line break. Source
  • The W3C Metadata Vocabulary for Tabular Data defines foreignKeys, with columnReference naming referencing columns and reference naming the target table and columns. Source
  • The pandas read_csv documentation says to use str or object types to preserve values rather than interpret them. Source
  • SourceX's request form asks for scope, volume, format, timeline, licensing and de-identification requirements and has a field for additional specifications; datasets are sourced on request. Source
  • SourceX's FAQ says AI developers receive datasets with documented rights, permitted uses and delivery requirements. Source

Tell us what data you need

Share scope, volume, format, timing and licensing needs. Datasets are sourced on request.

See if your company qualifies