Give a "key_name" to your user entities at creation time.  I use
'platform_uid', but you can use whatever you want.  Getting entities
by key_name is as fast as it gets -- it treats the Datastore like a
big distributed hash table.

See:
http://code.google.com/appengine/docs/python/datastore/keysandentitygroups.html#Kinds_Names_and_IDs
and:
http://code.google.com/appengine/docs/python/datastore/modelclass.html#Model_get_by_key_name

I use strings for both platform and uid for flexibility.

You also may want to store the platform and uid as fields separately
too so you can query on them independently.



On Jul 10, 6:04 am, neil souza <[email protected]> wrote:
> the problem:
>
> how to best structure the id system for a social network app on app
> engine.
>
> the run down:
>
> users access the app through a social network. they identify
> themselves to the app with a 'platform type id' (pl_type_id, enum) and
> 'platform user id' (pl_user_id, 64bit int) pair. examples: user 12345
> at facebook, user 45678 at myspace, etc.
>
> we need to be able to find their data using that pair. we also need to
> be able to find their friend's data using lists of the same sort of
> pairs.
>
> let's say for the sake of simplicity that each user has a User object
> in the datastore. we need to be able to efficiently fetch a specific
> User object using a (pl_type_id, pl_user_id) pair, and fetch a list of
> User objects (up to say 1000) using a list of (pl_type_id, pl_user_id)
> pairs.
>
> ideas thus far:
>
> 1.) User has integer properties for pl_user_id and pl_type_id.
> resolving one user object is no issue, resolving many requires an 'IN'
> query, which is not viable since it makes 1 query for each pair in the
> list - NO GOOD
>
> 2.) User objects use key names of the form '<pl_type_id>:<pl_user_id>'
> or something similar. then we can form the key from the provided info
> and fetch based on keys. we never used to do this because sql sucked
> at finding strings - not sure how app engine does..? - BETTER..?
>
> 3.) is there a way to specify the id on a newly created Model? we know
> the pl_user_id is unique. we can then have a Model for each network
> and build keys from the pl_user_id. this is how we used to roll in the
> mysql world. - MAYBE..?
>
> additional ideas and feedback appreciated, thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
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