I’m kind of breaking my head over a Toxi solution for tag database schemas. I am working on a system where users can post items, and these items can have tags associated with them. After reading on tags, I found the Toxi solution most suitable for my needs. However, I'm not quite sure if I plan it right, so I would like you to speak out about this.
I will have three databases.
itemscontaining item_idothers
tagmap, using item_idand tag_idas foreign keys,
tagscontaining tag_idandtag_text
When adding a new item, can I assume that the process of adding tags to the database is as follows:
- sort submitted tags into an array
- for each tag in the array:
- get tag_id from tags, where tag_text matches the current tag
- if it returns 0 rows:
- add tag to table tags
- get tag_id
- add item_id and tag_id to tagmap
- complete (give user a-okay, etc.)
This means that we get an entry in the tagmap for each tag for each element. This seems right, but I can't help but think that there is a better way to do this than with a huge amount of entries there ...
Regarding tag editing, I came up with the following process, although I think there is a better way that I haven't found yet.
- retrieve tags using item_id and paste into user editable field
- makes changes. on submit:
- delete lines from tagmap, where item_id corresponds to edited
- same process as above
. , - , , ?
, : tagmap , , , ?
, , , , , . , cron tag_id tagmap , tag_use . , ?
, . Welp, , , , , , , .
, , .
!