SlideShare une entreprise Scribd logo
1  sur  49
NESTED DATA SETS
(THINK ACL)
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 1
INTRODUCTION
 Eli Aschkenasy
 themodularway.com
 Oracle certified (doesn’t really mean anything)
 GE sourcing database project
 Agenda
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 2
AGENDA
 Introduction (5min)
 Simple Explanation of Nested Data Sets (10min)
 Types of Hierarchies (5min)
 The Joomla Way (5min)
 Basic Functions (15min)
 Advanced Functions (10min)
 The Ten Commandments (for ever…)
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 3
WELCOME TO OUR DEMO TEAM (COURTESY OF MS POWERPOINT TEMPLATES)
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 4
NESTED SETS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 5
NESTED SETS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 5
1
2
3 4 5 6 7
8 9
1
0
1
1
1
2
1
3
1
4
1
5
1
8
1
9
1
7
1
6
2
0
21
22
lft, rgt
NESTED SETS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 5
CEO
VP
Financial Support Marketing Sales Developme
nt
Research
position
NESTED SETS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 5
NESTED SETS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 5
container
NESTED SETS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 5
container
NESTED SETS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 5
container
NESTED SETS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 5
container
AGENDA
 Introduction (5min)
 Simple Explanation of Nested Data Sets (10min)
 Types of Hierarchies (5min)
 The Joomla Way (5min)
 Basic Functions (15min)
 Advanced Functions (10min)
 The Ten Commandments (for ever…)
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 6
TYPES OF HIERARCHIES
Static nodes and static edges
 A chart of accounts in an accounting system will
probably not change much over time.
 This is probably best done with a hierarchical
encoding scheme rather than a table.
Static nodes and dynamic edges
 For example, an Internet Newsgroup message
board. Obviously you cannot add a node to a
tree without adding an edge, but the content of
the messages (nodes) never change once they
are posted; however, new replies can be posted
as subordinates to any existing message (edge).
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 7
TYPES OF HIERARCHIES
Dynamic nodes and static edges
 This is the classic organizational chart in which
the organization stays the same, but the people
holding the offices rotate frequently.
 This is assuming that your company does not
reorganize more often than its personnel turns
over.
Dynamic nodes and dynamic edges
 The fastest path from the fire station to a
particular home address will not necessarily be
the same route at 5:00 AM as it will be at 5:00
PM.
 Once the fire is put out, the node that
represented the burning house can disappear
from the tree and the next fire location becomes
a to which we must find a path.
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 8
TYPES OF HIERARCHIES
Dynamic nodes and static edges
 This is the classic organizational chart in which
the organization stays the same, but the people
holding the offices rotate frequently.
 This is assuming that your company does not
reorganize more often than its personnel turns
over.
Dynamic nodes and dynamic edges
 The fastest path from the fire station to a
particular home address will not necessarily be
the same route at 05:00 Hrs. as it will be at 17:00
Hrs.
 Once the fire is put out, the node that
represented the burning house can disappear
from the tree and the next fire location becomes
a to which we must find a path.
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 9
AGENDA
 Introduction (5min)
 Simple Explanation of Nested Data Sets (10min)
 Types of Hierarchies (5min)
 The Joomla Way (5min)
 Basic Functions (15min)
 Advanced Functions (10min)
 The Ten Commandments (for ever…)
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 10
THE JOOMLA WAY - JTableNested
 http://docs.joomla.org/Using_nested_sets
 Table creation (required fields)
