Skip to content
HELP
GLOSSARY

Glossary

Aggregation

Aggregation operations are used to combine multiple values into a single value. Examples include count, sum, avg, min, and max.

Analytics

The process of distilling data into useful information. For example, looking at your bank statement to figure out how much money you’re spending in various categories is an exercise in data analytics.

Large organizations use data analytics to predict many variables relevant to their decision-making process, like supply chains, market trends, and customer behavior.

Annotations

A definition can be preceded by a number of optional annotations.

Common annotations include @function, @inline, @outline, @ondemand, and @static.

Any

A unary relation which contains all values. In other words, Any(x) evaluates to true for any value of x.

Arity

The number of elements in a relation’s tuples. For example, {(1, 2, 3); (4, 5, 6)} has arity 3.

Array

An nn-dimensional grid of numbers or other values.

A 1-dimensional array is a vector and a 2-dimensional array is a matrix.

Arrays are conventionally represented in Rel in the COO format (opens in a new tab). This means, for example, that a matrix AA is represented as an arity-3 relation that contains a tuple of the form (i, j, v) whenever v is the value in the ith row and jth column of AA. For example, consider this matrix:

A=[4.52.03.30.51.05.0]A = \begin{bmatrix} 4.5 & -2.0 & 3.3 \\ -0.5 & 1.0 & 5.0 \\ \end{bmatrix}

In Rel, this relation would be represented as:

def A = {
  (1, 1, 4.5); 
  (1, 2, -2.0); 
  (1, 3, 3.3); 
  (2, 1, -0.5); 
  (2, 2, 1.0); 
  (2, 3, 5.0)
}

Base Relation

A relation whose tuples are inserted into the database. Base relations contrast with derived relations, which are computed from base relations and other derived relations.

Binary Relation

A relation of arity 2. In other words, a binary relation is a relation whose tuples are pairs.

Bindings

A language construct in Rel by which variables are introduced. Bindings may appear in the head of a rule or integrity constraint or in a relational abstraction.

Examples: x, x in A, y in B, x, y where A(x, y).

CLI

A command-line interface for interacting with the RelationalAI platform. It can be used to create and manage projects, datasets, and models.

Cartesian Product

The Cartesian product of two relations consists of every concatenation of a tuple from the first relation with a tuple from the second relation. For example, the Cartesian product of {(1, 2); (3, 4)} and {("a"); ("b")} is {(1, 2, "a"); (1, 2, "b"); (3, 4, "a"); (3, 4, "b")}.

Character

A single letter, number, punctuation mark, or other symbol. Character literals in Rel are enclosed in single quotes: 'c' represents the character “c”.

Composition

A shortcut for joining the last column of a relation with the first column of another relation. The syntax for relational composition is a period (.). Example:

def order_products = {(12, 3213) ; (10, 3213) ; (7, 9832)}
def product_names = {(3213, "laptop"); (9832, "iphone"); (45353, "TV")}
def output = order_products.product_names

Concatenation

Concatenating means “putting one just after the other”. For example, the concatenation of the tuples (4, 2, 7) and (3, 1) is the tuple (4, 2, 7, 3, 1).

Conceptual Modeling

The process of constructing a problem’s ontological schema.

CSV Schema

The schema of a CSV file associates each column with a type. The load_csv option schema is a binary relation mapping each column to its type. The pairs are of the form (RelName, String):

module config
    def schema = {
        (:cocktail, "string");
        (:quantity, "int");
        (:price, "decimal(64, 2)");
        (:date, "date");
    }
end

Data Model

An object or concept, consisting of data, that informatively represents another object, concept, phenomenon, or system.

For example, a model airplane is a physical model of a real airplane. Friendship is a conceptual model of alliance between countries. Your driver’s license uses a conceptual model—consisting of your name, date-of-birth, address, eye color, sex, height, and organ-donor status—to represent you. The conceptual model used by your driver’s license is also a data model, since your name, date of birth, etc. are data.

Decimal

