The best database structure ...

From: Webmaster Sphere-Project <webmaster_at_sphere.difware.com>
Date: 2000/07/17
Message-ID: <397351BA.14EB5D8A_at_sphere.difware.com>#1/1


Hello !
I wanna make a table where each entry are organize like in a hard-drive : with directories and sub-directories (without limitation on the number

of level). Now, I'm looking for the best table/database structure for those kind of services. Any ideas ?

Here mine, I'm not sure if that's the best, so please all critics are welcome :

Make a table called PATHS as following :

    ID The directory's ID (computer always prefer numeric to string !)

    NAME The name of the directory     PARENT The parent's ID

Then each entry of my table (let's call it TABLE ..*g*) content the ID of its path.

For getting all entry in a directory A : filters all entry TABLE where ID=A
For get all sub-directories of A : filters all entry of PATHS where PARENT=A
For get the canonical name of A (in pseudo-code) : Here, don't sounds efficient at all .. no ?

    do {
    CURRENT=PARENT
    FULLNAME=NAME+'\'+FULLNAME
    while (PARENT!=0)
etc..etc...

What all of ya guys are thinking about that ? Is that the best structure ? If anyone knows better, let me know it ...

Thank in advance...

DELABRE Ludovic Received on Mon Jul 17 2000 - 00:00:00 CEST

Original text of this message