Hierarchical/tree database for directories path in filesystem

Viewed 17959

I want to store the directories (present on the disk) into a database, maintaining their hierarchical/tree structure.

Here's a figure:

                         (ROOT)
                       /        \ 
                    Dir2        Dir3
                   /    \           \
                 Dir4   Dir5        Dir6
                 /          
               Dir7

I am using the SQLite database.

Please suggest me:

  1. the SQL query to store above structure in SQLite database, and

  2. a query to retrieve full path of the directory when I select one.

    i.e. suppose I select Dir7 then I should get the full path like ROOT/Dir2/Dir4/Dir7

3 Answers
Related