[Dbix-class] Representing directory structures

Len Jaffe lenjaffe at jaffesystems.com
Sun Apr 7 19:40:18 GMT 2013


In my opinion, the best way to model a tree in an RDBMS is to use
Materialized Path.

I found the amount of work involved in each insert/delete of a nested set
to be too great, and adjacency lists (parent pointer) fails to allow for
retrieving all of a tree or subtree with one round-trip to the db.
 Materialized Path does not suffer these drawbacks.

I recall there being a couple of MP modules available for DBI and DBIC.

Len.


On Sun, Apr 7, 2013 at 2:42 PM, Bill Moseley <moseley at hank.org> wrote:

> Anyone using DBIC to represent hierarchal directory (folder) structures?
>
> Essentially just like a file system, except users each have their own
> root.  To add to the complexity, I need to be able to "share" folders and
> all child elements to other users.
>
> My assumption is this would involve a single table where each row can
> represent either a directory entry (e.g. a "file") or a sub-directory that
> references its parent.
>
> Postgresql has "WITH RECURSIVE" which DBIC has no support for (other than
> virtual views):
>
> http://www.postgresql.org/docs/9.2/static/queries-with.html
>
>
> But, Adjacency Lists and Nested Sets are (were?) often discussed as
> solutions for hierarchal data in the database.  I asked on the Pg list ba=
ck
> in 2007:
>
>
> http://postgresql.1045698.n5.nabble.com/Adjacency-List-or-Nested-Sets-to-=
model-file-system-hierarchy-td1876116.html
>
>
> but, so far, I've happily avoided using these approaches of representing
> hierarchal data in the database.
>
>
> BTW -- I have recently written a "tag"-based system (like the familiar
> gmail) which is easy to represent in a highly normalized schema but is a
> fundamentally different approach.
>
>
> --
> Bill Moseley
> moseley at hank.org
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
>



-- =

lenjaffe at jaffesystems.com   614-404-4214   www.lenjaffe.com
Proprietor: http://www.theycomewithcheese.com/ - An Homage to Fromage
Perl Advent Planet <http://www.lenjaffe.com/PerlAdventPlanet/> - Advent
Calendars: Perlish and otherwise.
Greenbar <http://www.greenbartraining.org/>: Grubmaster: 2012-2009, Grub
Asst: 2008, Trained: 2007.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20130407/76f=
b3036/attachment-0001.htm


More information about the DBIx-Class mailing list