Query Languages for Graph Databases

Query Languages for Graph Databases

Copyright: © 2018 |Pages: 12
DOI: 10.4018/978-1-5225-2255-3.ch176
(Individual Chapters)
No Current Special Offers


In the past few years many NoSQL databases have emerged, including graph databases. NoSQL databases have certain advantages and they can be used in certain domains as an alternative to relational databases. In order to use graph databases, one needs to be familiar with specific languages like Cypher Query Language (CQL) or Gremlin. However, some statements in CQL can be considered too complex for end users as it is shown later on. Because of that the main idea of this paper is to explore two other languages for graph databases. One of them is new and it is used to pose queries visually. Since CQL does not support recursion, views, etc., the other language is used to show how to use recursion and views on a graph database.
Chapter Preview


One can find more or less complicated definitions, but one could say that a database is an organized collection of data. It is assumed that a database is stored as files on a computer. Actually, any list of items on a paper could be called a collection of data as well, but today it is assumed that databases are stored digitally.

In order to create a text file, some text processor should be used (for example, Word, Wordpad, Notepad, etc.). In the same way, in order to create a database, some Database Management System (DBMS) should be used. Many systems are available, including Oracle, DB2, SQL Server, PostgreSQL, MySQL, Microsoft Access, Neo4j, MongoDB, etc. The majority of DBMSs are relational in nature. “Relational” means that the main structure that is used to store data is a relation, or as users usually call it, a table. One table contains zero or more rows. The idea of storing data into relations (tables) is quite old and relational databases have been used for over 40 years. Relations store data in a compact and organized way and redundancy and anomalies that are caused by redundancy are usually avoided. The relational model was introduced by dr. E. F. T. Codd. in the late 1960s and early 1970s.

In order to use a database management system, one has to be familiar with Structured Query Language (SQL). SQL is a standardized language that is supported by all major Relational DBMS software vendors (it does not belong to any vendor in particular). SQL contains many statements to work with data. The CREATE statement is used to create different objects in the database, as well as the database itself. The INSERT, UPDATE and DELETE statements are used for data manipulation purposes. In order to retrieve data from one or more tables, SELECT statement is used. Many other, complex statements are available as well, but for our purposes, we can skip the details. Each DBMS has some (graphical) client program (one or more) that can be used to write queries (in SQL) in order to work with the database (for example, phpMyAdmin, Workbench, Navicat, pgAdmin, SQL Server Management Studio, etc.). More on SQL can be found in (Rabuzin, 2011, 2014).

Relational databases are mature technology; many DBMSs are available, SQL is standardized, etc. But in recent years things have changed. Extremely large amounts of unstructured and/or semi structured data come from different sources and relational databases can not cope with such large amounts of data in a satisfactory manner. Furthermore, certain queries require too much time to execute and sometimes such behavior is not acceptable. Because of this new types of databases are being invented (and used) on a daily basis, especially NoSQL technologies, which are becoming more and more important.

The word NoSQL had different meanings in the past (for example, No to SQL), but today people usually mean “Not Only SQL”. When one talks about NoSQL databases, several different types can be distinguished (some authors believe that XML databases should be included as well, as well as some other types, but it doesn’t make much difference):

  • Document oriented databases,

  • Column oriented databases,

  • Key Value databases,

  • Graph databases.

Document oriented databases, like MongoDB, do not use tables to store data. Instead, they use collections that store documents. Since one document contains all the data that are relevant, foreign keys are not used (at least not in a form that one is used to in relational databases). Document databases can use references to link between documents, but usually all the referenced data could/should be included within the document. So basically, collections would correspond to tables and documents would correspond to rows. It is important to have in mind that the document schema is flexible and each document within the collection can have different schema.

Key Terms in this Chapter

Cypher Query Language (CQL): In order to use graph databases CQL could be used, but other languages do exist as well.

Query By Example (QBE): Visual query language supported in Microsoft Access.

Visual Cypher: A new, proposed graphical language for graph databases.

Structured Query Language (SQL): A standardized language for relational databases.

NoSQL: New database types that are used as an alternative to the relational data model.

Datalog: A logic programming language that is important for deductive databases.

Graph Databases: A database type that uses vertices and edges to store information.

Complete Chapter List

Search this Book: