>z> i wonder is there RECURSIVE select function in sqlite? the background >z> for the question are: create table objects (id INTEGER PRIMARY KEY >z> AUTOINCREMENT, name text unique) create table tree(id int, child_id >z> int, PRIMARY KEY(id, child_id)) i want to draw the whole tree, is >there >z> good solution for the function? > >If you want to store a tree structure in relational tables, then you >could >read up on things like this: > >http://articles.sitepoint.com/article/hierarchical-data-database > >The model on the second page is the one to go for.
Just adding a note to this good advice: depending on your application current and future needs, you may find it useful to store a "level" column, with for instance, 0 being the root, 1 the first level branches or leaves, aso. If ever you have usage for it, it will simplify many queries a great lot while eating only little space. As an example, you can then build a hierarchical SQL view of the tree or subtree, displaying it exactly as the display_tree() PHP function shown on this page, all with simple SQL. _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

