SAP Relationship Mapping
How the Synthesized Platform maintains SAP table relationships through module knowledge and configurable virtual foreign keys.
The SAP Relationship Challenge
SAP systems present unique challenges for data management:
No Explicit Foreign Keys
Unlike typical relational databases, SAP tables rarely define foreign key constraints at the database level:
-- SAP HANA shows no FK constraints
SELECT * FROM SYS.REFERENTIAL_CONSTRAINTS
WHERE SCHEMA_NAME = 'SAP_SCHEMA';
-- Result: Empty or minimal results
Why?
-
Performance optimization in high-volume OLTP systems
-
Flexibility for customizations (Z-tables)
-
Historical design decisions from R/3 era
Implicit Relationships
Relationships exist through naming conventions and field semantics:
MARA.MATNR ←→ MAKT.MATNR (Material master to descriptions)
MARA.MATNR ←→ MARC.MATNR (Material master to plant data)
MARC.WERKS ←→ T001W.WERKS (Plant to plant master)
These are "virtual" foreign keys - understood by SAP applications but not enforced by the database.
How the Platform Handles This
Automatic Table Ordering
The platform automatically orders tables for correct data flow:
# Tables are processed in dependency order:
tables:
# 1. Root table first (MARA)
- table_name_with_schema: "SCHEMA.MARA"
# 2. Dependent tables follow
- table_name_with_schema: "SCHEMA.MAKT" # depends on MARA
- table_name_with_schema: "SCHEMA.MARC" # depends on MARA
- table_name_with_schema: "SCHEMA.MARD" # depends on MARC
Virtual Foreign Key Definitions
MM Module Virtual FKs
| Child Table | Child Fields | Parent Table | Parent Fields |
|---|---|---|---|
MAKT |
MANDT, MATNR |
MARA |
MANDT, MATNR |
MARC |
MANDT, MATNR |
MARA |
MANDT, MATNR |
MARD |
MANDT, MATNR, WERKS |
MARC |
MANDT, MATNR, WERKS |
MBEW |
MANDT, MATNR |
MARA |
MANDT, MATNR |
MARM |
MANDT, MATNR |
MARA |
MANDT, MATNR |
MVKE |
MANDT, MATNR |
MARA |
MANDT, MATNR |
MSEG |
MANDT, MBLNR, MJAHR |
MKPF |
MANDT, MBLNR, MJAHR |
Key Field Patterns
SAP uses consistent patterns for relationships:
| Pattern | Description | Example |
|---|---|---|
MANDT |
Client/mandant - always first in composite keys |
MANDT = '100' |
Primary Business Key |
Main object identifier |
MATNR, LIFNR, KUNNR |
Organizational Keys |
Org structure identifiers |
WERKS, BUKRS, VKORG |
Document Keys |
Document identification |
MBLNR + MJAHR, BELNR + GJAHR |
Configuration Options
Using Predefined Relationships
The SAP Workflow Wizard automatically applies known relationships:
# Automatically generated - no manual configuration needed
tables:
- table_name_with_schema: "SCHEMA.MARA"
transformations:
- columns: ["MANDT", "MATNR"]
params:
type: passthrough # Preserve keys for relationships
- table_name_with_schema: "SCHEMA.MAKT"
transformations:
- columns: ["MANDT", "MATNR"]
params:
type: passthrough # Match parent keys
Custom Virtual Foreign Keys
For custom tables (Z-tables) or non-standard relationships, define virtual FKs:
virtual_foreign_keys:
- table_schema: "SCHEMA"
table_name: "ZCUSTOM_TABLE"
columns:
- "MANDT"
- "MATNR"
referenced_table_schema: "SCHEMA"
referenced_table_name: "MARA"
referenced_columns:
- "MANDT"
- "MATNR"
Module Filtering
Handling Complex Relationships
Many-to-Many Relationships
SAP uses intermediate tables for M:N relationships:
MARA ←→ KNMT ←→ KNA1
(Material) (Cross-Ref) (Customer)
The platform handles these through proper table ordering and key preservation.
Validation
Troubleshooting
Missing Parent Records
Symptom: Child records reference non-existent parents
Cause: Time slicing excluded older master data
Solution: * Ensure referential integrity is enabled * Extend time slice period * Verify master data filter includes referenced records