I have a category table
<code>create table sportsmen(
subfolders? would be
hunters
subfolders of hunters:
foxhunters
birdhunters
treehunters
deerstalkers</code>
a guru made a short (get out of here) comment ...:
"You're right about the normalization, as far as I can tell. I
think you'd get by with fewer columns in your table, however, if rather than
creating one column for each category (ie, foxhunder_id, hunter_id, etc),
you instead created one column and called it "function_id" or something like
that. Then you could "F123" for a foxhunter or "H123" for a hunter. "
So what would such a structure look like ...in a table....?
or is it a class....$f123="foxhunters"; .....in a config.php?
Russell Griechen
You could create a table called sportsmen which has 3 fields function_id, function_title, parent_function_id
So that records in your table would look like :-
function_id, function_title, parent_function_id
1, Sportsmen, 0
2, Hunters, 1
3, Fox Hunters, 2
4, Bird Hunters, 2
As you can see Fox Hunters will have the parent id of 2
which makes it a sub category of Hunters.
Using this table structure you can represent any depth of tree
structure as long as the parent id's point back to the higher lever
function.
This is a good way to normalise the data in a database.