Introduction
Graph theory in mathematics is study of graphs. Graphs in mathematics can be used to represent a solution of a problem. A graph consists of dots called vertices (V) and lines connecting dots are called edges (E). Two connecting vertices by an edge are adjacent.
By Mathematical Definition
A graph is an ordered pair G=(V,E) consisting of a nonempty set V (called vertices) and a set E (called edges) of two-element subset of V.
Graphs are drawings with numbered vertices connected by edges. Here is an example of a graph that has 6 vertices and 7 edges.
G = (V, E) = ({a, b, c, e, e, f}, {{a, b}, {b, c}, {a, d}, {c, d}, {d, e}, {c, f}, {e, f} })
Graph Databases
Graph databases are developed based on graph theory. In graph databases, a graph can be used to represent data entities, their attributes, and relationships. The vertices of a graph database are called nodes and edges are called edges.

A graph database is a set of nodes, edges, and properties. Nodes in a graph database represents entities. Nodes in a graph database are equivalent to a table in a relational database. A node in a graph database is equivalent to a record (a row) in a relational database. Edges in a graph database represent relationships between two nodes and equivalent to relationships in a relational database. Edges in a graph database can be directed or undirected. Direction on edges has a different meaning than undirected edges. In some graph databases, edges can have numerical values also known as weight. Properties in a graph database represents data that can be applied to nodes and edges. In a graph database, both nodes and the edges can store data.

The above diagram is a graphical representation of a graph database with three nodes, Bob, Alice, and James. The entity type of the nodes is Person. The properties of Person entity include Name, Sex, Born, College, and Employer. The connecting lines (edges) represent the relationship between two nodes.
Graph Database Query Languages
Graph databases are NoSQL databases. That means, unlike relational databases, graph databases do not use SQL as their query language. The data storage format of graph databases can use different formats such as a table, document, or a key-value pair. Graph databases are based on semantic queries and allows fast retrieval of data by design.
There is no single universal query language for all graph databases. Each graph database provides its own query language or API or library.
A few common more widely accepted and used query languages are GraphQL, AQL, Gremlin, SPARQL, and Cypher.
- GraphQL is Facebook query language for any backend service provide by Facebook.
- AQL (ArangoDB Query Language) is an SQL like query language used in ArangoDB databases.
- Cypher Query Language a graph query declarative language for Neo4j databases.
- Gremlin is a graph programming language that works over various graph database systems; part of Apache TinkerPop open-source project.
- SPARQL is a query language for RDF databases, can retrieve and manipulate data stored in Resource Description Framework format.
- Microsoft, Facebook, LinkedIn, Twitter and several other large corporations expose their data via APIs and their own languages. The following diagram represents a Microsoft graph database model used in Office 365.


Join the conversation! Your thoughts help the community grow.