ProblemI need to display different data based on some set of long lists of rules. Rules are different for each website that would use my system.Each second, I fetch an everchanging data set from a datastore and upsert them into games and stats collections. After that, I need to display the data after applying the site-specific rules.Basically, when new data arrives, I merge that data into games and stats collections, and then I would derive the custom games and stats data from the original games and stats collections.I've got some solutions:Creating different collections for each website, and continuously merging data from the original collections to website's collections and apply rules for all the data.In this case, I need to ensure that data synced properly between new collections and it's more complex to use it.Re-create custom collections for each website on each data update by applying rules. This will remove merging and will create the collection all over again.This can cause race-condition problems when re-creating data and cause server-unavailability problems, or retry-mechanisms.Use the original collections and apply the rules on each web request and cache the data for 5 secs (it needs to update fast).This would slow down the webserver, and create some problematic caching invalidation code.Each solution has its own tradeoffs.So, which solution do you think is the best? What other solutions can you suggest?CollectionsGamesStart DateCompetitors: ID, NameTournaments: ID, NameStats Collection(belongs to a game)Stat: StatTypeId, GameID, StatRatioRules CollectionCompetitor rules: Enable/disable some competitors for a websiteTournament rules: Enable/disable some tournaments for a websiteStats rules: Change stat ratios for a websiteThere are many other details about rules of course, such as priority order: Tournament rules overwrite competitor rules which override stats rule etc. I kept them here simple for brevity.
Deriving data from MongoDB collections that are distinct for each website
design;architecture;database design;scalability;mongodb