P.S. Set your mysql username as 'root' with empty password
Download File
ErrorReportingEnable=0 |
TraceOutputFileEnable=1 |
MaxWarnings=0 |
Have a table for tags.
Have a table for posts.
Associate the related tags to the posts.
Do some complex queries using 'GROUP BY' to fetch the tags and their counts.
But in the case of document oriented database like MongoDB, the tags will be stored as a String Array inside each post object. For example a post objects will look like
It is a piece of cake through a tool called MapReduce. As the name indicates this includes two functions, Map and Reduce. To simplify we can say as,
Reduce function - receives the key and the value array, reduces the received values and eventually returns the result.
For more detailed info about these functions have a look at http://www.mongodb.org/display/DOCS/MapReduce.
Now let us see a sample code for illustration. The scenario is the same, there will be list of tasks and each task will have n number of tags and we have to group these tags with their count.
My tasks collection will look like the snippet below
The MapReduce class is written as,
Note : Here I had used MongoMapper, Mongo ORM for Ruby. To know more about MongoMapper, visit http://mongomapper.com/
You can also use, db = Mongo::Connection.new("localhost", 27017).db("mydb")
Used this Class to mapReduce tags as