OrientDB Manual

Document and Graph Models

OrientDB supports both document and graph data models. This combinations provides an extended set of features that can be utilized in several different scenarios.

Document Model

The data in this model is stored inside documents. A document is a set of key/value pairs (also referred to as fields or properties) where a key allows access to its value. Values can hold primitive data types, embedded documents or arrays of other values. Documents are not typically forced to have a schema which can be a benefit because they remain flexible and easy to modify. Documents are stored in collections enabling developers to group data as they decide. OrientDB uses the concepts of "classes" and "clusters" instead of "collections" for grouping documents. This provides several benefits we will discuss in further sections of the documentation. The table below illustrates the comparison between the relational model, the document model and the OrientDB document model:

Relational Model Document Model OrientDB Document Model
Table Collection Class or cluster
Row Document Document
Column Key/value pair Key/value pair
Relationship not available Link

Graph Model

A graph represents a network-like structure consisting of vertices (also known as nodes) interconnected by edges (also known as relationships). OrientDB's graph model is represented by the concept of a property graph, which defines the following:

  • vertex - an entity that can be linked with other vertices and has the following mandatory properties:
    • unique identifier
    • set of incoming edges
    • set of outgoing edges
  • edge - an entity that links two vertices and has the following mandatory properties:
    • unique identifier
    • link to incoming vertex (also known as head)
    • link to outgoing vertex (also known as tail)
    • label that defines the type of connection/relationship between head and tail vertex

In addition to mandatory properties each vertex or edge can also hold a set of custom properties. These properties can be defined by users, which can make vertices and edges appear similar to documents. In the table below, you can find a comparison between the graph model, the relational data model and the OrientDB graph model:

Relational Model Graph Model OrientDB Graph Model
Table Vertex and Edge Class Class or Cluster
Row Vertex Vertex
Columns Key/value pair Key/value pair
Relationship Edge Edge