Home etc Blogs OrientDB: A Flexible and Scalable Multi-Model NoSQL DBMS

OrientDB: A Flexible and Scalable Multi-Model NoSQL DBMS

0
268
OrientDB

The optimal performance of a software application depends on how efficiently the underlying data model is defined. OrientDB is a multi-model NoSQL database management system that combines the strengths of graphs with the flexibility of documents, and is highly scalable. This article introduces various features of OrientDB.

the success of a software application is dependent to a large extent on the manner in which data is represented in it. The underlying data model decides critical application performance measures such as speed. Modern-day database management systems provide excellent features that help to work with data in an optimal manner. NoSQL databases have become an important part of the data analysis ecosystem.

Features of OrientDB
In the past, databases had the ability to support only a single data model. OrientDB can support multiple data models. Its features are listed in Figure 1.

OrientDB features
Figure 1: OrientDB features

Speed: OrientDB is tailor-made to work at a super speed. The official documentation claims that it can store up to 120,000 records in a second. The speed of OrientDB is excellent for both read and write operations. The usage of RAM is also better. The traversing speed of the tree is not affected majorly by the size of the database, which is an awesome feature to have.

Enterprise level abilities: Though NoSQL databases are very useful, in many scenarios they are adapted as secondary databases. The power of OrientDB lies in the fact that it is both flexible and powerful to function as an operational DBMS.

Zero configuration multi-master architecture: OrientDB provides elastic linear scalability. As it has zero configuration multi-master architecture, it is very well suited for the cloud environment.

Zero delay start: The ability to get started without any delay is an important reason why you should choose OrientDB. As it is built using Java, it can run on all major operating systems without depending on a long list of dependencies.

Multi-language bindings: OrientDB has bindings for multiple languages. So it is easier to adapt it in various environments without making major modifications to your existing architecture.

Free and open source: Being free and open source software (FOSS), OrientDB is well tested and customisable. Its cost of ownership is very minimal.

Flavours of OrientDB
OrientDB is available in two major flavours or editions:

  • Community edition
  • Enterprise edition

The Community edition is available in free and open source mode with an Apache 2 License, which provides unrestricted usage for open source and commercial projects.
The Enterprise edition has some additional features. To name a few: query profiler, distributed clustering configuration, non-stop backup and restore, etc.

OrientDB editions
Figure 2: OrientDB editions

Getting started with OrientDB
OrientDB can be freely downloaded from https://orientdb.org/download. As stated earlier, it is available for all major operating systems such as GNU Linux, Mac OS and Microsoft Windows. To run the OrientDB for the first time, carry out the following steps:

  • Download the installer matching the operating system in which you want to install OrientDB. Extract the files to a folder.
  • The server can be started by firing server.sh (in the case of Windows, run the file server.bat).
  • During the first run, it will ask for the password for root account. Set the password.
    As OrientDB starts, open your browser and type the following URL: http://localhost:2480. If OrientDB is installed properly, you will get the login screen (Figure 3).
OrientDB login screen
Figure 3: OrientDB login screen
  • Enter the user name and password (you can create a new DB or choose an existing DB), and you will be redirected to the Studio Home screen (Figure 4).

    OrientDB Studio Home screen
    Figure 4: OrientDB Studio Home screen
import com.orientechnologies.orient.core.db.ODatabaseSession;
import com.orientechnologies.orient.core.db.OrientDB;
import com.orientechnologies.orient.core.db.OrientDBConfig;
import com.orientechnologies.orient.core.metadata.schema.OClass;
import com.orientechnologies.orient.core.metadata.schema.OType;
public class Main {
  public static void main(String[] args) {
    OrientDB orient = new OrientDB(“remote:localhost”,         OrientDBConfig.defaultConfig());
    ODatabaseSession db = orient.open(“test”, “admin”, “admin”);
    OClass person = db.getClass(“Person”);
    if (person == null) {
      person = db.createVertexClass(“Person”);
    }
    if (person.getProperty(“name”) == null) {
      person.createProperty(“name”, OType.STRING);
      person.createIndex(“Person_name_index”, OClass.INDEX_TYPE.NOTUNIQUE, “name”);
    }
    if (db.getClass(“FriendOf”) == null) {
      db.createEdgeClass(“FriendOf”);
    }
    db.close();
    orient.close();
  }
}

You can then run the queries on the graph. Detailed instructions and a demo is available in the official documentation at https://orientdb.org/docs/3.0.x/fiveminute/java-4.html

Multi-model
As stated earlier, the OrientDB engine has support for various models, as listed below:

  • Graph
  • Document
  • Key-value
  • Object model
Multi-model OrientDB
Figure 5: Multi-model OrientDB

The real power of OrientDB lies in the fact that it can combine all the features of the aforementioned four models. The core engine itself is built to support all these models. Some multi-model choices simply provide an interface. At the core level these tools have only one model, but through some sort of an additional API layer, they provide support for other models. This hinders their performance by affecting the speed and scalability. In the case of OrientDB, the multi-model support is at the core level, which enhances its speed and scalability.

The document model: Here, data is stored inside the documents. These documents are not mandated to have any specific schema. They are flexible and easy to modify. OrientDB uses Class, Document and Link to represent Table, Row and Relationship respectively.

The graph model: In the graph model, vertices and edges are used. The vertices are connected by edges. Edges are used to link two vertices. The OrientDB graph model has a Class that extends Vertices and Edges.

Key-value model: The key-value model is the simplest of the models. The OrientDB key-value model has Class for Table and Link for Relationships.

Object model: The object model has support for inheritance between types. With features such as direct binding, this model is highly suitable in scenarios where object representation can capture the real-world scenario in a better manner.

PyOrient
One of the advantages of OrientDB is the support for multiple languages. With the PyOrient module, it can be used along with the Python language. To install PyOrient, use the following code snippet:

sudo pip install pyorient

The PyOrient client can be used to connect to the OrientDB server, as follows:

client = pyorient.OrientDB(“localhost”, 2424)
session_id = client.connect(“admin”, “admin_passwd”)

The shutdown operation can be carried out with the following code snippet:­­­­

client.shutdown(‘root’, ‘root_passwd’)

A few useful functions to work with PyOrient are listed below.

  • command(): To issue SQL commands
  • Batch(): To issue batches of commands
  • db_create(): For creating a database
  • db_drop(): For removing a database
  • query (): To issue synchronous queries to the database.

For the detailed list, navigate to https://orientdb.com/docs/2.2.x/PyOrient-Client.html.

With all these features, OrientDB is a great choice if you want multi-model support for your application. If you are interested in learning more about OrientDB, there is a free course offered. You can find out more about the course at https://orientdb.org/getting-started.

NO COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here