C3 AI Documentation Home

Add and Update Entities in the Object Model

The entities in the Object Model tab of Data Fusion are the entity Types that make up your application's data model. Each entity Type defines a kind of data your application stores: its fields, its relationships to other entities, and the methods that act on it. Add an entity when your data model needs a Type it does not have yet, for example:

  • A Type for a part of your business, such as Customer, Order, or Asset.
  • A target Type that receives records from a data integration pipeline.
  • A Type with built-in behavior, such as time series or machine learning features, which you get by starting from an entity template.

You add, edit, remix, and delete entities in the Diagram view of the Object Model, which shows your data model as an entity relationship diagram (ERD). For the Diagram view, see Manipulate ERD Views with Object Model.

Before you begin

Data Fusion writes the entities you add or change into your application's root package. The root package is the package your application is built from. Dependency packages are the packages your application depends on.

Before you add or change entities, check the following:

  • Your application must not be in production or test mode: in those modes, Add new entity is unavailable, its tooltip starts with "Cannot add entities in", and the code editor opens read-only.

Add an entity

Start from a template that already includes the behavior you need, or start from scratch.

The Select an entity template list shows these templates, sorted by name:

TemplateChoose the template whenMixes
Entity with Feature EvaluatableYou want to derive machine learning features from the entity's data.FeatureEvaluatable
Sample Time Series Complex PartitioningThe entity holds a time series that needs complex partitioning.FeatureEvaluatable
Simple CalcYou want to start from an entity that already has calc fields.None
Simple RelationalYou want a plain relational entity with a few string and double fields to adapt.None
Simple Timeseries consisting of IntervalDataPointsYou store a time series as interval data points.IntervalDataPoint
Timed Interval RelationYou relate two entities over a period with a start and end timestamp.TimedIntervalValue
Timeseries headerYou need one header entity that represents a collection of time series.IntervalDataHeader

Each template mixes in the Type in the Mixes column, which provides its behavior. For what each mixed-in Type provides, see its documentation. The list includes every entity template available in your application, so it can differ with the packages your application uses.

To add an entity:

  1. In C3 AI Studio, open your application, select Data > Data Fusion, and then select the Object Model tab.

  2. In the view switch, select Diagram view.

  3. In the entity toolbox, select Add new entity. The code editor opens on Select an entity template.

  4. Select a template, or select Create entity from scratch to start from an empty Type.

    The Create New Entity editor opens. The editor's Files list holds the Type's declaration file (.c3typ) and its implementation file (.js).

  5. In the .c3typ file, set the Type's name in the declaration and define its fields and methods. Implement the methods in the .js file.

  6. Optional: Select Evaluate to check the declaration for errors without saving it.

  7. Select Create.

Create New Entity editor for the Simple Relational template, with the declaration and implementation files in the Files list, the declaration open, and the Evaluate and Create buttons

The Entity Created dialog confirms that Data Fusion added the Type to your root package. The dialog also says that the new entity will appear in the diagram shortly. Select Return to Object Model Canvas to close the editor, or Continue Editing to keep working. If the declaration has an error, the editor shows a message such as "Failed to parse the type declaration for" followed by the Type name.

If you close the editor with unsaved changes, the Code Has Changed dialog opens. Select Save Changes to keep your changes or Discard Changes to drop your changes.

Edit an entity

You can edit an entity in your root package, including an entity marked final (a Type that cannot be remixed). To edit an entity:

  1. In the Diagram view, right-click the entity, or hover over it and select Actions.
  2. Select Modify Code. The code editor opens with the Type's files.
  3. Edit the files.
  4. Select Save.

The Entity Updated dialog confirms the change. Select Return to Object Model Canvas to close the editor, or Continue Editing to keep working.

Remix an entity from a dependency package

To change an entity from a dependency package, remix it: save an edited copy in your root package. The menu shows Remix Code for an entity in a dependency package that is not marked final. To remix an entity:

  1. In the Diagram view, right-click the entity, or hover over it and select Actions.
  2. Select Remix Code. The code editor opens with the Type's files.
  3. Edit the declaration. The declaration must use the remix type syntax, or the save fails.
  4. Select Save.

Code editor for a dependency entity opened with Remix Code, with the Resolution Declaration, Original Declaration, and Remix tabs, a remix type declaration, and the Evaluate and Save buttons

The Entity Remixed dialog confirms that Data Fusion saved the remix in your root package.

For other entities, such as a dependency entity marked final, the menu shows View Code. View Code opens the code editor read-only.

Delete an entity

Delete an entity Type that you no longer need from your root package.

To delete an entity:

  1. In the Diagram view, right-click the entity, or hover over it and select Actions.
  2. Select Delete.

Context menu of an entity in the root package, with Preview Data, Preview Schema, Modify Code, and Delete

Data Fusion removes the Type's definition from your root package and removes the node from the diagram. The message Deleting <Type name>... appears, followed by Successfully deleted <Type name>.

Delete is unavailable for entities in a dependency package, for entities marked final, and in production or test mode. The disabled item shows the tooltip "Cannot delete types outside the root package or final types".

See also

Was this page helpful?