CREATE TABLE IF NOT EXISTS `#__nestedsets` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`parent_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
`lft` int(11) NOT NULL DEFAULT '0',
`rgt` int(11) NOT NULL DEFAULT '0',
`level` int(10) UNSIGNED NOT NULL DEFAULT '0',
`title` varchar(255) NOT NULL,
`alias` varchar(255) NOT NULL DEFAULT '',
`access` tinyint(3) UNSIGNED NOT NULL DEFAULT '0',
`path` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `idx_left_right` (`lft`,`rgt`)
) DEFAULT CHARSET=utf8;
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 11
THE JOOMLA WAY - JTableNested
 http://docs.joomla.org/Using_nested_sets
 Creating Root Node
$sql = 'INSERT INTO ckm_profiles'
. ' SET parent_id = 0'
. ', lft = 0'
. ', rgt = 1'
. ', level = 0'
. ', title = '.$db->quote( 'root' )
. ', alias = '.$db->quote( 'root' )
. ', access = 1'
. ', path = '.$db->quote( '' )
;
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 12
THE JOOMLA WAY - JTableNested
 http://docs.joomla.org/Using_nested_sets
 Basic Functions: getRootId() and update data (just like JTable)
$rootId = $table->getRootId();
if ($rootId === false) {
$rootId = $table->addRoot();
}
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 13
$table->bind( $data_array );
$table->check();
$table->store();
THE JOOMLA WAY - JTableNested
 http://docs.joomla.org/Using_nested_sets
 Inserting Node
$table = JTable::getInstance( 'yourtable' );
$table->setLocation( $reference_id, 'first-child' );
$table->bind( $data_array );
$table->id = 0;
$table->check();
$table->store();
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 14
THE JOOMLA WAY - JTableNested
 http://docs.joomla.org/Using_nested_sets
 Basic Functions
$table->isLeaf $subtree = $table->getTree( $id ); $pathNodes = $table->getPath( $id ); $table->publish( $id,
$state, $userId )
$table->orderUp( $id ) $key = $this->_tbl_key; $reference_id = JRequest::getInt( 'reference' );
$this->$key = JRequest::getInt( 'id' ); $relation = 'last-child';
$delta = -2; $node_id = JRequest::getInt( 'id' );
$table->move( $delta ); $table->moveByReference( $reference_id, $relation, $node_id );
$table->delete( $node_id )
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 15
AGENDA
 Introduction (5min)
 Simple Explanation of Nested Data Sets (10min)
 Types of Hierarchies (5min)
 The Joomla Way (5min)
 Basic Functions (15min)
 Advanced Functions (10min)
 The Ten Commandments (for ever…)
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 16
NESTED SETS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 17
1
2
3 4 5 6 7
8 9
1
0
1
1
1
2
1
3
1
4
1
5
1
8
1
9
1
7
1
6
2
0
21
22
lft, rgt
BASIC FUNCTIONS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 18
1
2
3 4 5 6 7
8 9
1
0
1
1
1
2
1
3
1
4
1
5
1
8
1
9
1
7
1
6
2
0
21
22
Root Node
SELECT *
FROM Orgchart
WHERE lft = 1;
BASIC FUNCTIONS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 19
1
2
3 4 5 6 7
8 9
1
0
1
1
1
2
1
3
1
4
1
5
1
8
1
9
1
7
1
6
2
0
21
22
Leaf Node (PHP check in J)
SELECT *
FROM Orgchart
WHERE(rgt - lft) = 1;
BASIC FUNCTIONS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 19
1
2
3 4 5 6 7
8 9
1
0
1
1
1
2
1
3
1
4
1
5
1
8
1
9
1
7
1
6
2
0
21
22
Leaf Node (PHP check in J)
SELECT *
FROM Orgchart
WHERE(rgt - lft) = 1;
BASIC FUNCTIONS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 19
1
2
3 4 5 6 7
8 9
1
0
1
1
1
2
1
3
1
4
1
5
1
8
1
9
1
7
1
6
2
0
21
22
Leaf Node (PHP check in J)
SELECT *
FROM Orgchart
WHERE lft = (rgt-1);
BASIC FUNCTIONS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 19
1
2
3 4 5 6 7
8 9
1
0
1
1
1
2
1
3
1
4
1
5
1
8
1
9
1
7
1
6
2
0
21
22
Leaf Node (PHP check in J)
SELECT a, b, c
FROM Orgchart
WHERE lft = (rgt-1);
BASIC FUNCTIONS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 20
1
2
3 4 5 6 7
8 9
1
0
1
1
1
2
1
3
1
4
1
5
1
8
1
9
1
7
1
6
2
0
21
22
Total Nodes (not in
J)
BASIC FUNCTIONS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 20
1
2
3 4 5 6 7
8 9
1
0
1
1
1
2
1
3
1
4
1
5
1
8
1
9
1
7
1
6
2
0
21
22
Total Nodes (not in
J)
((rgt – lft)+1) / 2
BASIC FUNCTIONS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 21
1
2
3 4 5 6 7
8 9
1
0
1
1
1
2
1
3
1
4
1
5
1
8
1
9
1
7
1
6
2
0
21
22
Subordinates
SELECT Mgrs.name AS manager, Workers.name AS worker
FROM Orgchart AS Mgrs, Orgchart AS Workers
WHERE Workers.lft > Mgrs.lft AND Workers.lft < Mgrs.rgt;
BASIC FUNCTIONS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 22
1
2
3 4 5 6 7
8 9
1
0
1
1
1
2
1
3
1
4
1
5
1
8
1
9
1
7
1
6
2
0
21
22
Level of node (J has info in
row)
SELECT O2.name, COUNT(O1.name) AS level
FROM OrgChart AS O1, OrgChart AS O2
WHERE O2.lft BETWEEN O1.lft AND O1.rgt
GROUP BY O2.name;
BASIC FUNCTIONS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 23
1
2
3 4 5 6 7
8 9
1
0
1
1
1
2
1
3
1
4
1
5
1
8
1
9
1
7
1
6
2
0
21
22
Maximum Height of Tree
SELECT MAX( hlevel ) AS height
FROM (
SELECT 02.name, COUNT( O1.id ) -1 AS hlevel
FROM OrgChart AS O1, OrgChart AS O2
WHERE O2.lft BETWEEN O1.lft AND O1.rgt
GROUP BY O2.id
) AS L1
BASIC FUNCTIONS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 24
1
2
3 4 5 6 7
8 9
1
0
1
1
1
2
1
3
1
4
1
5
1
8
1
9
1
7
1
6
2
0
21
22
Age of Child Node
SELECT Workers.name
FROM OrgChart AS Mgrs, OrgChart AS Workers
WHERE Mgrs.lft = 2
AND Workers.lft = Mgrs.lft + 1;
AGENDA
 Introduction (5min)
 Simple Explanation of Nested Data Sets (10min)
 Types of Hierarchies (5min)
 The Joomla Way (5min)
 Basic Functions (15min)
 Advanced Functions (10min)
 The Ten Commandments (for ever…)
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 25
ADVANCED FUNCTIONS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 26
1
2
3 4 5 6 7
8 9
1
0
1
1
1
2
1
3
1
4
1
5
1
8
1
9
1
7
1
6
2
0
21
22
Path between Nodes (J is path to
root)
SELECT O2.name, (SELECT COUNT(*)
FROM OrgChart AS O4
WHERE O4.lft BETWEEN O1.lft AND O1.rgt
AND O2.lft BETWEEN O4.lft AND O4.rgt) AS path_nbr
FROM OrgChart AS O1, OrgChart AS O2, OrgChart AS O3
WHERE O1.lft = 2
AND O3.lft = 19
AND O2.lft BETWEEN O1.lft AND O1.rgt
AND O3.lft BETWEEN O2.lft AND O2.rgt;
ADVANCED FUNCTIONS
Children to Parent
 Mom dies and Grandma adopts the kids.
 In effect the position itself is removed.
 This is a vertical promotion of an entire subtree.
Child node to the deleted node’s
position
 Give the business to the oldest son.
 The problem is that when the son is promoted,
this leaves a vacancy in his former position.
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 27
Deleting Nodes (J is simple (?))
ADVANCED FUNCTIONS
Sibling moves over to the vacant
position
 Dad dies and his oldest brother takes over the
business.
 This assumes that there is such a brother to take
the vacant position.
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 28
Deleting Nodes (J is simple (?))
ADVANCED FUNCTIONS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - THEMODULARWAY 29
1
2
3 4 5 6 7
8 9
1
0
1
1
1
2
1
3
1
4
1
5
1
8
1
9
1
7
1
6
2
0
21
22
Deleting Nodes (J is simple (?))
// Delete the node and all of its children.
$query = $this->_db->getQuery(true);
$query->delete();
$query->from($this->_tbl);
$query->where('lft BETWEEN ' . (int) $node->lft . ' AND ' . (int) $node->rgt);
$this->_runQuery($query, 'JLIB_DATABASE_ERROR_DELETE_FAILED');
// Compress the left values.
$query = $this->_db->getQuery(true);
$query->update($this->_tbl);
$query->set('lft = lft - ' . (int) $node->width);
$query->where('lft > ' . (int) $node->rgt);
$this->_runQuery($query, 'JLIB_DATABASE_ERROR_DELETE_FAILED');
// Compress the right values.
$query = $this->_db->getQuery(true);
$query->update($this->_tbl);
$query->set('rgt = rgt - ' . (int) $node->width);
$query->where('rgt > ' . (int) $node->rgt);
$this->_runQuery($query, 'JLIB_DATABASE_ERROR_DELETE_FAILED');
ADVANCED FUNCTIONS
 Find width of subtree: (rgt-lft)+1
 Find offset of subtree: (old lft-new left)
 Store original lft
 Add width to lft and rgt where lft>=new left (creating gap)
 Change lft and rgt of subtree to lft-offset and rgt-offset where lft between cur_lft and cur_left+width
(filling gap)
 Subtract width from lft and rgt where lft>=new lft+width (connecting right)
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 30
Moving Subtrees (J is simple)
ADVANCED FUNCTIONS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 31
1
2
3 4 5 6 7
8 9
1
0
1
1
1
2
1
3
1
4
1
5
1
8
1
9
1
7
1
6
2
0
21
22
Moving Subtrees (J is simple)
ADVANCED FUNCTIONS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 31
1
2
3 4 5 6 7
8 9
1
0
1
1
1
2
1
3
1
4
1
5
1
8
1
9
1
7
1
6
2
0
21
22
Moving Subtrees (J is simple)
ADVANCED FUNCTIONS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 32
1
2
3 4 9
1
0
1
5
1
6
1
7
1
8
1
9
2
2
2
3
2
1
2
0
2
4
21
22
1
1
1
2
1
3
1
4
Moving Subtrees (J is simple)
width = (16-13)+1 = 4
orig_lft = 13
offset = (orig_lft-new_lft)+width = 12
ADVANCED FUNCTIONS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 33
1
2
3 4 5
1
0
1
5
1
6
2
2
2
3
2
1
2
4
21
22
1
1
1
2
1
3
1
4
6 7
89
Moving Subtrees (J is simple)
width = (16-13)+1 = 4
orig_lft = 13
offset = (orig_lft-new_lft)+width = 12
ADVANCED FUNCTIONS
Terry Earls
Charlotte
Weiss
Rob
Walters
Manuel
Oliveira
Dan
Wilson
Chen
Yang
Phyllis
Harris
Mark
Hanson
Maureen
Magnotta
Patricia
Doyle
Mike
Nash
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 34
1
2
3 4 5
1
0
1
5
1
6
1
8
1
9
1
7
2
0
21
22
1
1
1
2
1
3
1
4
6 7
89
Moving Subtrees (J is simple)
width = (16-13)+1 = 4
orig_lft = 13
offset = (orig_lft-new_lft)+width = 12
AGENDA
 Introduction (5min)
 Simple Explanation of Nested Data Sets (10min)
 Types of Hierarchies (5min)
 The Joomla Way (5min)
 Basic Functions (15min)
 Advanced Functions (10min)
 The Ten Commandments
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 35
TEN COMMANDMENTS
 I am not the Lord thy God, test on your own
 Thou shalt think if Nested Sets are what you
need
 Thou shalt utilize native Joomla! if adequate
 Thou must add index to rgt
 Honor thy table locks
 Thou shalt think about a-synch data
 Thou shalt separate entities from hierarchy
 Hierarchy Leafs are still categories (Thou shalt)
 Thou shalt allow entities belonging to many
nodes
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 36
JOOMLADAY NETHERLANDS 2013 - ELI ASCHKENASY - @ELIASCHKENASY 37
HET EINDE
ja, ik spreek vloeiend nederlands...

Contenu connexe

En vedette

Rise of Column Oriented Database
Rise of Column Oriented DatabaseRise of Column Oriented Database
Rise of Column Oriented DatabaseSuvradeep Rudra
 
Dremel: Interactive Analysis of Web-Scale Datasets
Dremel: Interactive Analysis of Web-Scale Datasets Dremel: Interactive Analysis of Web-Scale Datasets
Dremel: Interactive Analysis of Web-Scale Datasets robertlz
 
More Better Nested Set
More Better Nested SetMore Better Nested Set
More Better Nested Setxibbar
 
NoSQL? No, SQL! - SQL, the underestimated "Big Data" technology
NoSQL? No, SQL! - SQL, the underestimated "Big Data" technologyNoSQL? No, SQL! - SQL, the underestimated "Big Data" technology
NoSQL? No, SQL! - SQL, the underestimated "Big Data" technologyDataGeekery
 
Slides: NoSQL Data Modeling Using JSON Documents – A Practical Approach
Slides: NoSQL Data Modeling Using JSON Documents – A Practical ApproachSlides: NoSQL Data Modeling Using JSON Documents – A Practical Approach
Slides: NoSQL Data Modeling Using JSON Documents – A Practical ApproachDATAVERSITY
 
Big Data Platforms: An Overview
Big Data Platforms: An OverviewBig Data Platforms: An Overview
Big Data Platforms: An OverviewC. Scyphers
 

En vedette (9)

Rise of Column Oriented Database
Rise of Column Oriented DatabaseRise of Column Oriented Database
Rise of Column Oriented Database
 
Dremel: Interactive Analysis of Web-Scale Datasets
Dremel: Interactive Analysis of Web-Scale Datasets Dremel: Interactive Analysis of Web-Scale Datasets
Dremel: Interactive Analysis of Web-Scale Datasets
 
Google's Dremel
Google's DremelGoogle's Dremel
Google's Dremel
 
Trees and Hierarchies in SQL
Trees and Hierarchies in SQLTrees and Hierarchies in SQL
Trees and Hierarchies in SQL
 
More Better Nested Set
More Better Nested SetMore Better Nested Set
More Better Nested Set
 
NoSQL? No, SQL! - SQL, the underestimated "Big Data" technology
NoSQL? No, SQL! - SQL, the underestimated "Big Data" technologyNoSQL? No, SQL! - SQL, the underestimated "Big Data" technology
NoSQL? No, SQL! - SQL, the underestimated "Big Data" technology
 
Slides: NoSQL Data Modeling Using JSON Documents – A Practical Approach
Slides: NoSQL Data Modeling Using JSON Documents – A Practical ApproachSlides: NoSQL Data Modeling Using JSON Documents – A Practical Approach
Slides: NoSQL Data Modeling Using JSON Documents – A Practical Approach
 
Models for hierarchical data
Models for hierarchical dataModels for hierarchical data
Models for hierarchical data
 
Big Data Platforms: An Overview
Big Data Platforms: An OverviewBig Data Platforms: An Overview
Big Data Platforms: An Overview
 

Similaire à MySQL Nested Datasets #JDNL13

MySQL Performance Optimization #JDNL13
MySQL Performance Optimization #JDNL13MySQL Performance Optimization #JDNL13
MySQL Performance Optimization #JDNL13Eli Aschkenasy
 
When to NoSQL and when to know SQL
When to NoSQL and when to know SQLWhen to NoSQL and when to know SQL
When to NoSQL and when to know SQLSimon Elliston Ball
 
When to no sql and when to know sql javaone
When to no sql and when to know sql   javaoneWhen to no sql and when to know sql   javaone
When to no sql and when to know sql javaoneSimon Elliston Ball
 
Redis the better NoSQL
Redis the better NoSQLRedis the better NoSQL
Redis the better NoSQLOpenFest team
 
What You Missed in Computer Science
What You Missed in Computer ScienceWhat You Missed in Computer Science
What You Missed in Computer ScienceTaylor Lovett
 
SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)
SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)
SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)Mark Wilkinson
 
PHP Database Programming Basics -- Northeast PHP
PHP Database Programming Basics -- Northeast PHPPHP Database Programming Basics -- Northeast PHP
PHP Database Programming Basics -- Northeast PHPDave Stokes
 
Agile Data Science 2.0 - Big Data Science Meetup
Agile Data Science 2.0 - Big Data Science MeetupAgile Data Science 2.0 - Big Data Science Meetup
Agile Data Science 2.0 - Big Data Science MeetupRussell Jurney
 
Oracle Objects And Transactions
Oracle Objects And TransactionsOracle Objects And Transactions
Oracle Objects And Transactionstepsum
 
Agile Data Science 2.0
Agile Data Science 2.0Agile Data Science 2.0
Agile Data Science 2.0Russell Jurney
 
Agile Data Science 2.0
Agile Data Science 2.0Agile Data Science 2.0
Agile Data Science 2.0Russell Jurney
 
Rails, Postgres, Angular, and Bootstrap: The Power Stack
Rails, Postgres, Angular, and Bootstrap: The Power StackRails, Postgres, Angular, and Bootstrap: The Power Stack
Rails, Postgres, Angular, and Bootstrap: The Power StackDavid Copeland
 
PHP CLI: A Cinderella Story
PHP CLI: A Cinderella StoryPHP CLI: A Cinderella Story
PHP CLI: A Cinderella StoryMike Lively
 
Beyond shuffling global big data tech conference 2015 sj
Beyond shuffling   global big data tech conference 2015 sjBeyond shuffling   global big data tech conference 2015 sj
Beyond shuffling global big data tech conference 2015 sjHolden Karau
 
Drupal Development (Part 2)
Drupal Development (Part 2)Drupal Development (Part 2)
Drupal Development (Part 2)Jeff Eaton
 
Sql interview question part 12
Sql interview question part 12Sql interview question part 12
Sql interview question part 12kaashiv1
 
Sql interview question part 12
Sql interview question part 12Sql interview question part 12
Sql interview question part 12kaashiv1
 
Old Oracle Versions
Old Oracle VersionsOld Oracle Versions
Old Oracle VersionsJeffrey Kemp
 

Similaire à MySQL Nested Datasets #JDNL13 (20)

MySQL Performance Optimization #JDNL13
MySQL Performance Optimization #JDNL13MySQL Performance Optimization #JDNL13
MySQL Performance Optimization #JDNL13
 
When to NoSQL and when to know SQL
When to NoSQL and when to know SQLWhen to NoSQL and when to know SQL
When to NoSQL and when to know SQL
 
When to no sql and when to know sql javaone
When to no sql and when to know sql   javaoneWhen to no sql and when to know sql   javaone
When to no sql and when to know sql javaone
 
Redis the better NoSQL
Redis the better NoSQLRedis the better NoSQL
Redis the better NoSQL
 
What You Missed in Computer Science
What You Missed in Computer ScienceWhat You Missed in Computer Science
What You Missed in Computer Science
 
SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)
SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)
SADI in Perl - Protege Plugin Tutorial (fixed Aug 24, 2011)
 
PHP Database Programming Basics -- Northeast PHP
PHP Database Programming Basics -- Northeast PHPPHP Database Programming Basics -- Northeast PHP
PHP Database Programming Basics -- Northeast PHP
 
Agile Data Science 2.0 - Big Data Science Meetup
Agile Data Science 2.0 - Big Data Science MeetupAgile Data Science 2.0 - Big Data Science Meetup
Agile Data Science 2.0 - Big Data Science Meetup
 
Oracle Objects And Transactions
Oracle Objects And TransactionsOracle Objects And Transactions
Oracle Objects And Transactions
 
Agile Data Science 2.0
Agile Data Science 2.0Agile Data Science 2.0
Agile Data Science 2.0
 
Agile Data Science 2.0
Agile Data Science 2.0Agile Data Science 2.0
Agile Data Science 2.0
 
Rails, Postgres, Angular, and Bootstrap: The Power Stack
Rails, Postgres, Angular, and Bootstrap: The Power StackRails, Postgres, Angular, and Bootstrap: The Power Stack
Rails, Postgres, Angular, and Bootstrap: The Power Stack
 
PHP CLI: A Cinderella Story
PHP CLI: A Cinderella StoryPHP CLI: A Cinderella Story
PHP CLI: A Cinderella Story
 
Beyond shuffling global big data tech conference 2015 sj
Beyond shuffling   global big data tech conference 2015 sjBeyond shuffling   global big data tech conference 2015 sj
Beyond shuffling global big data tech conference 2015 sj
 
Drupal Development (Part 2)
Drupal Development (Part 2)Drupal Development (Part 2)
Drupal Development (Part 2)
 
Sql interview question part 12
Sql interview question part 12Sql interview question part 12
Sql interview question part 12
 
Ebook12
Ebook12Ebook12
Ebook12
 
Sql interview question part 12
Sql interview question part 12Sql interview question part 12
Sql interview question part 12
 
Old Oracle Versions
Old Oracle VersionsOld Oracle Versions
Old Oracle Versions
 
SQL -PHP Tutorial
SQL -PHP TutorialSQL -PHP Tutorial
SQL -PHP Tutorial
 

Dernier

%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile EnvironmentVictorSzoltysek
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 

Dernier (20)

%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 

MySQL Nested Datasets #JDNL13