Logo Tiger & Nebim V3 SQL Schemas: Polymorphic Joins & Turkish Unicode Traps in AI
Solving firm/period table sharding, context-dependent TRCODE/MODULENR routing, 6-column SKU variant keys, and silent İ/ı NFKD failures with an enterprise ontology.
- 01In Logo Tiger/GO, integer TRCODE values change meaning across tables and MODULENR contexts (e.g., wholesale sales invoice is TRCODE=8 in INVOICE, but TRCODE=38 with MODULENR=4 in CLFLINE).
- 02In Nebim V3 retail/apparel databases, SKU identity requires a 6-column composite join (
ItemTypeCode + ItemCode + ColorCode + ItemDim1..3), and retail PII columns return ciphertext when encryption is licensed. - 03Turkish text and locale defects fail silently without throwing exceptions:
"İ".lower()produces"i" + U+0307(breaking ASCII dictionary keys), and1.000,42flips Anglo thousand/decimal separators by three orders of magnitude.
1. Logo Tiger / GO: Firm-Period Sharding, Polymorphic Refs & Triple Currency Layers
Logo Tiger and GO organize SQL Server tables across three scopes: firm-and-period transaction tables (LG_001_01_STFICHE, LG_001_01_STLINE, LG_001_01_INVOICE, LG_001_01_CLFLINE, LG_001_01_ORFLINE), firm-level master cards (LG_001_ITEMS, LG_001_CLCARD, LG_001_UNITSETL), and system-wide tables (L_CAPIDEF, L_DAILYEXCHANGES). Raw Text-to-SQL agents routinely break across fiscal rollovers or multi-year comparisons.
Even within a single period, foreign-key references are polymorphic and conditional on type discriminators:
- Polymorphic
STOCKREF: OnSTLINEandORFLINE,STOCKREFpoints toLG_XXX_ITEMS.LOGICALREFonly on material lines (LINETYPE = 0); whenLINETYPE = 4, the exact same integer column references a service card (SRVCARD), and whenLINETYPE = 2, a discount card. Unconditional joins corrupt line-level margins. TRCODE+MODULENRContext Shift: A wholesale sales invoice carriesTRCODE = 8inINVOICE, yet appears in the AR/AP ledgerCLFLINEasMODULENR = 4andTRCODE = 38. MeanwhileCLFLINE.SOURCEFREFroutes toINVOICE(MODULENR=4),CLFICHE(MODULENR=5), orBNFLINE(MODULENR=7).- Three Parallel Currency Layers: Lines carry transaction currency (
TRCURR,TRRATE,TRNET), reporting currency (REPORTRATE,REPORTNET), and pricing currency (PRCURR,PRPRICE) side by side.
entity LedgerEntry {
source: LOGO.LG_{firm}_{period}_CLFLINE where CANCELLED == 0
polymorphic_link source_document {
when MODULENR == 4 -> SalesOrPurchaseInvoice via (SOURCEFREF == INVOICE.LOGICALREF)
when MODULENR == 5 -> CurrentAccountVoucher via (SOURCEFREF == CLFICHE.LOGICALREF)
when MODULENR == 7 -> BankTransaction via (SOURCEFREF == BNFLINE.LOGICALREF)
}
metric wholesale_receivable_net: sum(TRNET)
where MODULENR == 4 and TRCODE == 38 and SIGN == 0
}2. Nebim V3: 6-Column Variant Keys, Encrypted PII & the Integrator Boundary
Widely deployed across apparel, retail, footwear, and optics, Nebim V3 separates shared report metadata (NebimV3Master), operational logs (NebimV3EventLog), and per-company SQL Server databases using strict table prefixes: cd* (master cards plus language-keyed *Desc twins), pr* (variants, barcodes, attributes), tr* (orders, reservations, shipments, invoices), and st* (stOrder, stReserve open quantities).
A variant SKU across prItemVariant, prItemBarcode, trStock, and ItemInventory is uniquely keyed by six columns: ItemTypeCode + ItemCode + ColorCode + ItemDim1Code (Size) + ItemDim2Code + ItemDim3Code (with unused dimensions stored as empty strings). Joining on ItemCode alone triggers massive 1:N fan-out across colors and sizes. Furthermore, writes must flow through the official Nebim V3 Integrator API rather than raw SQL inserts that bypass validation.
3. Six Silent Turkish Unicode & Number-Parsing Traps in AI Pipelines
Multilingual AI pipelines processing Turkish ERP headers, PDFs, and spreadsheets encounter bugs that never raise an exception—they simply return empty lookups or numbers off by 1,000x:
- Dotted Capital
İ(U+0130) Combining Mark: Standard.lower()maps"İ"to"i" + U+0307(combining dot above), not plain"i". A header like"AÇIKLAMA GEREKSİNİMİ"silently misses every plain-ASCII dictionary key unless you normalize with NFKD and strip combining marks. - Non-Invertible Case Folding (
i ↔ İ,ı ↔ I): Calling locale-unaware.upper()on"belirlenecek"yields dotless"BELIRLENECEK", failing to match"BELİRLENECEK"status sentinels. - NFD Filesystem & PDF Extraction: macOS paths and PDF extractors emit decomposed UTF-8 (
"u" + U+0308instead of"ü"). Normalize toNFCat the ingestion boundary. - Inverted Thousand/Decimal Separators (
1.000.000vs0,4210): Period marks thousands and comma marks decimals, while regex\dmatches non-ASCII digits. Parse explicitly with[0-9]rules. - Never Verify Fidelity Through a Match Fold: Keep the folded lookup key separate from the verbatim display string—otherwise an ASCII-mangled quote passes verification as "exact".
Never trust string normalization without post-conditions: assert every schema key lookup returns non-empty, and assert both sides of any cross-source reconciliation read non-empty before interpreting differences.
Glossary Concepts Referenced in This Guide
FOREIGN KEY constraints—common across mature ERP and manufacturing databases.STAT = 4, SPEC_CODE = "B2") in operational tables to verified business states and calculation inclusion rules.ORDER_LINES and PAYMENTS) in one flat SQL query, multiplying totals silently.UPDATE/INSERT statements on ERP/CRM databases, requiring typed action proposals validated against preconditions and approved by a named human role.Free to reference in engineering docs, ADRs, articles, and course syllabi with attribution.
[Logo Tiger & Nebim V3 SQL Schemas: Polymorphic Joins & Turkish Unicode Traps in AI — Ontoloji.org](https://ontoloji.org/en/guides/logo-tiger-nebim-v3-sql-schema-and-turkish-unicode-traps)