views:

34

answers:

1

Basically this is a database and query question. How do you implement related post in your site, suppose you have this table:

+------+        +------+
+ Post +        + Tags  +
-------- N : M  --------

where post have the body and link m:n to tag. This is a very common scenario of implement tag and post.

so, How do you implement related post in your site?

+2  A: 

Find all the posts which overlap on at least one tag and use term frequency - inverse document frequency to weight the tags by importance, and sum the weights. Return related posts in descending order of total weight.

Mark Byers