Working With Models in the RAI Console
A short guide to working with models in the RAI Console.
Models in RelationalAI’s RKGS are collections of relations, modules, entities, integrity constraints, or any kind of logic that is persisted in the database. You can use models to build and organize your Rel applications.
Persisting models in the database is called loading models.
For more information on installed models in the context of Rel applications, see Working With Models.
Managing Models
You can manage and edit models through the RAI Console. Note that it is also possible to manage models through the RelationalAI 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:
- All models that you have directly created.
- All models associated with notebooks.
- Built-in Rel Libraries.

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. This is 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:
- Right-click </> 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.

- In the dialog box that opens, give the model a name and click Create.
On Mac computers, right-click is equivalent to Control+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 under 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:
-
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.
-
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, it’s best practice to:
- Export the model so that you can access it later if necessary.
- Check with other team members to make sure they are not using the model. The model will be unrecoverable once deleted.
To delete a model:
- Right-click the model you want to delete and choose Delete.
- 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:
- Click the name of the model in the Object Tree. The model opens in the Model Editor.

- 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.
- 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 Show/Hide Models on the right-hand side of the Console.

Using Find and Replace
The Model Editor has a find-and-replace feature that lets you search the current Models tab for a string, and then replace this string.
To use Find and Replace:
- Press Control+F (PC) or Command+F (Mac). A panel opens at the bottom of the Editor:

- Enter a string in the Find field and press Enter (PC) or Return (Mac). Search results are highlighted in the Query Editor.
- Enter a replacement string in the bottom box and click replace or replace all.
Note that if you select text in the Editor and then press Control+F (PC) or Command+F (Mac), the Find field will automatically be populated with the selected text.
Available options are:
Option | Description |
---|---|
match case | Respects case sensitivity. For example, if you enter “Student” into the Find field and select match case, the Console will find “Student” but not “student.” |
regexp | Uses regular expressions in both Find and Replace fields. |
by word | Finds only whole words (that is, words enclosed in white spaces). For example, if you enter “story” into the Find field and select match case, the Console will find “story” but not “history.” |
Navigating Search Results
To select the next search result, click next or press F3 or Control+G (PC) or Command+G (Mac). To select the previous search result, click previous or press Shift+F3 or Control+G (PC) or Command+G (Mac). You can also select all results by clicking all.
Using Regular Expression
You can use regular expressions in search.
For example, if you want to search for only numerals, type the following in the Find field: [0-9]
.
Regular expressions make use of special characters: .[{()\^$|?*+
.
To search for these characters, you need to escape them with a backslash \
. For example, if you need to find .
, type \.
in the Find field.
You can also capture and replace groups.
In the Find field, enter parentheses ()
to indicate a capturing group, such as (.*?)
.
In the Replace field, you can reference groups with numbers preceded by $
, such as $1
.
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:
- Right-click the model you want to export and choose Export Model.
- 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:
-
Either:
- Right-click </> Models in the Object Tree.
OR
- Under </> Models, right-click the notebook into which you want to import the model.
-
Choose Import Model.
-
Browse to the location containing the Rel file.
-
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:
-
Either:
- Right-click </> Models in the Object Tree.
OR
- Under </> Models, right-click the notebook in which you want to create a folder.
-
Choose Create Model.
-
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 asfolder-name/subfolder-name/my-model
.

- Click Create.
The model appears in the folder in the Object Tree.

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:
-
Either:
- Right-click </> Models in the Object Tree.
OR
- Under </> Models, right-click the notebook into which you want to import the folder.
-
Choose Import Folder.
-
Browse to the location containing the folder.
-
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:
- Click </> Models to expand its tree view.
- Click notebooks.
- Click the notebook model you want 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 under it in the Object Tree.

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 more details, see Rel Libraries.