Skip to content
RKGMS
RAI CONSOLE
Working with Models

Working with Models in the RAI Console

A short guide to working with models in the RAI Console

Models in our RKGMS are collections of relations, modules, entities, integrity constraints, or any kind of logic that is persisted in the database. Using models is great a way to build and organize your Rel applications.

We call persisting models in the database installing models.

For more information on installed models in the context of Rel applications, see the concept guide Installing Models.

Managing Models

You can manage and edit models through the RAI Console. Note that it is also possible to manage models through our SDKs.

When you open a database in the RAI Console, models appear in the object tree on the left-hand side of the RAI Console.

The object tree lists

create model

You can create, delete, edit, import, and export models from the RAI Console. You edit models using the Model Editor, which is an IDE-type environment for editing model code directly.

Creating Models

You can create models directly from the object tree. You may find doing so useful in order to:

  • Develop in Rel outside of the notebook environment.
  • Create models that will be shared across notebooks.
  • Create models that you want to make available to an SDK.

To create a model:

  1. Right-click on </> Models in the object tree on the left-hand side of the Console and choose Create Model. You can also add a model to a notebook by right-clicking the notebook’s name under Models in the object tree.
create model
  1. In the dialog box that opens, give the model a name and click Create.
🔎

On Mac computers, right-click is equivalent to Ctrl-click.

The new model appears in the object tree and opens in the Model Editor (the middle window) so that you can edit it.

Note that when you click a model, a list of relations defined in the model appears beneath it in the object tree.

Renaming Models

You can rename models either in the Model Editor or in the object tree.

To rename a model:

  1. Either:

    Double-click the model name in the tab at the top of the Model Editor.

    OR

    Right-click the model in the object tree and choose Rename.

  2. Enter the new name for the model and press Enter or Return.

Deleting Models

You can delete models in the object tree.

Before doing so, we recommend:

  1. Exporting the model so that you can access it later if necessary.
  2. Checking with other team members to make sure they are not using the model. The model will be unrecoverable once deleted.

To delete a model:

  1. Right-click the model you wish to delete and choose Delete.
  2. In the confirmation message that appears, click Delete.

The model disappears from the object tree and is removed from the database.

Editing Models

You edit models in the Model Editor. You can add any valid Rel code to the model; the Model Editor will flag any errors in your code when you save.

To edit a model:

  1. Click the name of the model in the object tree. The model opens in the Model Editor.
models editor
  1. Edit code as needed. Note that a blue dot appears next to the name of the model at the top of the window until you save it.
  2. Click Save.

At any time, you can revert changes by clicking Revert.

Showing or Hiding the Model Editor

You can show or hide the Model Editor by clicking the Show/Hide Models button on the right-hand side of the Console:

models editor

Exporting and Importing Models

You can share models with other users by exporting and importing them.

Exporting Models

You can export models as Rel files in order to share them with other users. Once you export a model, other users will be able to import it into their databases.

To export a model:

  1. Right-click the model you wish to export and choose Export Model.
  2. Open or save the file on your system. By default, models are saved as <your-filename>.rel.

Importing Models

You can import Rel files either directly into the database or into a notebook.

To import a model:

  1. Right-click either

    </> Models in the object tree

    OR

    under </> Models, the notebook into which you want to import the model.

  2. Choose Import Model.

  3. Browse to the location containing the Rel file.

  4. Click Open.

The model appears in the object tree and is imported into the database.

Organizing Models in Folders

You can create folders to organize your models. To create a folder, you create a model and use forward slashes (/) to indicate that the model should be contained within a folder. You can also import folders that contain Rel files, which will appear as folders in the object tree.

Creating Folders

To create a folder:

  1. Right-click either

    </> Models in the object tree

    OR

    under </> Models, the notebook in which you want to create a folder.

  2. Choose Create Model.

  3. In the dialog box that opens, give the model a name with a forward slash to indicate a folder, such as folder-name/my-model. You can use multiple forward slashes to create subfolders, such as folder-name/subfolder-name/my-model.

create model folder
  1. Click Create.

The model appears in the folder in the object tree.

create model folder

You can add additional models to the folder by right-clicking the folder and selecting Create Model or Import Model.

Importing Folders

To import a folder:

  1. Right-click either

    </> Models in the object tree

    OR

    under </> Models, the notebook into which you want to import the folder.

  2. Choose Import Folder.

  3. Browse to the location containing the folder.

  4. In the message that opens, click Upload to confirm.

The folder appears in the object tree, with the Rel files added as models. You can add additional models to the folder by right-clicking the folder and selecting Create Model or Import Model.

Viewing and Editing Notebook Models

The object tree lists all installed models for notebooks in the database. For more information on notebooks, see Working with RAI Notebooks.

To view details for a notebook model:

  1. Click </> Models to expand its tree view.
  2. Click notebooks.
  3. Click the notebook model you wish to view.

The model opens in the Model Editor, where you can edit it.

Note that when you click a model, a list of relations defined in the model appears beneath it in the object tree.

a view of notebook models

Viewing Rel Libraries

The Rel Libraries provide for common tasks user-friendly relations organized by use cases. You can view these by clicking them in the object tree. For details on Rel libraries, see Rel Libraries.