A numeric type which represents numbers with a fixed number of digits after the decimal point. The element decimal[n, digits, v] is a value of type Decimal which uses n bits to represent the value v with digits digits of precision after the decimal point.

Declaration

A Rel model consists of of a set of declarations, which can be rules, entity or value type declarations, module declarations, integrity constraints, or use declarations.

Derived Relation

A relation that is computed from other relations using logical rules.

For example, results is a base relation and medal is a derived relation in this example:

//update
def insert:results = {("Alice", 1), ("Bob", 2), ("Charlie", 3), ("Dave", 4), ("Eve", 5)}
 
//install
def medal(name) = exists(place : results(name, place) and place  3)

Docstring

A string that provides documentation for the relation targeted in the rule following the docstring. A relation’s docstring can be accessed using docstring:

doc"""The number 0."""
def zero = 0
def output = docstring[:zero]

Element

One of the items in a tuple. An element may be a number, a string, a date, a character, an instance of a value type, or an instance of an entity type. For example, the third element of the tuple (7,4,13)(7, 4, 13) is 13.

Engine

A virtual machine running in a cloud provider (such as Microsoft Azure) that executes query computations and processes database transactions.

Entity

Something that exists in the real world and can be uniquely identified independently of its properties or other relationships. Entities are modeled in Rel using an entity type declaration:

entity type Person = String, Date
def output = ^Person["Marcus Jones", 1990-01-01]

Exception

An error thrown during the execution of an expression.

This can happen even if an expression is syntactically correct.

For example:

def json = parse_json["result"]

Existential Quantification

A logical operation that expresses the idea that there exists at least one value of a variable that makes a given relation non-empty. For example,

def R = 1;2;3
def output = exists(x : R(x), x > 2)

Formula

An expression that evaluates to either true or false.

For Expression

A Rel expression of the form {<expr> for <binding>}. A from expression evaluates to the set of all possible values of <expr> where the variable or variables in <binding> range over their set of permitted values.

| Example | Description | :------------------------------ | :-------------------| x+1 for x in {1; 2; 3} | Binary relation {(1, 2); (2, 3); (3, 4)} | x+1 from x in {1; 2; 3} | Unary relation {2; 3; 4} | x, x+1 from x in {1; 2; 3} | Binary relation {(1, 2); (2, 3); (3, 4)} | x, x+1 for x in {1; 2; 3} | Ternary relation {(1, 1, 2); (2, 2,3); (3, 3, 4)}

Function

A relation that associates every input to at most one output element, where the final element is regarded as the output and the input comprises all of the other elements.

Functional Dependency

An argument of a relation is functionally dependent on a set of arguments if it can be determined by those arguments.

For example, in the relation add, which contains a triple (x, y, z) if x + y = z, the argument z is functionally dependent on the arguments x and y.

Graph Normal Form

A level of database normalization beyond the usual Third Normal Form used by wide-table relational database management systems.

A collection of relations is in Graph Normal Form if it satisfies two conditions:

  1. Indivisibility of facts. Each tuple in each relation must correspond to a single, indivisible fact. In other words, each relation must have at most one non-key column.
  2. Things not Strings. The identity of each element in the database must reflect the identity of the concept it represents. In other words, elements in the database should be equal if and only if they are intended to represent the same real-world object.

Grounded Variables

A variable v is said to be grounded when Rel can determine that v represents an element of a finite set of values. If a variable is not grounded, error messages will inform you that it is “not ground” or “not bound”.

Head

The head of a rule is the part that appears between the keyword def and the body of the rule. For example,

def <head> {
  <body>
}

Higher Order

Rules whose arguments represent non-singleton relations.

// Move the last element of each tuple to the first position
@outline
def rotate[R] {y, x... : R(x..., y)}

Higher Order Relation

A relation, some of whose arguments represent non-singleton relations. For example, count is a higher-order relation because the relation R in count[R] represents an entire relation rather than an individual element.

Identifier

