0% found this document useful (0 votes)
40 views46 pages

5 & 6 - Graph Database

The document discusses the weaknesses of Relational Database Management Systems (RDMS) and introduces graph databases as an alternative, highlighting their ability to represent data and relationships effectively. It explains graph theory concepts, including vertices, edges, and various types of graphs, as well as graph traversal methods and data structures like adjacency and incidence matrices. Additionally, it describes the property graph model and its components, emphasizing the importance of graph databases in scenarios where relationships between data objects are critical.

Uploaded by

Usama Riaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views46 pages

5 & 6 - Graph Database

The document discusses the weaknesses of Relational Database Management Systems (RDMS) and introduces graph databases as an alternative, highlighting their ability to represent data and relationships effectively. It explains graph theory concepts, including vertices, edges, and various types of graphs, as well as graph traversal methods and data structures like adjacency and incidence matrices. Additionally, it describes the property graph model and its components, emphasizing the importance of graph databases in scenarios where relationships between data objects are critical.

Uploaded by

Usama Riaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

No-SQL Databases

By Dr. Muhammad Ali Ismail


Weaknesses of RDMS
• Inadequate Representation of data

• Semantic Overloading

• Weak support for Recursion

• 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.

• Graphs structure data into a set of

– 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.

• An edge can be directed (with an arrow tip) or undirected.

– 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

• Traversal : finding certain nodes in a graph. It may FULL or PARTIAL

• The two simplest kinds of a full traversal are


– depth-First search: It follows the edge to the First adjacent node (in the given order) and then
proceeds towards the First adjacent node of 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.

– For edgeless graphs the matrix contains only 0s

– For edges in the graph matrix cells are filled with


1s
simple undirected graph
Directed Graph
Undirected Multigraph
Directed Multigraph
Incidence Matrix
• For cardinality |V| = n and |E| = m incidence
matrix is an n ×m matrix where rows
– denote vertices v1 . . . vn; and

– columns denote edges e1 . . . em.

– For edgeless graphs the matrix contains no


columns; as soon as edges are present, columns
are created and filled
Undirected Graph
Directed Graph
Undirected Multigraph
Directed Multigraph
Adjacency List

• Adjacency list stores the vertex set V and for


each vertex stores a linked list of neighboring
(that is, adjacent) vertices.
Undirected Graph
Directed Graph
Undirected Multigraph
Directed Multigraph
Incidence List
• In the incidence list, each edge has its
representation as an individual data object.
And this allows for storing additional
information on the edge in the edge object
Undirected Graph
Directed Graph
Undirected Multigraph
Directed Multigraph
The Property Graph Model

• A property graph is a labeled and attributed directed


multigraph with identifiers

• G = (V, E, LV , LE, ID)

• V is the set of nodes.


• E is the set of edges.
• LV is the set of node labels .
• LE is the set of edge labels
• The set ID is the set of identifiers that can uniquely be
assigned to nodes and edges.
• A specific node then has the following
elements: v = (id, l, P)
– Where and
– is a node label.
– P is a set of properties. each property is a
name:value-pair. And it is optional.
Example
specific nodes and edges
Storing Property Graphs in Relational
Tables : Example
Storing Property Graphs in Relational Tables
Storing Property Graphs in Relational Tables
Lets Explore

• Neo4j

You might also like