Schema

A schema is like a blueprint of a database that contains all user-defined types and rules used in a database. All queries are validated with the TypeQL syntax and a type system of a schema. Every piece of data inserted in a TypeDB database as an instance of a type. Rules are used for reasoning.

Queries

Table 1. Schema queries
Query type № of clauses Clause(s) Keyword Mandatory

Define

1

Define

define

Yes

Undefine

1

Undefine

undefine

Yes

Both Define and Undefine queries can be used only in a schema session and write transaction. For more information on the limitations of a schema session, see the Schema integrity enforcement.

Type system

Types in a schema are modeled with the use of the PERA model.

To create new types in a schema, subtype one of the existing types. A subtype inherits all definitions of its supertype.

By default, a schema has three built-in root types that can be subtyped, but can’t be instantiated (used to insert data).

Table 2. Root (built-in) types
Root type label A subtype of the root type An instance of data of a subtype

entity

Entity type

Instance of entity type

relation

Relation type

Instance of relation type

attribute

Attribute type

Instance of attribute type

For more information on type definitions, see the Type definitions page.

To learn about rules, see the Rule definitions page.

Provide Feedback