FLATLINE wrote:
Every category has: cat_id - Unique autonumber of each category cat_parent - The cat_id of the parent category cat_name - The display name of the category
-
Animals
-
Facilities
-
Houses
-
Apartment
-
2-3 Floors
-
4-12 Floors
-
12+ Floors
-
Private
-
Factories
-
Other
|
I've been working on a similar problem for a couple weeks off and on. However, I'm still fiddling around with how I want to model my data...
What I want to do is create a category system where subsets can be supersets of supersets.
From your example (sort of), Facilities could be a subcategory of Factories.
Another example would be:
-
Animals
-
Facilities
-
Houses
-
Apartment
-
2-3 Floors
-
4-12 Floors
-
12+ Floors
-
Private
-
Subsidized Housing
-
Tenants
-
People
-
Drug Addicts
-
Crack Whores
-
Cartman's Mother
-
Politicians
-
Animals
-
Dogs
-
Cockroaches
-
Factories
-
Other
-
Government
-
Corruption
-
Ministry of Lying
-
Ministry of Cheating
There is a reason to my madness, as I've clearly illustrated. e.g. Clearly, you will find Filth within the Ministry of Justice, but also where you find Filth, you are also likely to find Government.
Inside of the concept of "Cockroach" you will find the idea "Filth". Inside of the concept "Filth" you will find the concept "Government". Inside of "Government", you will find "Politicians", and all Politicians are Cockroaches.
How to model that though... I've pretty much settled on a second table to handle the "joins". I'm still fiddling though because something doesn't quite smell right and I can't test it without thousands of entries and extensive testing.
For the display, I'll probably go for some kind of DHTML expanding menu and not a select. But I will at some point need them.
For that, you may want to consider using a "null" character like '-' or '.' or '>'. Selects can be fussy with how they display things.
Find out how many "deep" each record is, then write that many "null" characters.
However, that is a pretty bad idea for a select unless you have a small number of records and they don't go too deep. I'd reconsider how you want to display things. DHTML may be the answer. SoThink has a good editor for that. Just Google "Sothink".
I know for my problem, I will face an infinite number of records "deep" because I can always go Cockroaches --> Filth --> Government --> Cockroaches --> Filth --> Government --> Cockroaches --> Filth --> Government --> Cockroaches --> Filth --> Government, etc.
That's another problem though. I'm pretty sure I have