StupidRalph
02-16-2008, 02:03 PM
I have a third party 'database' (I use that term very loosely when referring to this dataset of text files).
I was examining the a table for categories and noticed they have it set up with the parents, (children, grandchildren if applicable) all in the same column separated by a colon (:). I checked their sample site and I noticed in their webapp they just refer to the category simply as one long string with the whole family i.e. ("Animal:Birds:Birds of Prey" is a single category) .
Example
id,category
"0","Parent1"
"1","Parent2"
"2","Parent2:Child1"
"3","Parent2:Child1:Grandchild1"
"4","Parent2:Child1:Grandchild2"
"5","Parent2:Child1:Grandchild3"
"6","Parent2:Child1:Grandchild4"
"7","Parent3"
"8","Parent3:Child1"
"9","Parent3:Child2"
"10","Parent3:Child2:Grandchild1"
"11","Parent3:Child2:Grandchild2"
"12","Parent3:Child3"
"13","Parent3:Child4"
"14","Parent3:Child4:Grandchild1"
"15","Parent3:Child4:Grandchild2"
Sample:
id,category
"1","Animals"
"2","Animals:Amphibians"
"3","Animals:Antique"
"4","Animals:Birds:Birds Of Prey"
"5","Animals:Birds:Game Birds"
"6","Animals:Birds:North American"
"7","Animals:Birds:Tropical"
"8","Animals:Birds:Waterfowl"
"9","Animals:Birds"
"10","Animals:Cats"
"11","Animals:Dogs"
"12","Animals:Farm"
"13","Animals:Fish/Marine Life"
"14","Animals:Fish/Marine Life:Shells"
"15","Animals:Horses"
"16","Animals:Insects"
"17","Animals:Insects:Butterflies"
"18","Animals:Other Pets"
"19","Animals:Reptiles"
"20","Animals:Wildlife"
"21","Animals:Wildlife:Forest"
"22","Animals:Wildlife:Jungle"
My question is should I just leave it as is, or should I set it up to better handle parent/child relationships. I could set it up similar to how I'm handling resources in my access control lists.
+--------------------+--------------------+-----------+
| id | parent_id | privilege |
+--------------------+--------------------+-----------+
| site | NULL | |
| index | site | |
| login | site | |
| logout | site | |
| PhoneBook | site | |
| Printer | site | |
| profile | site | |
| svn | site | checkout |
| svn | site | commit |
| svn | site | update |
| TextWritingProggie | site | |
| LaTeX | TextWritingProggie | |
| OOfficeWriter | TextWritingProggie | |
+--------------------+--------------------+-----------+
I was examining the a table for categories and noticed they have it set up with the parents, (children, grandchildren if applicable) all in the same column separated by a colon (:). I checked their sample site and I noticed in their webapp they just refer to the category simply as one long string with the whole family i.e. ("Animal:Birds:Birds of Prey" is a single category) .
Example
id,category
"0","Parent1"
"1","Parent2"
"2","Parent2:Child1"
"3","Parent2:Child1:Grandchild1"
"4","Parent2:Child1:Grandchild2"
"5","Parent2:Child1:Grandchild3"
"6","Parent2:Child1:Grandchild4"
"7","Parent3"
"8","Parent3:Child1"
"9","Parent3:Child2"
"10","Parent3:Child2:Grandchild1"
"11","Parent3:Child2:Grandchild2"
"12","Parent3:Child3"
"13","Parent3:Child4"
"14","Parent3:Child4:Grandchild1"
"15","Parent3:Child4:Grandchild2"
Sample:
id,category
"1","Animals"
"2","Animals:Amphibians"
"3","Animals:Antique"
"4","Animals:Birds:Birds Of Prey"
"5","Animals:Birds:Game Birds"
"6","Animals:Birds:North American"
"7","Animals:Birds:Tropical"
"8","Animals:Birds:Waterfowl"
"9","Animals:Birds"
"10","Animals:Cats"
"11","Animals:Dogs"
"12","Animals:Farm"
"13","Animals:Fish/Marine Life"
"14","Animals:Fish/Marine Life:Shells"
"15","Animals:Horses"
"16","Animals:Insects"
"17","Animals:Insects:Butterflies"
"18","Animals:Other Pets"
"19","Animals:Reptiles"
"20","Animals:Wildlife"
"21","Animals:Wildlife:Forest"
"22","Animals:Wildlife:Jungle"
My question is should I just leave it as is, or should I set it up to better handle parent/child relationships. I could set it up similar to how I'm handling resources in my access control lists.
+--------------------+--------------------+-----------+
| id | parent_id | privilege |
+--------------------+--------------------+-----------+
| site | NULL | |
| index | site | |
| login | site | |
| logout | site | |
| PhoneBook | site | |
| Printer | site | |
| profile | site | |
| svn | site | checkout |
| svn | site | commit |
| svn | site | update |
| TextWritingProggie | site | |
| LaTeX | TextWritingProggie | |
| OOfficeWriter | TextWritingProggie | |
+--------------------+--------------------+-----------+