The name of a relation or variable in Rel. An identifier may be any sequence of any Unicode letter or underscore, followed by zero or more Unicode letters, underscores, or numbers. For example, the following are valid identifiers: x, a1, b1c, θ, φ, Σ, ß, β1, β2, ^V.

Incremental View Maintenance

An implementation feature of RelationalAI’s system whereby the contents of derived relations are updated incrementally whenever base relations are updated, as opposed to being repopulated from scratch in response to every change.

Infinite Relation

A relation that contains an infinite number of tuples.

For example, the relation R in the definition below contains all of the tuples ...(-3, -2), (-2, -1), (-1, 0), (0, 1), (1, 2), (2, 3), ...:

@inline
def R(x in Int, y in Int) = {
  y = x + 1
}

Inline

When a definition of relation R is annotated with @inline its definition is expanded at every place where it is used. For example,

@inline
def P[x, y] = x * x + y
def Q[x] = P[x, x] + P[2.0, 3.0]

This makes the definition of Q equivalent to:

def Q[x] = x * x + x + 2.0 * 2.0 + 3.0

Insert

A reserved relation used to insert tuples into base relations in the database. In any non-read-only transaction, the tuples in the relation insert are used to modify the base relations as follows: the first element in each tuple should be a Symbol that specifies the name of the relation to be modified, and the remaining elements should compose the tuple to be inserted into the relation.

Integrity Constraint

A declaration that ensures that a specified condition is met. For example:

ic symmetric(a, b) {
    R(a, b) implies R(b, a)
}

If a transaction is attempted that would violate an integrity constraint installed in a database, that transaction is rejected and the user is notified of the integrity constraint violation.

Join

An operation whereby data in multiple relations are combined into a single relation.

def color = {
    "UPS", "brown";
    "FedEx", "purple";
    "USPS", "blue"
}
 
def hex = {
    "purple", "#4d148c";
    "blue", "#333366";
    "brown", "#310200"
}
 
def output(carrier, hex) {
    exists(color : color(carrier, color) and hex(color, hex))
}

Key

The smallest set of arguments that uniquely identifies a tuple in a relation. In Rel, a relation’s key is customarily either all of the relation’s arguments or all of them except the last one.

Literal

An expression that directly represents a specific value. For example, 17 is an integer literal, while "flower" is a string literal.

Module

A relation that represents a collection of relations.

Partial application is used to access the relations being grouped in a module. For example, the relations store[:office] and store[:product] are grouped together in the module store below:

module store
    def office = {"Boston"; "New York"; "Los Angeles"; "Chicago"}
    def product = {(1, "Laptops"); (2, "Desktops"); (3, "Phones")}
end

The keys in a module — :office and :product in the example above — are Symbols.

Module Declaration

Syntax for defining a module that begins with module <module_name> and ends with end. For example:

module store
    def office = {"Boston"; "New York"; "Los Angeles"; "Chicago"}
    def product = {(1, "Laptops"); (2, "Desktops"); (3, "Phones")}
end

The declaration above defines a relation store which contains the following tuples:

{
    (:office, "Boston");
    (:office, "New York");
    (:office, "Los Angeles");
    (:office, "Chicago");
    (:product, 1, "Laptops");
    (:product, 2, "Desktops");
    (:product, 3, "Phones")
}

The body of a module declaration may contain rules, use declarations, integrity constraints, and other module declarations. Module declarations may also be parameterized.

Nullary Relation

A relation of arity zero. There are two nullary relations: {()} and {}.

Ontology

A description of the concepts used in a database, including rules that define how the concepts relate to one another. For example, an ontology for a zoo’s animal database might enumerate types like bird, fish, mammal, flamingo, tiger, etc., as well as facts like “all flamingos are birds, all tigers are mammals”, and so on.

Outline

An annotation that directs the compiler to use the annotated definition as a template from which to generate a first-order definition that is specialized on the higher-order parameters.

For example:

doc"Compute the transitive closure of a binary relation"
@outline
def transitive_closure[R] = R
@outline
def transitive_closure[R] = R . (transitive_closure[R])
 
