Skip to content

Usage ​

Overview ​

Data services provide structured data storage with automatic CRUD operations, relationship handling, and database persistence. This page covers working with data services, configuring them, and integrating them with workflows and applications.

Data Service Components ​

Database Schema

Data services include database tables and relationships for all defined entities. Database schema is generated from the data model definition.

API Layer

Complete interface for data access with operations for all entities. The API layer handles requests, validates data, and enforces constraints.

Standard Operations

Automatic create, read, update, and delete operations for all entity types. Standard operations include filtering, pagination, and relationship navigation.

Validation Logic

Enforcement of constraints and business rules. Validation occurs at the API layer before database operations.

Access Control

Authentication and authorization for data operations. Access controls specify who can perform which operations on what data.

Data Service Evolution ​

Adding Entities

New entity types can be introduced as application requirements expand. New entities receive automatic operations while existing entities remain unchanged.

Modifying Entities

Existing entities can be updated with new fields or adjusted relationships. Schema changes are applied while preserving existing data.

Adding Validation

New constraints and validation rules can be introduced. Constraints are enforced on all subsequent operations.

Custom Operations

Specialized operations can be added beyond standard CRUD. Custom operations extend data services for unique requirements.

Custom logic and existing data are preserved during schema evolution.

Custom Business Logic ​

Beyond standard operations, data services support custom logic:

Complex Queries

Specialized filtering, aggregation, and search operations tailored to specific requirements.

Business Workflows

Multi-step operations coordinating multiple entities or external systems.

External Integration

Connections to external systems including APIs, notification services, and legacy systems.

Calculations

Derived fields, aggregations, and computed values based on entity data.

Configuration ​

Database Configuration

Database behavior settings:

  • Connection pooling for concurrent operations
  • Query timeouts to prevent long-running operations
  • Transaction isolation levels balancing consistency and performance

API Configuration

API behavior controls:

  • Rate limiting to prevent overload
  • Query depth limits to prevent complex requests
  • Field permissions controlling data access

Caching

Performance optimization through caching:

  • Query result caching to reduce database load
  • Field-level caching for expensive computations
  • Cache invalidation strategies to maintain data freshness

Monitoring ​

Service Health

Monitor data service operational status:

  • Service availability and uptime
  • API response times
  • Error rates and failure patterns
  • Database connection utilization

Debugging

Tools for investigating issues:

  • Query logs showing recent API calls
  • Error details with failure causes
  • Performance metrics identifying bottlenecks
  • Database query analysis

Integration ​

Workflow Engine

Workflows access data services through connection tasks:

  • Data Import — Read data into workflow execution
  • Data Export — Write workflow results to data services
  • Type Validation — Ensure data compatibility between workflows and services

The Workflow Engine uses a data service for its own backend, storing workflows, experiments, and results.

See Workflow Engine for integration details.

Frontend Applications

Applications connect to data services for operational data:

  • Configuration-driven data connections
  • Type-safe queries
  • Real-time data updates
  • Automatic error handling

See Frontend Architecture for frontend integration.

Best Practices ​

Schema Design

  • Start with core entities, add complexity incrementally
  • Model operational domain, not technical database structure
  • Define validation constraints at the data layer
  • Structure for evolution as requirements emerge

Performance

  • Index fields used in common query patterns
  • Avoid deeply nested relationship queries
  • Use pagination for large result sets
  • Apply caching where appropriate

Security

  • Authenticate all API requests
  • Authorize operations based on user permissions
  • Validate input at the API boundary
  • Audit data access for compliance

Maintenance

  • Track schema changes over time
  • Test updates in non-production environments
  • Monitor performance metrics
  • Document custom operations and business rules

Common Patterns ​

Asset Management

Track operational assets with location, status, and maintenance. Typical entities: Sites, Assets, Maintenance Records, Work Orders.

Scheduling

Manage time-based resource allocations. Typical entities: Resources, Schedules, Bookings, Assignments.

Event Tracking

Record time-series observations and measurements. Typical entities: Events, Sensors, Readings, Alerts.

Transaction Processing

Record business transactions with audit trails. Typical entities: Transactions, Items, Parties, Audit Logs.

See Examples for detailed implementation patterns.

User documentation for Optimal Reality