
Ontology in Practice series 3/4 · (1) The Meaning of Data That Should Survive a System Change · (2) Four Tasks Behind a Sewing Data Dictionary · (3) Finding Meaning in a Database Without Keys · (4) Letting AI Answer on Top of a Meaning Layer
KEY POINTS
For a database with no links between tables, we inferred the links from which values contain which, and divided the tables into four domains: customer, store, product and operation. Calculation rules hidden in report formulas were pulled out and their meaning confirmed with the customer, and columns that look alike by name but are updated by different rules were given separate definitions. Season classification, whether closed stores are included, and the boundary between confirmed and provisional data were agreed with the customer and kept on record.
When we took over the database of an ERP that a fashion brand had used for many years, the first thing we confirmed was that nothing linked the tables to each other. The database had a large number of tables, but nowhere did it say which column of which table pointed to what in another table. The ERP vendor did not disclose its internal logic either, so there was no way to tell which combination of tables produced the numbers shown on screen.
“Can store sales be recalculated from this database?”
The short answer is yes, but first the meaning of the data had to be restored piece by piece. This article covers four tasks we used to find meaning in a database with no linking information. This part is about working backwards to the definitions of data in a customer system that was already in operation.
The state of the database
The diagnosis before the work started found the following.
| Item checked | What we found |
|---|---|
| Links between tables | No foreign key constraints, so join keys cannot be known from the database alone |
| Screens versus tables | The ERP’s internal logic is not disclosed, so the source tables of on-screen numbers are unknown |
| State by schema | Schemas still being updated are mixed with schemas that stopped updating long ago |
| Leftovers | Temporary tables and traces of bulk loads remain |
A foreign key is linking information written into the database that says which row of another table a column points to. If the store code column of the sales table has a foreign key saying “this value points to the store code in the store table”, the relation between the two tables is known without anyone explaining it. Without it, people have to find the relations between tables themselves.
Task 1. Inferring links from which values contain which
If links are not written down, they have to be found in the data values. The method used for this is inclusion dependency analysis. If every value in one column appears in the list of values of another column, the first column is inferred to point to the second.1
A class register is a good comparison. If every student number on the list of people who handed in an assignment exists in the school’s enrollment record, the student number field on that list can be seen as pointing to the enrollment record. If it contains numbers that are not in the enrollment record, the two are either different numbering systems or one of them has errors.
Test: set of values in column A ⊆ set of values in column B
Example) every value of sales.store_code exists in store.store_code
→ sales.store_code is inferred to be a link pointing to store.store_code※ Table and column names are examples for explanation.
Grouping the tables along the links inferred this way revealed four domains: customer, store, product and operation. The classification at this stage covers every table without exception, and we agreed with the customer to trim it whenever the analysis shows a column is not used. Values can overlap by chance, so an inferred link is finalized only after the person in charge of that business area has confirmed it.

Task 2. Pulling out calculation rules hidden in report formulas
After finding the links, we checked how the numbers are calculated. When we opened the formulas in the reporting tool the customer used, confirmed sales were being produced in different ways depending on store type. Most stores used the confirmed price recorded on the sales record as it is, but some online sales channels calculated a confirmed price separately by multiplying the selling price by a fixed ratio.
When we asked the customer, there was a reason. For those channels only the selling price was registered and margin and commission were not entered, so the report had been producing an estimate of its own. This confirmed price feeds straight into the calculation of distribution commission and contribution margin, so if it is recalculated in a new system without knowing the rule, profit by channel comes out different.
Rules like this are written in the judgment rule (SWRL) format from part 1.3
Condition: sales channel = online channel group AND margin information = none
Conclusion: confirmed price = selling price × channel estimate factor※ An example to show only the format of the rule. The actual factor is not given.
Two things change once the rule is written down as a document. The same numbers can be reproduced after the system is replaced, and sales calculated from an estimate can be told apart from sales that were actually entered.
Task 3. Sorting out columns that look alike but mean different things
The sales records had two columns related to returns. One was a sales type that tells whether a transaction is a sale or a return, and the other was a return flag. Counting returns with each of the two columns gave different numbers.
The cause was in how the two columns are updated. According to the customer, the return flag was a marker set to Y on the original sale when that sale was later returned. In principle the return slip itself should stay N, but there were cases where Y had been set on return slips during manual entry, and online sales and returns are registered separately, so the flag on the original sale was never updated.
| Column | What it actually means | What to watch when counting returns |
|---|---|---|
| Sales type | Whether the slip is a sale or a return | Used as the basis for counting return slips |
| Return flag | Whether the original sale was later returned | Manual entry errors and missing updates from online channels are mixed in |
The same diagnosis also found that there is no column that separately identifies exchanges, and that the refund reason column is empty. The customer did not record exchanges separately in the system and managed everything as sales and returns. Findings like these are written down as the property definitions and constraints covered in part 1.2 With a constraint that says “a return slip must point to its original sales slip”, return records with a broken link can be picked out automatically.
Task 4. Agreeing classification and scope with the customer
The last task was settling, with the customer, questions that the data alone cannot answer.
| Question | What was agreed | Ontology technique |
|---|---|---|
| Where do products whose season is written as all season go? | Top-level season classes are set as all season (ALL), SS and FW. Total = ALL + SS + FW | Designing taxonomic relations (isA) |
| Is past data from closed stores included in AI queries? | Yes | Criteria for including instances |
| Up to when is data treated as confirmed? | Monthly data up to 2 months before the migration date is confirmed, and anything after that is provisional | Data version management |
The third criterion was needed because the sales data was not reconciled in real time. Sales data can change until the monthly close, so the most recent two months are kept as provisional data and checked for consistency again.
These agreements are not left as something said in a meeting. They are kept on record. When the same question comes up, it has to be possible to find who decided what, when and on what basis, so that the basis for the numbers holds even when the person in charge changes.

What the four tasks leave behind
When the four tasks are done, the following documents remain outside the database.
| Task | Output |
|---|---|
| Inferring links from which values contain which | Table link structure by domain |
| Pulling out hidden calculation rules | Calculation rule documents |
| Sorting out columns that mean different things | Property definitions and constraints |
| Agreeing classification and scope | Classification scheme and record of agreements |
These documents are the meaning layer described in part 1. The next part covers how we built a structure in which AI answers questions on top of this meaning layer, and how the integration problem that arose when the customer replaced its ERP is reconnected through the same meaning layer.
👉 Ontology in Practice (4) : Letting AI Answer on Top of a Meaning Layer
Sewing Production Glossary
Foreign key
Linking information written into the database that says which row of another table a column points to.
Inclusion dependency
A relation in which every value in one column appears in the list of values of another column. It is the basis for inferring links between tables when no linking information exists.
Domain
The range of tables and concepts that belong to the same business subject (customer, store, product and so on).
Reconciliation
Comparing the numbers in different records and checking the differences.
Confirmed / Provisional
Closed data that no longer changes / data that can still change because it has not been closed.
References
- Ziawasch Abedjan, Lukasz Golab, Felix Naumann, Profiling relational data: a survey, The VLDB Journal 24(4), 2015. Classification and detection methods of data profiling techniques, including inclusion dependencies. ↩
- W3C, OWL 2 Web Ontology Language Primer (Second Edition), 2012. Class hierarchies and constraints. ↩
- W3C, SWRL: A Semantic Web Rule Language Combining OWL and RuleML, W3C Member Submission, 2004. Rules made of conditions and conclusions. ↩