def edges = (1, 2); (2, 3); (3, 4)
def output = transitive_closure[edges]

Parameterized Module Declaration

A module declaration with parameters. For example:

@outline
module my_stats[R]
    def my_minmax = (min[R], max[R])
    def my_mean = mean[R]
    def my_median = median[R]
end
def output = my_stats[{1; 2; 3; 5; 8; 13; 100}]

Partial Application

The operation of supplying an initial segment of arguments to a relation and obtaining the rest of each tuple in the relation that begins with the given arguments. For example, the output of the following transaction is {(2, 3); (4, 5)}:

def R = {
  (1, 2, 3); 
  (1, 4, 5); 
  (2, 6, 7)
}
def output = R[1]

Precedence

The order in which operations apply in an expression.

For example, the default precedence rules imply that multiplication is performed before addition in the expression 1 + 2 * 3. Curly braces or parentheses may be used to override default precedence rules: for example, the addition is performed first in (1 + 2) * 3 or {1 + 2} * 3. By convention, curly braces are often used for non-singleton relations and parentheses for singletons.

Projection

The operation of dropping some of a relation’s columns.

This example shows how you can drop the first and last columns of a ternary relation:

def myrel = { (1, "a", 2); (1, "b", 3); (3, "a", 6); (4, "b", 12) }
def output(y) = exists(x, z : myrel(x, y, z))

Query Cell

Query cells execute read-only transactions. They do not affect the state of the database or other cells.

Raw Strings

Used to represent strings that contain characters that would otherwise be interpreted as part of the string syntax.

A raw string begins with the identifier raw, immediately followed by N double quotes, where N must be an odd number. The raw string extends until the nearest occurrence of N double quotes.

raw"""
The backslash \ and percent sign % usually have special meanings.
"""

Reasoning

The process of inferring new facts based on a knowledge graph’s ontology and data.

Recursion

A rule in Rel is recursive if the same relation is referenced in the rule’s head and body. For example, the second rule in this example is recursive because it references the relation ancestor in both the head and body:

def ancestor(a, b) = parent(a, b)
def ancestor(a, b) = exists(c : parent(a, c) and ancestor(c, b))

A pair of rules is mutually recursive if the body of the first rule references the head of the second rule and vice versa. A sequence of three rules is mutually recursive if the body of the first rule references the head of the second rule, the body of the second rule references the head of the third rule, and the body of the third rule references the head of the first rule. Mutual recursion is defined similarly for sequences of four or more rules.

Rel

RelationalAI’s declarative modeling language, used to define relations and logic in the RelationalAI system.

Relation

A set of tuples. For example, {(1, 2), (3, 4), (5, 6)} is a relation with three tuples, each of which contains two elements.

Relations may be visualized as tables, with tuples corresponding to rows.

Relational Abstraction

Defines a relation without a name.

The general structure of a relational abstraction is { binding : expression }. The binding introduces one or more variables, while the expression evalutes to a relation for each value of the variables. For example:

{ x, y : x != y and exists( p : parent(p, x) and parent(p, y)) }

Relational Application

A language construct in Rel whose syntax involves a relation immediately followed by a set of arguments in parentheses. The expression evaluates to true if the tuple in the parentheses is in the relation and false otherwise.

age("Martin", 39)

This expression evaluates to true if the relation age contains the tuple ("Martin", 39), and false otherwise.

Relational Knowledge Graph

A database that represents knowledge as a collection of base relations and derived relations.

Relational Knowledge Graph Management System

A system designed to support building and using a relational knowledge graph.

RelName

Another name for Symbol.

Rule

A declaration that specifies how to populate a named relation with a set of tuples which is computed from a given logical rule.

For example, this rule says that R should contain every integer from 1 to 10:

def R(x) = range(1, 10, 1, x)

Schema

How data in a database are organized.

Schema Mapping

Transforming data from one schema to another.

Semantic Stability

