Schema Design Patterns¶
Note
Status: This page is under development.
Learn schema design patterns from production zlmdb applications.
Overview¶
This guide covers:
The
@tabledecorator patternSchema class architecture
Table attachment with
Schema.attach()Foreign key relationships
Schema versioning with UUIDs
Coming Soon¶
This page will cover patterns from Crossbar.io (cfxdb) and pydefi:
The Schema Class Pattern - Schema class definition - Table type hints -
Schema.attach()factory method - Example from cfxdb.cookiestoreTable Definitions with @table - UUID-based table identifiers - Serialization parameter binding - Main tables vs index tables - Example from pydefi.database.exchange
Object Classes - Lazy loading from FlatBuffers - Property decorators with type hints -
marshal()andparse()methods -build()andcast()for FlatBuffersForeign Key Relationships - UUID-based references - Hierarchical data modeling - Example: Market → Exchange, Market → Pair - Lookup patterns
Schema Versioning - UUID table identifiers for versioning - Schema evolution strategies - Backward compatibility
Multi-Table Schemas - Organizing related tables - GlobalSchema example (Crossbar.io) - PyDefi schema (20+ tables)
Real-World Examples¶
Examples will be drawn from:
cfxdb.cookiestore: Cookie authentication (Crossbar.io)
cfxdb.globalschema: Management realm (20+ tables)
pydefi.database: Cryptocurrency data (exchanges, markets, trades)
See Also¶
High-Level ORM API - ORM overview
Indexes and Lookups - Index patterns
Serialization Strategies - Serialization choices