2

I'm trying to get my head around NoSQL and Google Cloud Datastore, and I don't know how to chose between two different options for storing data.

I have a list of orders, and every order is for an unspecified number of products. What are the pros/cons of storing the product list as an array property for the order entity vs having product child entities for each order parent?

Richie
  • 77
  • 2
  • 4

1 Answers1

2

Firstly, be well aware of the distinction between the 2 possible approaches of implementing a relationship between entities:

  • one entity can contain a Key type property pointing to another entity (which might or might not exist!) - this is a functional relationship only, not one at the datastore level
  • having the 2 datastore entities in a parent-child (ancestry) relationship, inside the same datastore entity group.

Using the 2nd one has scalability implications, see also:

As for storing a list as an array property vs as separate entities, see Creating your own activity logging in GAE/P (where repeated properties is just how array properties are called in the ndb client library context).

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97