The OrientDB engine supports Graph, Document, Key/Value, and Object models, so you can use OrientDB as a replacement for a product in any of these categories. However, the main reason why users choose OrientDB is because of its true Multi-Model DBMS abilities, which combine all the features of the four models into the core. These abilities are not just interfaces to the database engine, but rather the engine itself was built to support all four models. This is also the main difference to other multi-model DBMSs, as they implement an additional layer with an API, which mimics additional models. However, under the hood, they're truly only one model, therefore they are limited in speed and scalability.
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 the 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 advantageous, 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" as its form of "collections" for grouping documents. This provides several benefits, which we will discuss in further sections of the documentation.
OrientDB's Document model also adds the concept of a "LINK" as a relationship between documents. With OrientDB, you can decide whether to embed documents or link to them directly. When you fetch a document, all the links are automatically resolved by OrientDB. This is a major difference to other Document Databases, like MongoDB or CouchDB, where the developer must handle any and all relationships between the documents herself.
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|
|Column||Key/value pair||Document field|
A graph represents a network-like structure consisting of Vertices (also known as Nodes) interconnected by Edges (also known as Arcs). 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 an incoming Vertex (also known as head)
- link to an 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 that extends "V" (for Vertex) and "E" (for Edges)|
|Column||Vertex and Edge property||Vertex and Edge property|
This is the simplest model of the three. Everything in the database can be reached by a key, where the values can be simple and complex types. OrientDB supports Documents and Graph Elements as values allowing for a richer model, than what you would normally find in the classic Key/Value model. The classic Key/Value model provides "buckets" to group key/value pairs in different containers. The most classic use cases of the Key/Value Model are:
- POST the value as payload of the HTTP call ->
- GET the value as payload from the HTTP call ->
- DELETE the value by Key, by calling the HTTP call ->
The table below illustrates the comparison between the relational model, the Key/Value model, and the OrientDB Key/Value model:
|Relational Model||Key/Value Model||OrientDB Key/Value Model|
|Table||Bucket||Class or Cluster|
|Column||not available||Document field or Vertex/Edge property|
This model has been inherited by Object Oriented programming and supports Inheritance between types (sub-types extends the super-types), Polymorphism when you refer to a base class and Direct binding from/to Objects used in programming languages.
The table below illustrates the comparison between the relational model, the Object model, and the OrientDB Object model: