Search
ctrl/
Ask AI
Light
Dark
System

Object Types

Object types are the primary components of an EdgeDB schema. They are analogous to SQL tables or ORM models, and consist of properties and links.

Properties are used to attach primitive data to an object type. In versions prior to EdgeDB 3.0 they must be declared with the property keyword, but the keyword is not required in 3.0+ unless the property is a computed property. For the full documentation on properties, see Properties.

Copy
type Person {
  email: str;
}

Links are used to define relationships between object types. Prior to EdgeDB 3.0, they must be declared with the link keyword, but the keyword is not required in 3.0+ unless the link is computed (e.g., backlinks). For the full documentation on links, see Links.

Copy
type Person {
  best_friend: Person;
}

There’s no need to manually declare a primary key on your object types. All object types automatically contain a property id of type UUID that’s required, globally unique, and readonly. This id is assigned upon creation and never changes.

Object types can either be abstract or non-abstract. By default all object types are non-abstract. You can’t create or store instances of abstract types, but they’re a useful way to share functionality and structure among other object types.

Copy
abstract type HasName {
  first_name: str;
  last_name: str;
}

Abstract types are commonly used in tandem with inheritance.

Object types can extend other object types. The extending type (AKA the subtype) inherits all links, properties, indexes, constraints, etc. from its supertypes.

Copy
abstract type Animal {
  species: str;
}

type Dog extending Animal {
  breed: str;
}

Object types can extend more than one type — that’s called multiple inheritance. This mechanism allows building complex object types out of combinations of more basic types.

Copy
abstract type HasName {
  first_name: str;
  last_name: str;
}

abstract type HasEmail {
  email: str;
}

type Person extending HasName, HasEmail {
  profession: str;
}

If multiple supertypes share links or properties, those properties must be of the same type and cardinality.

Refer to the dedicated pages on Indexes, Constraints, Access Policies, and Annotations for documentation on these concepts.