Overview
Entities represent distinct objects or concepts in your data model (like customers, orders, or products). They enable automatic relationship discovery and intelligent joins between views. When you define entities consistently across views, the semantic layer automatically understands relationships and can join data seamlessly.Entity Types
Primary Entity
Each view should have exactly one primary entity representing the main subject:Foreign Entity
Foreign entities reference objects primarily defined in other views:Entity Properties
| Property | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique identifier for the entity |
type | string | Yes | Entity type: primary or foreign |
description | string | Yes | Human-readable description |
key | string | No* | The dimension that serves as the entity key (single key) |
keys | array[string] | No* | The dimensions that serve as the entity keys (composite keys) |
key or keys must be provided, but not both.
Simple Entity Keys
Use thekey property for entities with a single identifier:
- “Show total revenue by customer acquisition channel”
- “What’s the average order value for customers from email campaigns?”
Composite Keys
For entities with composite keys, use thekeys field:
order_id and line_item_id.
How Entities Enable Joins
When you define entities consistently across views, Oxy automatically:- Identifies relationships between views based on matching entity names
- Generates JOIN clauses using the entity keys
- Enables cross-view queries without manual join logic
Example: Multi-View Query
Given these view definitions:- “What’s the total revenue by product category?” (joins orders, order_items, products)
- “Show me customer lifetime value by acquisition channel” (joins customers, orders)
- “Which products have the highest return rates?” (joins products, order_items, orders)
Best Practices
Naming
- Use singular nouns (e.g.,
customer,order,product) - Use consistent names across all views
- Match the business terminology your organization uses
Design
- Each view should have exactly one primary entity
- Add foreign entities for all relationships to other views
- Ensure entity keys reference valid dimensions in the view
Performance
- Index the columns used as entity keys in your database
- For composite keys, create composite indexes on those columns
- Consider the cardinality of joins when designing entities