Links have one or more tags, so at first it might seem natural to embed the tags:
link = { title: 'How would you implement these queries efficiently in MongoDB?'
url: 'http://stackoverflow.com/questions/3720972'
tags: ['ruby', 'mongodb', 'database-schema', 'database-design', 'nosql']}
How would these queries be implemented efficiently?
- Get links that contain one or more given tags (for searching links with given tags)
- Get a list of all tags without repetition (for search box auto-completion)
- Get the most popular tags (to display top 10 tags or a tag cloud)
The idea to represent the link as above is based on the MongoNY presentation, slide 38.