1. What is a graph database?
Welcome back! In the previous chapter, we learned the main concepts of column family databases. Let's end this course by studying the basic concepts of graph databases!
2. Graph databases - overview
Graph databases are
designed to treat data and its relationships with the same importance.
They are based on graph theory,
which is a branch of mathematics
that studies the graphs for modeling the relationships between objects.
3. Graph databases - parts of a graph
Graphs are structures that have two parts.
The vertices, also called nodes,
and the edges,
4. Graph databases - parts of a graph
also known as links or arcs.
5. Graph databases - nodes
Nodes represent entities, for example, users, cities, airports, employees, etc.
Let's represent the users of the Datazy social network with a graph.
Nodes can have properties,
6. Graph databases - nodes
such as the name, surname, email, date of birth, etc.
7. Graph databases - edges
Edges connect the nodes
and define
8. Graph databases - edges
the relationships between the nodes. In this example, we can see that Carol follows Ben and Shui, Ben also follows Shui, and Shui follows Carol.
Edges also have
9. Graph databases - edges
properties. Here we can see that the property of the edges is the year when a user started to follow another user.
10. Graph databases - types of edges
There are two kinds of edges.
Edges are directed
when they have one specific direction.
For example, Carol likes post number one and post number two, and Ben likes post number 2.
11. Graph databases - types of edges
Edges can also be undirected
when they have no direction. In this case,
we assume the relationship is mutual.
For example, we can model the friendship between Ben and Daya with undirected edges, assuming that both are friends.
12. Graph databases - queries
Querying the graph is called
traversing the graph.
For instance,
in the first example we saw, we can get all the users that Ben follows,
or get when Carol started following Shui.
In a graph where nodes represent cities, and the edges represent the highways that connect the cities with their distances, we can get the shortest path from one city to another.
The set of nodes and their edges across a graph is called a path.
Graph databases support query languages such as Cypher or Gremlin to retrieve and store data.
13. Popular graph databases
Here are some popular graph databases.
14. Let's practice!
Let's practice with some exercises about the basics of graph databases!