Hi,
I have a data model where I'm not sure if I'll get any benefit from nesting classes in entity groups. The basic model is that User owns many horses, a horse can only own one saddle:
// Model 1, nest everything:
User
Horse
Saddle
Horse
Saddle
// Model 2: Just let them all be siblings.
User
Horse
Horse
Saddle
Saddle
I'm not sure if I gain any advantage over nesting saddle instances under a horse, or if I should just leave them all as siblings.
Generating keys:
// Model 1:
Key key = new KeyFactory.Builder(
User.class.getSimpleName(), userid)
.addChild(Horse.class.getSimpleName(), horseid)
.addChild(Saddle.class.getSimpleName(), saddleid).getKey();
// Model 2:
Key key = new KeyFactory.Builder(
User.class.getSimpleName(), userid)
.addChild(Saddle.class.getSimpleName(), saddleid).getKey();
So generating keys is more work for situation 1, and I'm wondering if I should just switch to situation 2 instead, if I'm not gaining any advantage over the additional nesting? The operations I have to do:
- Delete a horse and its saddle.
- Create a horse with a saddle.
- Update a horse and its saddle.
- Get a horse by itself.
- Get a horse and its saddle at the same time.
Both models give me all the above, I think. Maybe model #1 offers the advantage that the entire User object doesn't have to be locked when performing operations only on a Saddle?
Thanks