Alex Rivera | Logout

How can I implement an "interesting tags" feature like that on Stack Overflow?

Asked 2010-05-26T16:51:41.890
30

Check my other question with bounty: Finding similar number patterns in table

I'm trying to implement an Interesting Tags feature. For reference, this is how it works on SO:

  1. I add into the "interesting" list my interested tags (like php, mysql, jquery and so on).
  2. Then, if any of the displayed questions has some of the tags in my list, it makes the background orange.

I understand how to use jQuery to do that (there are related questions on that), but can't figure out how to implement the back-end portion using MySQL!

So here's my question: How is it done? I imagine it working like this:

  • There is a row in mysql for every member, let's call it "interested_tags".
  • After I write and submit my tag through input, it is being written in a row "interested_tags".
  • Then, the main page has a query which shows all answers and it always checks question's tags with mine tags using strpos like this:

    if(strpos($question_tags, $my_tags) === true) {
       //and here will be made background orange
    }
    

Am I thinking right or is there any way to do it?

EDIT: So, can you show me an example or give me some tips how to implement this with many-to-many relationships? Thanks.

Edit
Report

3 Answers

7

There is a row in mysql for every member, let's call it "interested_tags".

More likely, there is an additional table that represents a many-to-many relationship between users and tags. With another table that associates tags with questions.

Then you'd just need a query (or more likely a stored procedure) that compares a user's tags to a question's tags and returns a boolean true or false.

answered 2010-05-26T17:16:47.797
2

@new question: http://skmzq.qiniucdn.com/data/20060423142114/index.html contains an (old but useful) comparison of different kinds of taggning. Don't forget to read the comments, they're very useful.

answered 2010-08-13T13:00:25.117
1

From the way the pages are rendering, I have guessed that the tag comparison is being done in JavaScript. So the steps would be:

  • query for the users interesting tags
  • make results available to client-side JS
  • JS iterates over each question and changes an attribute based on a match (includes removing the post if it matches an 'ignored' tag.
answered 2010-05-26T17:24:51.717

Your Answer