I am trying to design an application where users collaborate to build a repository, something like Quora:
- Questions will have topics (referenced by topic id).
- Each Topic can have parent topic and child topic (referenced by topic id).
I am trying to understand how to design the merge operations.
- Users should be able to merge one into other (would maintain a log of merges).
- They should also be able to un-merge if found wrong.
- when want to find answers related to a topic, I should be able to get answers from current topic and those merged into this topic.
- When I visit the question, only the merged topic should be visible.
The questions are
What operations should be performed when merge happens, should the topic that is merged into, be added to all the questions under it or keep everything as it is and just add a reference of merged topic
When showing answers related to a topic, search for reference id of topic and loop through merged reference ids as well.
The way to do this is how document management systems are developed. So the idea is to have a document compiled and made available when every merge is done.
This way only one copy of the topic is present and is indexed in whichever system is doing search, storage or is responsible for distribution.
The references to the topic should be kept separate and on every merge, the document should be recreated
Since eventual consistency is important in these scenarios(so the document can always stay and be referenced/dereferenced from the cache)
Hope this helps. Do take a look at twitter architechture for getting near realtime data http://highscalability.com/blog/2013/7/8/the-architecture-twitter-uses-to-deal-with-150m-active-users.html