Please enable JavaScript.
Coggle requires JavaScript to display documents.
Design Patterns of Data Bases - Coggle Diagram
Design Patterns of Data Bases
Graph, Trees and Hierarchies Overview
Graph theory is a branch of mathematics
deals with abstract structures
graph
diagram of "dots" and "lines" that model some kind of "flow" or relationship
edges("lines") can be undirected or directed
directed graph allows a "flow" along the edges in one direction only
undirected graph allows the flow to travel in both directions
edge must join two(and only two nodes)
Trees
special case of graphs
are graphs that have the following properties
Tree is a connected graph that has no cycles
Every node is the root of a subtree
Every two nodes in the tree are connected on one path
Tree is a connected graph that has one less edge than it has nodes
Hierarchy
special case of trees
is a directed tree with extra properties
subordination
inheritance
is the most important property of a hierarchy
This property does not exist in an ordinary tree
if :red_cross: an edge in a tree, we have 2 separate trees
is a common way to organize a great many things
have roles that are filled by entities
This role property does not exist in a tree
each node appears once in a tree and is unique.
Adjacency List Model
nodes contain the data
we can add columns to represent the edges of the tree
in the single-table representation of hierarchies
in SQL, there has to be one column for the identifier of the node and one column of the same data type for the parent of the node.
Nested Sets Model
Another way of representing trees is to show them
as nested sets
SQL is a set-oriented language
nested sets is a better model for trees and hierarchies.
Materializes Path
method for representing hierarchies in SQL stores the path from the root to each node as a string at that node