Just a wild thought: why would one like/need to have so many different tables (one for each level)? I would rather have one table which in each record would hold its own ID, its level number (say: section = 1; department = 2; ...), its name and the ID-number of its parent (and any other info you need to store for this entity.

Traversing such a structure or selecting would be rather simple with the help of some well chosen SQL-queries:
SELECT name FROM organization WHERE level = 3 and parent = 10
would give you all level 3 entities which are overseen by entity 10.

Finding out how deep your organization is, is as simple as finding the maximum of the level numbers.

You could store meta-data about the levels (not the individual entities) in a separate table, the ID of which is of course the level number, ... etc. etc.

No need to access the meta-data of the database and you can implement it in any type of database and use DBI::DBD in a portable way.

Of course if the structure of your organization is much more complex, you can always try to catch it in an XML-structure, which is more flexible but more difficult to use.

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law


In reply to Re: How to display all the content of the database? by CountZero
in thread How to display all the content of the database? by Alex the Serb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.