Tagging in MySQL
Published April 26th, 2005 in PHP, FeedmarkerPhillip Keller has a nice summary of a few database schemas for a tag-enabled application.
Basically, it comes down to normalized or not. I think you’re much better off normalizing to 3NF (a table for your records, a table for your tags, and a lookup table to tie them together). Here’s Feedmarker’s schema (the part in question):
TABLE tags (
id,
tag_name
);
TABLE sources (
id,
source_user_id,
source_title,
...other attributes …
);
TABLE source_tags (
source_id,
tag_id
);
The big difference for me, though, is that I’m using PostgreSql, not MySQL. I’m really not the most qualified person to get into the whole debate between these two. But I started out with Feedmarker in MySQL and switched, because some of the PostgreSql features are just too convenient to pass up. I’m thinking of views, sub-queries, unions and intersection.
In case you’re making the decision, here ’s an article that will help get you started.
While we’re on databases, Cal Henderson has a nice tutorial on searching in MySQL with PHP.
And lastly, but not leastly, Gimpu is a new social bookmarks manager I found running on Ruby on Rails. Seems like everybody is looking at Ruby, so it’s nice to see a bookmarker implemented in Rails so fast. If I didn’t have 6 months of labor sunk into PHP/PostgreSql, I’d seriously consider switching Feedmarker over.<—a842b8838a5206e5095dfbaf6f464be7—>
<—cd03c7dff5c4c4524ac6627fc70aa1ec—>
9 Responses to “Tagging in MySQL”
Please Wait
Leave a Reply