FindBoat
FindBoat

Reputation: 591

GAE datastore: Is it good to separate model with reference?

For instance, I have an Author model, which contains 2 parts: author profile, and his articles. class Author: # Author profile properties. name = ... age = ...

# Author articles properties. ...

When designing the model, I got two options: 1) Create a separate model class called article and add a list of reference in the Author model. 2) Just define all these into the same model and use projection query to read profile.

So which one is better in the sense of read/write/update cost given the fact that most of the read is for profile? What if the article property will get larger and larger in the future?

Upvotes: 0

Views: 54

Answers (1)

voscausa
voscausa

Reputation: 11706

A single entity if possible is the best solution. But what kind of queries do you use? Do have to query all the articles including the content or only the article metadata. Because you can put a lot of metadata is a single 1Mb entity.

So the real questions are: what kind of queries do you need, how much metadata do you have and what do you do with the result set, like showing a user a result page using a cursor.

Maybe you can use the search API : https://developers.google.com/appengine/docs/python/search/#Putting_Documents_in_an_Index

Upvotes: 1

Related Questions