Skip to content
BASE DERIVED OVERLOAD

Error Code: BASE DERIVED OVERLOAD

This guide explains why an overload error related to base and derived relations may occur and describes how to fix it.

Relations in the RelationalAI database are of two main types:

TypeDescription
Base relationsRAI database objects where all the data are stored and persisted. In a SQL database, these are the tables. Base relations are often referred to as EDB.
Derived relationsRelations whose content is defined by logical rules. These rules are persisted in the database. In a SQL database, these are the views. Derived relations are often referred to as IDB.

The system triggers a BASE DERIVED OVERLOAD error when you define a derived (or base) relation using the same name and data schema as another previously stored base (derived) relation. Having the same data schema means the number of columns and the data type of each column are the same.

Currently, a relation with a specific schema can either be a base or derived relation but not both at the same time.

To avoid this error, you can take one of the following actions:

  • Store all data in a base relation.
  • Store all data in a derived relation.
  • Use different relation names, and, if needed, write a new relation that serves as the union of the definitions of the base and derived relations.
  • Change the data type(s) in one of the relations.

Generally, it’s best to use one of the first three options to resolve the error. This is because changing the data type can lead to confusing and unnecessarily complex data schemas.

Example

Consider the following example to better understand the error. Say you store information about clothes in the base relation items, using the control relation insert:

// write query
 
def insert:items = {"shirts"; "socks"; "shoes"}
def output = items

In a subsequent transaction, you add more grocery items but, this time, you use a derived relation:

// read query
 
def items = {"fish"; "fruits"; "bread"}

First, you’ll notice the relation items still doesn’t include the new grocery items:

// read query
 
def output = items

More importantly, this subsequent transaction triggers a BASE DERIVED OVERLOAD error. This is because you’ve already defined the relation items in the database as a base relation with the data schema (String), so a derived relation with the same name and schema can’t simultaneously exist.

Error example from the RAI Console

To avoid the BASE DERIVED OVERLOAD error, you can store the grocery items in a base relation:

// write query
 
def insert:items = {"fish"; "fruits"; "bread"}
def output = items

You can also use different relation names and then, in a separate step, write a relation serving as the union of all definitions:

// read query
 
def items_grocery = {"fish"; "fruits"; "bread"}
def all_items = items; items_grocery
def output = all_items
Was this doc helpful?