![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
hi, ia m doing project like multi level marketing, i have to store the values in binary tree fromat, how to store the string values in binarytree format in database, send me the qureys, i used this CREATE TABLE NestedSet ( node CHAR(1) NOT NULL PRIMARY KEY, lf INT NOT NULL, rg INT NOT NULL); CREATE TABLE AdjacencyList ( node CHAR(1) NOT NULL PRIMARY KEY, parent CHAR(1) NULL); INSERT INTO AdjacencyList SELECT A.node,B.node AS parent FROM NestedSet AS A,NestedSet AS B where B.lf = (SELECT MAX(C.lf) FROM NestedSet C WHERE A.lf > C.lf AND A.lf < C.rg) |
#3
| |||
| |||
|
|
hi, ia m doing project like multi level marketing, i have to store the values in binary tree fromat, how to store the string values in binarytree format in database, send me the qureys, i used this CREATE TABLE NestedSet ( node CHAR(1) NOT NULL PRIMARY KEY, lf INT NOT NULL, rg INT NOT NULL); CREATE TABLE AdjacencyList ( node CHAR(1) NOT NULL PRIMARY KEY, parent CHAR(1) NULL); INSERT INTO AdjacencyList SELECT A.node,B.node AS parent FROM NestedSet AS A,NestedSet AS B where B.lf = (SELECT MAX(C.lf) FROM NestedSet C WHERE A.lf > C.lf AND A.lf < C.rg) |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
Kashi, could it be that you mix up things? Nested sets, Adjacency and binary trees are different ways to represent trees. You may have a look at Joe Celko's book "Trees and hierarchies in SQL" which gives you the details about all this. Also "send me the query". brgds Philipp Post |
|
NULL, rg INT NOT NULL); CREATE TABLE AdjacencyList ( node CHAR(1) NOT NULL PRIMARY KEY, parent CHAR(1) NULL); INSERT INTO AdjacencyList SELECT A.node,B.node AS parent FROM NestedSet AS A,NestedSet AS B where B.lf = (SELECT MAX(C.lf) FROM NestedSet C WHERE A.lf > C.lf AND A.lf < C.rg) |
#6
| |||
| |||
|
|
On Feb 2, 3:49 am, kashi <vishwa.bhyra... (AT) gmail (DOT) com> wrote: hi, ia m doing project like multi level marketing, i have to store the values in binary tree fromat, how to store the string values in binarytree format in database, send me the qureys, i used this CREATE TABLE NestedSet ( node CHAR(1) NOT NULL PRIMARY KEY, lf INT NOT NULL, rg INT NOT NULL); CREATE TABLE AdjacencyList ( node CHAR(1) NOT NULL PRIMARY KEY, parent CHAR(1) NULL); INSERT INTO AdjacencyList SELECT A.node,B.node AS parent FROM NestedSet AS A,NestedSet AS B where B.lf = (SELECT MAX(C.lf) FROM NestedSet C WHERE A.lf > C.lf AND A.lf < C.rg) For starters, CHAR(1) holds very short strings. Usually in a binary tree, each node's Left and Right (lf & rg?) links contain values that identify the child nodes. IOW, they contain values of the same type as the primary key. You never populated nestedset, so I have no clue if the INSERT is right or wrong. Ed |
#7
| |||
| |||
|
|
On Feb 2, 6:29 pm, Ed Prochak <edproc... (AT) gmail (DOT) com> wrote: On Feb 2, 3:49 am, kashi <vishwa.bhyra... (AT) gmail (DOT) com> wrote: hi, ia m doing project like multi level marketing, i have to store the values in binary tree fromat, how to store the string values in binarytree format in database, send me the qureys, i used this CREATE TABLE NestedSet ( node CHAR(1) NOT NULL PRIMARY KEY, lf INT NOT NULL, rg INT NOT NULL); CREATE TABLE AdjacencyList ( node CHAR(1) NOT NULL PRIMARY KEY, parent CHAR(1) NULL); INSERT INTO AdjacencyList SELECT A.node,B.node AS parent FROM NestedSet AS A,NestedSet AS B where B.lf = (SELECT MAX(C.lf) FROM NestedSet C WHERE A.lf > C.lf AND A.lf < C.rg) For starters, CHAR(1) holds very short strings. Usually in a binary tree, each node's Left and Right (lf & rg?) links contain values that identify the child nodes. IOW, they contain values of the same type as the primary key. You never populated nestedset, so I have no clue if the INSERT is right or wrong. * Ed can u send me the query how to store the string values in database,i doing multilevel marketing project , in that i am stroeing the values in binary format. |
#8
| |||
| |||
|
|
can u send me the query how to store the string values in database,i doing multilevel marketing project , in that i am stroeing the values in binary format. |
![]() |
| Thread Tools | |
| Display Modes | |
| |