Thank you all for your replies, they offered me some really good points to start digging on. I haven't posted my actual database structure in my first note on this topic so here it is:

-- 'attrs' keeps the attributes list in CSV form CREATE TABLE categories ( id INT UNSIGNED NOT NULL UNIQUE AUTO_INCREMENT, name CHAR(255) NOT NULL UNIQUE DEFAULT '', parent INT UNSIGNED NOT NULL DEFAULT '', attrs CHAR(255) NOT NULL DEFAULT '', time TIMESTAMP, PRIMARY KEY(id), KEY(name(16)), KEY(parent) ); -- _[id] is the id of the category as existent in 'categories' table CREATE TABLE cat_[id] ( id INT UNSIGNED NOT NULL UNIQUE AUTO_INCREMENT, name CHAR(255) NOT NULL UNIQUE DEFAULT '', time TIMESTAMP, ... attribute ... attribute ... attribute PRIMARY KEY(id), KEY(name(16)) ); -- bloat table to speed up common search patterns CREATE TABLE items_all ( id INT UNSIGNED NOT NULL UNIQUE AUTO_INCREMENT, name CHAR(255) NOT NULL DEFAULT '', category CHAR(255) NOT NULL DEFAULT '', cat_id INT UNSIGNED NOT NULL, PRIMARY KEY(id), KEY(name(16)), KEY(category(16)), KEY(cat_id), );
As you see, it's quite a clean/lame implementation of the second variant, as stated in my previous post. footpad suggested a 'fields/attributes' table instead of my 'attrs' column in the categories table. It should be an improvement for a large number of attributes, but I'm thinking there will be no such category with more than let's say 20 attributes for each category.
Normalization is a good thing, not that I was not thinking about it, but the problem at the first (the second too :) glance is that it can't be no normalization as I want to keep the bazaar feature ;-) meaning that this system should be able to store people as well as books, tools, flavours, images or anything else disregarding any resemblance between categories. In fact the only relation that I'm thinking to enhance somehow is the one of father-child category: as many of you have noted, there could be many overlapping attributes in some cases (humans-:grown-ups-:artists) so maybe there some normalization should be considered. Heh, some OOP techniques would be better in these cases as inheritance. Even more, polimorphism would be needed if i.e. would like to move around items from one category to another (i.e. 'musicians' from 'humans/grownups/artists/' in 'music/') :)
Heh, it will get so complex that I think that KISS should come up.For speed up purposes there may be used additional redundant databases containing specialized table in various things etc (as my all_items table).
I have already used Swish and maybe I will use it for this project too. Cascade, never heard of, I'll give it a try.
tnx.

--
AltBlue.


In reply to Re: database design by AltBlue
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.