CREATE TABLE `#departments` (
`id_depart` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`id_parent` INT(10) UNSIGNED DEFAULT NULL,
PRIMARY KEY (`id_depart`)
) ENGINE=INNODB
CREATE TABLE `departments_graph` (
latch VARCHAR(32) NULL,
origid BIGINT UNSIGNED NULL,
destid BIGINT UNSIGNED NULL,
weight DOUBLE NULL,
seq BIGINT UNSIGNED NULL,
linkid BIGINT UNSIGNED NULL,
KEY (latch, origid, destid) USING HASH,
KEY (latch, destid, origid) USING HASH
)
ENGINE=OQGRAPH
data_table='#departments' origid='id_parent' destid='id_depart'
SELECT * FROM `departments_graph` WHERE latch='breadth_first' AND origid=1 AND destid=2;