NOTE: I know this is not a “Bukkit” or Minecraft related website, but I believe the awesome people here will have more knowledge of database design with Mongo than the kids do on the Minecraft forums. Thank you for your time and your assistance!
I am needing advice on how to solve a Mongo database design issue. As such, I have multiple plugins that need to read/write to Mongo. Each plugin uses a “main” or core plugin to communicate with MongoDB. Each plugin holds data related to that particular plugin. Questions and code references provided below.
Plugin Setup Example:
Core Plugin:
- MongoDB Access.
- Utility Classes.
- Shared classes among all plugins.
- This plugin is used on all servers.
Minigame Plugin:
- Contains a variety of games.
- Each game within the plugin needs to save game specific statistics
(kills, times played, etc). - Will continue to be expanded to have more games and more data to save.
- This plugin is not used on all servers.
Some future plugin:
- Will need to save data that is currently unknown but will be designed
in the future.
Some questions regarding the design for this specific setup:
- Should all data for each current plugin and future plugins and
features use one specific Mongo database document? - Should each plugin have it’s own document?
- As features expand and new data needs to be saved and retrived, how
do I prevent NullPointerExceptions due to old profiles not
containing new data (for instance a new minigame release)?
My original thoughts were to pack everything into one single profile document. However not all data in the document would be needed for ever server. So my next idea was to refactor the current setup and separate my database design into multiple documents based on each plugin. However this seems clunky and my lack of experience shows. I am looking for an intelligent design based around my current circumstances. Multiple plugins with constantly evolving sets of data.
My code for reference:
My current profile read/write code: https://pastebin.com/HExiVi5d
My profile data class: https://pastebin.com/8fX6X6b7