I am trying to determine the most efficient way to create a voted object in a GAE datastore. I would like to show the user a voting control for this person or an icon indicating that they have already voted for him; those. I ask: "User voted for this organization?" Suppose we have a Question object that the user can vote on. Here is what I am going to do:
- Request for Question objects. These questions already have a pre-calculated rating by which I will sort.
- Use a relation index object that is a child of the Question object. A query for all Questions using the same filters as # 1, where my user is a member of this relationship index object.
- Combine results # 2 into # 1 by setting the foundVoted property to true for each item in the set.
This is the cleanest way I could think of, but it still requires two queries. I did not create duplicate Question objects for each user because this would cause too much data duplication. Is this a good way to deal with what is actually the mix between the m2m relationship between Voices and Questions, or am I thinking too relationally?
source
share