One of the benefits of using Graph Normal Form: because a collection of relations in Graph Normal Form is fully broken down into indivisible facts, schema changes can be applied without having to split relations to accommodate those changes.

For example, a wide table storing many one-to-one relationships must be split into two tables if circumstances change so that one of the relationships becomes one-to-many.

Set

An unordered collection of objects that does not contain duplicates.

Shadowed Variable

A variable introduced in a particular scope shadows any variable with the same name in an outer scope.

String

A sequence of characters. For example, the string "Hello" is a string consisting of the five characters 'H', 'e', 'l', 'l', and 'o'.

String Interpolation

A Rel language construct for embedding a value into a string. For example, if you have a singleton relation name that contains the string "Alice", you can embed it into a string like this: "Hello %(name)!".

Syntax

The textual form of a construct in a language. For example, the Rel syntax for defining a relation involves using the keyword def.

Symbol

A data type in Rel which is similar to String but which is typically used to indicate that the element represents schema rather than data. For example, the names of relations or the column headers in CSV data are represented and can be accessed using Symbols. A Symbol has the form of an identifier prefixed with a colon, such as :title.

Symbols are also used to represent relation names in modules. For example, the partial application Graph[:edge] may be used to access the relation called edge in the module Graph:

module Graph
    def node = {1; 2; 3; 4}
    def edge = {(1,2); (2, 3); (3, 4); (4, 1)}
end
def output = Graph[:edge]
 
 
## The Relational Model
 
An organizational structure for databases wherein all data are organized into sets of tuples.
 
 
## Things Not Strings
 
A catchphrase for the idea that elements in the database should be represented in a way that encodes their meaning.
 
Specifically, a database is said to satisfy the "things not strings" principle if it is possible to determine whether two elements in the database are intended to refer to the same real-world concept by doing an equality comparison between the two elements.
 
 
## Transactions
 
A unit of work that takes the database from one state to another. 
Transactions happen *atomically*, meaning that either the entire transaction succeeds or it fails and the database is left unchanged.
 
 
## Tuple
 
An ordered list of elements. 
For example, the tuple `("AcmeCo", 1920-06-21)` is a tuple containing two elements: the string `"AcmeCo"` and the date `1920-06-21`.
 
 
## Underscore
 
A synonym of `Any`, the infinite relation that contains every element. 
 
 
After further rewriting, this typically becomes an existential quantification of a variable with a unique name. Underscore is often used when you do not care about certain arguments of a
relation and want to avoid introducing a named variable and quantifier.
 
```rel
// Unary relation of all orders with a line item:
{ order: line_item(order, _) }

Update

A write transaction. An update typically changes the state of the database in some way.

Use Declaration

A language construct in Rel that allows you to import relations from a module into the current scope:

module store
    def office = {"Boston"; "New York"; "Los Angeles"; "Chicago"}
    def product = {(1, "Laptops"); (2, "Desktops"); (3, "Phones")}
end
 
module summary
    with store use office, product
 
    def num_offices = count[office]
    def num_products = count[product]
end

Value Column

A column in a relation that is not part of the relation’s key.

Value Type

A value type is a custom type for database elements. For example, rather than representing a distance using a floating point number, you can represent the element in a way that includes both the quantity and the unit:

def UnitOfDistance = :in ; :cm ; :km ; :mile
value type UDistance = UnitOfDistance, Float
def dist = (:A, :B, ^UDistance[:cm, 100.0])
def dist = (:B, :C, ^UDistance[:in,  50.0])

Varargs

A mechanism to write code that works for multiple arities, where x... matches zero or more variables. For example, the stdlib defines first and last as:

@inline
def first[R](x) = (y... : R(x, y...))
 
@inline
def last[R](y) = (x... : R(x..., y))

Vector

A data structure which represents an ordered list of elements.

Vectors are represented in Rel as binary relations. The first column is the array index, and the second column is the value at that index:

def A = {
  (1, 4.2);
  (2, 18.0);
  (3, 3.14);
  (4, 11.0);
  (5, 7.5)
}
Was this doc helpful?