I would like a bit more clarification on the toxi method of storing tags in a database – mentioned elsewhere on SO.
The database schema is:
Table: Item
Columns: ItemID, Title, Content
Table: Tag
Columns: TagID, Title
Table: ItemTag
Columns: ItemID, TagID
This is probably a stupid question (but I don't know the answer)... Should each entry, in the Table Tag, have a unique title. i.e. I only store a tag once or store it every time I use it?
To illustrate, which of the two tables below should I end up with:
TagID Title
1 Fish
2 Cat
3 Dog
or
TagID Title
1 Fish
2 Fish
3 Cat
4 Fish
5 Dog
6 Cat
If using the first table, before entering the tag I would first have to run and sql statement to find out if it exists, correct?
Any help will be appreciated. I had my fingers burn recently due to hacking together and indexing, want to start getting the basics correct.