Schema
This section explains the schema of λORM: what it contains, how it is defined and used, and how it is synchronized with the databases.
The schema holds all the configuration the ORM needs. It separates the business model (domain) from the persistence of the data (infrastructure):
- In the domain, the entities and enums that represent the business model are completely clean, without any attribute that couples them to persistence.
- All queries are written against the business model, so they are decoupled from the physical model of the data.
- In the infrastructure, everything needed to store and read the data in the different sources (databases) is defined.
The schema can be written in a YAML or JSON file (usually lambdaORM.yaml), or passed as an object when the ORM is initialized.
All the expressions used to define conditions and actions are evaluated by the expression engine 3xpr.
Example
This example shows a stage that uses two sources: source 1 is MySQL and holds the Countries table, and source 2 is PostgreSQL and holds the States table.
For the Countries entity, the names of the table and its columns are the same as the names of the entity and its properties, so no mapping needs to be written.
For the States entity, the names of the table and its columns are different, so the mapping defines them.
In this section
- Definition: every key of the schema.
- Expressions, Environment variables and Composite entities.
- Schema Use: how to load the schema and generate the model.
- Examples: Basic, Extend, Multiple stages, Stage with multiple sources, Composite and Listener.
- Synchronization: push, pull, fetch, introspect and incorporate.
- Engines: differences between database engines.
The Data Gateway publishes a schema over the network; its own settings are in a separate configuration file.