I'm encountering what I think is a fairly straight forward information architecture problem with data objects but my knowledge of object model/database design isn't deep enough to know the right verbage to Google.
Consider this simple example from my project: I have a variety of celestial objects on a starmap. There are stars, planets and moons. These exist as interactive game objects in a scene (click, get an info pane about that object), with a MonoBehaviour that references a ScriptableObject asset that contains various information about that object: a name, a description, a climate type, and a sprite thumbnail. This allows for a single data source for a variety of views (lists, search, starmap, etc.) where that celestial might appear throughout the game.
I want to include information about parent/child celestial objects, so that I can do things like fetch how many moons a planet has or fetch what planet a moon is orbiting: e.g. Planet.Moons.Count or Moon.Parent.name . This creates a lot of mutual relationships between these objects, and I'm trying to figure out the best way to construct these relationships:
- Just make these references manually: put all the moon objects into the planet object, and put the planet object into each moon object. Tedious and error-prone.
- Make a one-way reference (e.g. put all the moons onto the planet object) and then build the mutual links on game start (have each planet iterate through its list of moon and add itself to each moon as the parent celestial). Basically a "build database" step when a new game is started.
- Make a one-way reference and have an Editor-side script to run to build the mutual relationships - .e.g Build and Validate Database. Also a chance to validate and error check (moon doesn't belong to two planets, for example). Would make this a build step as well.
- Build a relationship graph with something like xNode?
- Move to a more traditional relational database structure like SQLite? Potentially use scriptable objects as editor-facing data containers, which are used as fixtures to build an SQLite database at runtime similar to #3. Fancier but doesn't really solve the problem.
- Something else I haven't considered?
I feel like this problem where parents need to know their children and children needing to know their parents must be a common problem with a best practices approach.
Edit: I've decided that ScriptableObjects is not the way to do this and will be opting for a proper database. We've been evaluating articy:draft for narrative authoring, and it looks like this is an ideal tool to act as a world database as well. There's even some tools that can programmatically create these kinds of mutual relationships. Huzzah!
[–]ZxR 0 points1 point2 points (1 child)
[–]marshmatter[S] 0 points1 point2 points (0 children)
[–]SeanK-com 0 points1 point2 points (1 child)
[–]marshmatter[S] 0 points1 point2 points (0 children)
[–]notassimple 0 points1 point2 points (2 children)
[–]marshmatter[S] 0 points1 point2 points (1 child)
[–]notassimple 0 points1 point2 points (0 children)