Getting Started
Tutorial: Building with CleaveDB
Computed Fields (ENRICH) — Overview
In traditional database design, derived values (such as full names, sales tax, profit margins, or age classifications) create an architectural dilemma: either waste disk space storing redundant denormalized fields, or duplicate calculation logic across every web and mobile client application. CleaveDB solves this with Computed Virtual Fields (ENRICH).
The Three Pillars of ENRICH
1. Virtual Fields
Synthesize new attributes on the fly that act as native fields for reads, filtering, and aggregation.
2. Expressions & Formulas
Combine string concatenation (CONCAT), arithmetic calculations, and boolean comparisons.
3. Enrichment with Masking
Pair virtual fields with MASK to dynamically redact calculated values based on session roles.
Key Benefits
- Single Source of Calculation: Define business logic (e.g. tax formula or discount rate) once in the database rather than across multiple client apps.
- First-Class Queryability: Filter directly using computed fields in
WHEREclauses (e.g.WHERE is_adult = true). - Streaming Integration: Out-of-the-box support for WebSocket broadcasts—live subscribers receive pre-calculated values instantly.
Explore Computed Field Topics
Step through the lessons below to master virtual field declarations in CleaveQL:
