It doesn't feel like you need a tree structure at all. Maybe I am missing something...

If you really do need a tree then Joe Celko probably has what you need. (skip the travelogue at the start)

table: Categories: category_desc | catID table: Items: item_desc | itemID | catID table: Attributes attribute_desc | AttributID | itemID SELECT category_desc, item_desc, attribute_desc FROM Categories, Items, Attributes WHERE Categories.catID = Items.catID AND Items.itemID = Attributes.itemID;
This scheme has many advantages over the "multiple tables" solution. A couple are:
  1. You won't have to add a table every time you add a category.

  2. With cascading deletes, you don't have delete tables when you delete a category.

This scheme has many advantages over the "one big table" solution. Three are:
  1. You won't have to add/delete columns if you add/delete attributes
  2. In a normalized table structure you have a lot more flexibility with the queries.

  3. if you change a description you will do it in only one place

This scheme has no disadvantages over the two you have been considering. If performance is an issue. (and it is unlikely that it is) You are better off exploring caching of one sort or another.

Apart from being off topic, you might do better by asking database questions on a database forum. The monks are a nice bunch, but not every problem is a nail.



email: mandog


In reply to Re: (2) database design by mandog
in thread database design issue: one big table vs hundred of smaller tables by AltBlue

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.