DraftEngineering
Designing Canonical Schemas
A canonical table has one schema, many protocols, and a lineage key back to the raw log. Draft while dex.trades is being designed.
Context
Protocol tables are accurate and unusable across protocols. Canonical tables are usable and must not lose the protocol.
Method
Each canonical row keeps protocol, tx_hash, log_index and block_number. Domain fields are the intersection of what every decoder can populate honestly.
Findings
Draft. The temptation is to add a column for every protocol quirk. That produces a protocol table with extra names.
Implications for the data model
If a field cannot be filled by every decoder in the union, it stays on the protocol table.