>From what I understand, I believe that in the datastore these two models are
pretty much the same (I have to use python syntax since this is what I use):

UserCommunityModel1(db.Model):
    Email = StringProperty(required=True)
    Communities = ListProperty(string,required=True)

UserCommunityModel2(db.Model):
    Email = StringProperty(required=True)
    Community = StringProperty(required=True)

If you want all users in  'community111', your GqlQuery will look like this
(it's pretty much the same query for both):

Select * From UserCommunityModel1 Where Communities = 'community111'
Select * From UserCommunityModel2 Where Community = 'community111'

And the results for each query would be the same (a List of entities giving
you the email addresses of people who belong to 'community111')..

If you wanted all the Communities for user with 'email111' your GqlQuery
would be:

Select * From UserCommunityModel1 Where Email = 'email111'
Select * From UserCommunityModel2 Where Email = 'email111'

In this case, processing the results of each query would require different
code.

For UserCommunity1, it would be (presuming "fetchedResults" is what the
query returned):

UsersCommunityList = fetchedResults[0].Communities

For UserCommunity2, it would be (again, this is in Python):

UsersCommunityList = []
for result in fetchedResults:
    UsersCommunityList.append(result.Community)

Again, my intuition tells me (based on the different appengine IO talks I've
watched about the datastore), that underneath.. in the datastore.. these
models look the same and have the same indexes and would be the same size.

The only difference is that it is somewhat easier to query
on UserCommunityModel1 when getting all of a user's Communities.. (and it
might be a little quicker since the datastore would be combining into one
entity before returning it to you).. And, you can query to get all emails
for users that belong to multiple Communities.

Also, the best way to test is just create a sample application and create
each model type.. populate each model with same same user and community
mappings (whatever you feel would be realistic).. and then run some
benchmarks against fetches to see how long each takes.. and how much CPU is
used.

On Tue, Aug 24, 2010 at 4:30 PM, skin <[email protected]> wrote:

> Thanks a lot Eli for sharing your thoughts on this. So what you are
> suggesting is that I can do with  just List<key> communitiesJoined in
> User class.
>
> I need not  have a mapping of users enrolled in community in Community
> class. And whenever i need to retrieve the list of users in a
> community, I should do select query with like Select * from Users
> where communityId in List of communities. Ain't this going to impact
> the response time to a greater extent?
>
> I think there has to be a trade-off between memory utilization and
> response time depending on the requirement. Is there some research
> done on which will be faster or some sample application which can show
> us which technique will be better.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to