C3 AI Documentation Home

Understand Data Models and Object Models

A data model defines how your application structures and stores information. You write it in .c3typ files using the C3 Type System. The data model specifies what entities exist (like Customer or Order), what fields they contain (like name or email), and how they relate to each other. Data models consolidate information from multiple sources—SQL databases, streaming sources, CSV files, external systems—into one view accessed through one API. This gives you consistent data access and data that's shareable across teams and applications.

An object model is a visual diagram of your data model. It shows your entities and their relationships as an interactive Entity Relationship Diagram (ERD). The object model makes your data architecture visible: business stakeholders can understand relationships without reading code, and technical teams can spot dependencies between entities. Changes appear instantly for everyone working on the same application.

You can find your object model in C3 AI Studio under Data Fusion > Object Model.

Create data models

When you build in C3 AI, yo create Types to define data structure, behavior, and relationships. Every C3 AI application uses Types as the central abstraction for data, operations, and functionality.

You have two main approaches to create Types:

  1. Data Fusion is a visual tool for integrating external data sources. It generates entity Types from data schemas and sets up data pipelines with minimal code.
  2. C3 AI VS Code Extension (VSCE) is the IDE for writing Types directly in code. It provides full development features like code completion, debugging, and real-time validation.

You'll often use both. For example, use Data Fusion to pull in external data, then extend those entities in VSCE with custom methods.

Before you start with either approach, you need to understand how Types work and what you can build with them.

How Types work

The data model sits between your business logic and database storage. Your application interacts with entities through a consistent API. Behind the scenes, the data model handles persistence to PostgreSQL for relational data or Cassandra for time-series data.

Here's a simple entity Type:

Type
entity type Employee {
  id: ~
  name: string
  email: string
  hireDate: datetime
}

Entity Types automatically include the Persistable interface, which handles storing and retrieving data.

Relationships connect entities. Building on the Employee type, here's how one organization has many employees:

Type
entity type Organization {
  id: ~
  name: string
  employees: [Employee](organizationId, id)
}

entity type Employee {
  id: ~
  name: string
  email: string
  hireDate: datetime
  organizationId: Organization
}

Type inheritance lets you extend base Types. You can create specialized employee types:

Type
extendable entity type Employee {
  id: ~
  name: string
  email: string
  hireDate: datetime
}

entity type Manager extends Employee type key "MGR" {
  department: string
  directReports: int
}

Mixins add fields and methods from one type to another, supporting multiple inheritance:

Type
entity type Employee mixes Identified, Persistable, Taggable {
  name: string
  email: string
  hireDate: datetime
}

The object model displays all of these structures visually. You'll see entities as boxes, fields listed inside each box, and lines showing relationships.

When creating Types, you define fields, value Types, collections, methods, and inheritance relationships. For a complete understanding of the Type system, see the following:

To learn more about specific Types and Type properties, see:

Data Fusion

Data Fusion provides a visual interface for connecting external data sources and automatically generates Entity Types from data schemas. Use Data Fusion to configure data pipelines with minimal code and manage ETL processes.

Data Fusion works through several components. A SourceSystem connects to external data systems. A SourceCollection provides logical grouping of data from a source. A Source models imported data objects. A Canonical serves as the inbound interface for source data schema. Transform functions handle data transformation.

Use Data Fusion when you're integrating external databases or data warehouses, working with file uploads like CSV or JSON, streaming data from Kafka or Kinesis, or building data pipelines with minimal custom coding.

The object model in Data Fusion visualizes your data architecture. Use it to see the entire structure at a glance, spot missing relationships, and export diagrams for discussions. It helps with gap analysis during integration design and mapping external data sources to Entity Types. Filter the view to focus on relevant entities and save important views for documentation. To work with ERD views, see Manipulate ERD Views with Object Model and Analyze Data Model.

For more information about Data Fusion, see Data Fusion Overview and Modeling Data in an Application.

C3 AI VS Code Extension

The C3 AI VS Code Extension (VSCE) provides full IDE integration with VS Code or Cursor, real-time type validation and error checking, code completion and intelligent suggestions, and interactive debugging capabilities. The extension includes a JavaScript Notebook for exploratory development, a REPL for interactive coding, and direct application connection for testing. You get a Package Explorer for managing local packages, application management and lifecycle control, test runner and debugging tools, file synchronization with C3 AI server, and support for Python and JavaScript implementations.

VSCE provides full control over type definitions and behavior. Use the extension to:

  • Create complex Types with custom logic
  • Implement business rules and calculations
  • Write performance-critical code
  • Debug and test implementations

For setup, see C3 AI VS Code Extension Overview, VSCE Features, VSCE Development Guide, and VSCE Debugging.

Implementation

After defining Types, you implement methods in JavaScript or Python. For JavaScript, see Implement JavaScript Methods. For Python, see Implement Python Methods, Implement Methods in C3, and C3 AI Python Runtime.

Specialized patterns

Beyond basic entity Types, some data patterns need specific approaches.

Time series data

Time series data consists of values associated with discrete timestamps. Use specialized Types when you need high-frequency time-stamped data from sensors, financial systems, or metrics tracking.

The platform handles normalization across different sources and time zones, manages data quality issues like duplicates and gaps, and optimizes storage with Cassandra. You get automatic preprocessing, multiple normalization modes, and performance optimization for large volumes.

For details, see:

Hierarchies

Hierarchies represent tree structures like organizational charts or geographic regions. Hierarchy denormalization flattens these structures for efficient querying.

Use hierarchies for organizational structures with multiple reporting lines, geographic hierarchies from country to region to city, product hierarchies from category to subcategory to item, or bill of materials structures.

For guidance on implementing hierarchies, see:

See also

Was this page helpful?