in reply to Re: perl create database with folder system (Tree in SQL)
in thread perl create database with folder system

It's a good idea to use the pre-order indices as ids; if you also store the maximal descendant id for each node (easily generated in pre-order by using the node's id for leaves, and using the last assigned id for non-leaves) you can easily check for descendants: A is B's descendant iff B.id <= A.id <= B.mdi.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^3: perl create database with folder system (Tree in SQL) (edit)
by LanX (Saint) on Dec 02, 2017 at 15:36 UTC
    I think imposing order into numerical ° IDs works only for static structures.

    If the max depth is fixed I can easily create a performant view where each column represents a level.

    SQL views on self joins are even updatetable in mysql.

    edit

    Of course there are attempts to use a path like strings as ID, ie 0_1 would be a parent of 0_1_15 , but this becomes a can of worms if you need to move branches ...

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Wikisyntax for the Monastery

    °) integers to be more precise