EdgeDB is a relational database with strongly typed schema.
An EdgeDB schema is primarily composed from object type definitions, which describe entities in a specific domain. An object type is a collection of named properties and links to other types.
Here is an example of a simple EdgeDB type using the Edge Schema notation:
type User {
property name -> str;
property address -> str;
multi link friends -> User;
}
str
in the above example is a
scalar type. EdgeDB also supports
collection types. Scalar
types and collection types are collectively called primitive types in
contrast with object types.
EdgeDB schemas consist of modules. Modules contain schema items.
There are several kinds of schema items:
Most items in EdgeDB schema support inheritance as a composition mechanism.
Schema items can extend other item(s) of the same kind. When extending,
child items inherit the aspects of the parent item(s) in a manner specific
to the schema item kind. For example, when an object type extends another
object type, it inherits all parent properties, links, constraints and other
aspects. Additionally, for instances of the child type
object IS ParentType
is true
(see IS operator
). Also,
instances of the child type are included in the set of all instances of
the parent type.
Multiple inheritance allows composing several types into one. A common
pattern is to have many basic abstract types (such as Named
,
HasEmail
, HasAddress
, etc.) each with their own links and
properties and then extending different combinations of them.
Finally, various inheritance structures enable the use of polymorphic queries.
EdgeDB schema definition language is a high-level declarative alternative to EdgeDB data definition commands. It is designed to be a concise and readable representation of schema state. Most of the examples and synopses in this section use the SDL notation.