OrientDB – Restore Database ”; Previous Next As like RDBMS, OrientDB also supports restoring operation. Only from the console mode, you can execute this operation successfully. The following statement is the basic syntax for restoring operation. orientdb> RESTORE DATABSE <url of the backup zip file> Example You have to perform this operation only from the console mode. Therefore, first you have to start the OrientDB console using the following OrientDB command. $ orientdb Then, connect to the respective database to restore the backup. You can use the following command to connect to the database named demo. orientdb> CONNECT PLOCAL:/opt/orientdb/databases/demo admin admin After successful connection, you can use the following command to restore the backup from ‘backup-demo.zip’ file. Before executing, make sure the backup-demo.zip file is placed in the current directory. Orientdb {db = demo}> RESTORE DATABASE backup-demo.zip If this command is executed successfully, you will get some success notifications along with the following message. Database restored in 0.26 seconds Print Page Previous Next Advertisements ”;
Category: orientdb
OrientDB – Basic Concepts
OrientDB – Basic Concepts ”; Previous Next The main feature of OrientDB is to support multi-model objects, i.e. it supports different models like Document, Graph, Key/Value and Real Object. It contains a separate API to support all these four models. Document Model The terminology Document model belongs to NoSQL database. It means the data is stored in the Documents and the group of Documents are called as Collection. Technically, document means a set of key/value pairs or also referred to as fields or properties. OrientDB uses the concepts such as classes, clusters, and link for storing, grouping, and analyzing the documents. The following table illustrates the comparison between relational model, document model, and OrientDB document model − Relational Model Document Model OrientDB Document Model Table Collection Class or Cluster Row Document Document Column Key/value pair Document field Relationship Not available Link Graph Model A graph data structure is a data model that can store data in the form of Vertices (Nodes) interconnected by Edges (Arcs). The idea of OrientDB graph database came from property graph. The vertex and edge are the main artifacts of the Graph model. They contain the properties, which can make these appear similar to documents. The following table shows a comparison between graph model, relational data model, and 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) Row Vertex Vertex Column Vertex and Edge property Vertex and Edge property Relationship Edge Edge The Key/Value Model The Key/Value model means that data can be stored in the form of key/value pair where the values can be of simple and complex types. It can support documents and graph elements as values. The following table illustrates the comparison between relational model, key/value model, and OrientDB key/value model. Relational Model Key/Value Model OrientDB Key/Value Model Table Bucket Class or Cluster Row Key/Value pair Document Column Not available Document field or Vertex/Edge property Relationship Not available Link The Object Model 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 following table illustrates the comparison between relational model, Object model, and OrientDB Object model. Relational Model Object Model OrientDB Object Model Table Class Class or Cluster Row Object Document or Vertex Column Object property Document field or Vertex/Edge property Relationship Pointer Link Before go ahead in detail, it is better to know the basic terminology associated with OrientDB. Following are some of the important terminologies. Record The smallest unit that you can load from and store in the database. Records can be stored in four types. Document Record Bytes Vertex Edge Record ID When OrientDB generates a record, the database server automatically assigns a unit identifier to the record, called RecordID (RID). The RID looks like #<cluster>:<position>. <cluster> means cluster identification number and the <position> means absolute position of the record in the cluster. Documents The Document is the most flexible record type available in OrientDB. Documents are softly typed and are defined by schema classes with defined constraint, but you can also insert the document without any schema, i.e. it supports schema-less mode too. Documents can be easily handled by export and import in JSON format. For example, take a look at the following JSON sample document. It defines the document details. { “id” : “1201”, “name” : “Jay”, “job” : “Developer”, “creations” : [ { “name” : “Amiga”, “company” : “Commodore Inc.” }, { “name” : “Amiga 500”, “company” : “Commodore Inc.” } ] } RecordBytes Record Type is the same as BLOB type in RDBMS. OrientDB can load and store document Record type along with binary data. Vertex OrientDB database is not only a Document database but also a Graph database. The new concepts such as Vertex and Edge are used to store the data in the form of graph. In graph databases, the most basic unit of data is node, which in OrientDB is called a vertex. The Vertex stores information for the database. Edge There is a separate record type called the Edge that connects one vertex to another. Edges are bidirectional and can only connect two vertices. There are two types of edges in OrientDB, one is regular and another one lightweight. Class The class is a type of data model and the concept drawn from the Object-oriented programming paradigm. Based on the traditional document database model, data is stored in the form of collection, while in the Relational database model data is stored in tables. OrientDB follows the Document API along with OPPS paradigm. As a concept, the class in OrientDB has the closest relationship with the table in relational databases, but (unlike tables) classes can be schema-less, schema-full or mixed. Classes can inherit from other classes, creating trees of classes. Each class has its own cluster or clusters, (created by default, if none are defined). Cluster Cluster is an important concept which is used to store records, documents, or vertices. In simple words, Cluster is a place where a group of records are stored. By default, OrientDB will create one cluster per class. All the records of a class are stored in the same cluster having the same name as the class. You can create up to 32,767(2^15-1) clusters in a database. The CREATE class is a command used to create a cluster with specific name. Once the cluster is created you can use the cluster to save records by specifying the name during the creation of any data model. Relationships OrientDB supports two kinds of relationships: referenced and embedded. Referenced relationships means it stores direct link to the target objects of the relationships. Embedded relationships means it stores the relationship within the record that embeds it. This relationship is stronger than the reference relationship. Database The database is an interface to access the real storage. IT
OrientDB – Backup Database
OrientDB – Backup Database ”; Previous Next Like RDBMS, OrientDB also supports the backup and restore operations. While executing the backup operation, it will take all files of the current database into a compressed zip format using the ZIP algorithm. This feature (Backup) can be availed automatically by enabling the Automatic-Backup server plugin. Taking backup of a database or exporting a database is the same, however, based on the procedure we have to know when to use backup and when to use export. While taking backup, it will create a consistent copy of a database, all further write operations are locked and waiting to finish the backup process. In this operation, it will create a read-only backup file. If you need the concurrent read and write operation while taking a backup you have to choose exporting a database instead of taking backup of a database. Export doesn’t lock the database and allows concurrent writes during the export process. The following statement is the basic syntax of database backup. ./backup.sh <dburl> <user> <password> <destination> [<type>] Following are the details about the options in the above syntax. <dburl> − The database URL where the database is located either in the local or in the remote location. <user> − Specifies the username to run the backup. <password> − Provides the password for the particular user. <destination> − Destination file location stating where to store the backup zip file. <type> − Optional backup type. It has either of the two options. Default − locks the database during the backup. LVM − uses LVM copy-on-write snapshot in background. Example Take a backup of the database demo which is located in the local file system /opt/orientdb/databases/demo into a file named sample-demo.zip and located into the current directory. You can use the following command to take a backup of the database demo. $ backup.sh plocal: opt/orientdb/database/demo admin admin ./backup-demo.zip Using Console The same you can do using the OrientDB console. Before taking the backup of a particular database, you have to first connect to the database. You can use the following command to connect to the database named demo. orientdb> CONNECT PLOCAL:/opt/orientdb/databases/demo admin admin After connecting you can use the following command to take backup of the database into a file named ‘backup-demo.zip’ in the current directory. orientdb {db=demo}> BACKUP DATABASE ./backup-demo.zip If this command is executed successfully, you will get some success notifications along with following message. Backup executed in 0.30 seconds Print Page Previous Next Advertisements ”;
OrientDB – Console Modes
OrientDB – Console Modes ”; Previous Next The OrientDB Console is a Java Application made to work against OrientDB databases and Server instances. There are several console modes that OrientDB supports. Interactive Mode This is the default mode. Just launch the console by executing the following script bin/console.sh (or bin/console.bat in MS Windows systems). Make sure to have execution permission on it. OrientDB console v.1.6.6 www.orientechnologies.com Type ”help” to display all the commands supported. orientdb> Once done, the console is ready to accept commands. Batch Mode To execute commands in batch mode run the following bin/console.sh (or bin/console.bat in MS Windows systems) script passing all the commands separated with semicolon “;”. orientdb> console.bat “connect remote:localhost/demo;select * from profile” Or call the console script passing the name of the file in text format containing the list of commands to execute. Commands must be separated with semicolon “;”. Example Command.txt contains the list of commands which you want to execute through OrientDB console. The following command accepts the batch of commands from the command.txt file. orientdb> console.bat commands.txt In batch mode, you can ignore errors to let the script continue the execution by setting the “ignoreErrors” variable to true. orientdb> set ignoreErrors true Enable Echo When you run console commands in pipeline, you will need to display them. Enable “echo” of commands by setting it as property at the beginning. Following is the syntax to enable echo property in OrientDB console. orientdb> set echo true Print Page Previous Next Advertisements ”;