Best way to organize a list of tags and their hierarchy in a database of some sort? (More details & examples inside)
October 24, 2011 1:16 PM Subscribe
Best way to organize a list of tags and their hierarchy in a database of some sort? (More details & examples inside)
I'm working on a project that is focused on tagging images and things (don't worry too much about this). Essentially I want to be able to save my list of tags so that at some point I can use it in conjunction with a MYSQL database. However! I don't know how to program, so right now everything is just in a text file. But I'd like to not have to retype everything down the line, so is there some sort of tagging program (or is there a simple way I could make a database with the right parameters)?
Essentially, it could boil down to something like this:
Level 1: Type
Level 2: Detailed Type
Level 3: Very Detailed Type
For example:
1: Tomato
2: Red
3: Heirloom
or
1: Lamborghini
2: Gallardo
3: Superleggera
There may even be a fourth level for some items.
Eventually, I want people to be able to enter this information from dropdown menus that are already populated with the tags that I'm currently writing in a text file. For all I know, using excel and various levels of columns is what I need to do, but maybe there is a better answer.
posted by darkgroove to computers & internet (5 answers total) 2 users marked this as a favorite
The data you want to store is hierarchical which makes a relational database (like mysql) not ideal for it, which isn't to say it can't be done that way.
In MySQL you could do it in a single table with three columns labelled "tagIDNumber", "tagName" and "parentTagIDNumber"
Your top level tags are retrieved with (I forget exact SQL syntax for this):
select tagIDNumber, tagName from tagTable where parentTagIDNumber == NULL
Then for each successive level down the tree, you do:
select tagIDNumber, tagName from tagTable where parentTagIDNumber == (tagIDNumber that you just looked up in the previous level.)
Alternatively, using a hierarchical model you just do:
Object { Car { Lamborghini { Gallardo { Superleggera {} } } } Tomato { Red { Heirloom (which aren't all red, BTW) {} } } }And at each level you create a dropdown menu showing all the items visible at that level of the tree.posted by tylerkaraszewski at 2:27 PM on October 24, 2011