5 & 6 - Graph Database
5 & 6 - Graph Database
• Semantic Overloading
• Homogeneity
– Horizontal
• all tuples have to range over the same set of attributes;
• that is, all rows have a fixed uniform format defined by the columns.
– Vertical
• values in one column have to come from the same predefined attribute
domain;
• mixing values from different domains in one column is not allowed.
Weaknesses of RDMS
• Infrequent updates:
• SQL dialects
• Restricted data types
• Declarative access
• Short-lived transactions
• Lower throughput
• Rigid schema
• Non-versioned data
Graph Database
• A graph is a structure that not only can represent data but also connections
between them.
– data objects
• which may have certain properties and are equivalent to entities in the relational terminology
• also called vertices)
– a set of links
• between these objects which characterize the relationship of the objects.
• also called arcs
• Graph databases application are domains where the links between data objects
are important and need to have their own semantics
A Review on Graph Theory
• A graph G consists of a set of vertices (denoted V) and a set of edges (denoted E); that is, G =
(V, E).
• The edge set E is a set of pairs of nodes; that is, each edge is represented by those two
vertices that are connected by the edge.
– In case of a directed edge the pair of nodes is ordered where the first node is the source node of the edge and the last
node is the target node
– In the undirected case, order of the pair of nodes does not matter because the edge can be traversed in both
directions.
• A graph is called undirected if it only has undirected edges, whereas a graph is called directed
(or a digraph) if it only has directed edges.
• A graph is called multigraph if it has a pair of nodes that is connected by more than one edge.
Simple Undirected Graph
Simple Directed Graph
Undirected Multigraph
Directed Multigraph
Weighted Graphs
Graph Traversal and Graph Problems
• Path: A connection between to nodes consisting of intermediary nodes and the
edges between them.
• Cycle: a path where starting node and end node are the same
– breadth-First search: It search visits all adjacent nodes of the starting node (in the given order)
and then does the same with the adjacent nodes of its First adjacent node, then of its second
adjacent node and so on
• When traversing a graph, restrictions may be applied that have come to known as
graph problems
Graph Problem
Graph Problem
Graph Problem
Graph Data Structure
• Adjacency
– Two nodes are adjacent if they are neighbors (that
is, there is an edge between them).
• Incidence
– An edge is incident to a node, if it is connected to
the node;
• if the edge is directed, it is positively incident to its
source node and negatively incident to its target node.
– A node is incident to an edge, if it is connected to
the edge.
Adjacency Matrix
• For cardinality |V| = n the adjacency matrix is
an n×n matrix where rows and columns
denote all the vertices v1 . . . vn.
• Neo4j