I'm trying to decide between two data modeling strategies for my app
and wondering which one is faster and more reliable.

I'll give an example of my use case because this is a fairly common
scenario and this discussion should benefit other developers as well:

I have a model, UserInfo, with usernames as keys, which makes an
instance fast to retrieve by username with get_by_key_name, and also
enforces the uniqueness constraint for usernames.

I also want each user to be able to have 0 or more aliases in addition
to their usernames (I'm developing an app with an OpenSocial component
on multiple social networks, in case you're wondering, and want the
user's ID on each network to be an alias of their username).  These
aliases should function just like usernames (enable lookup of the
associated UserInfo instance and be unique).  In other words, I want
to immitate an instance having multiple keys.

I'm trying to decide between 2 implementation strategies:

1) add an "aliases" ListProperty to UserInfo and use GQL on this
property for lookup.  This poses a problem: how to enforce uniqueness
of aliases across the system?  Transactions and entity groups don't
fit this case well.

2) create a new entity kind called Alias with keys being the aliases
and one ReferenceProperty pointing at the UserInfo instance associated
with this alias.  The advantage of this method is that it
automatically enforces the uniqueness constraint using keys.
Performance-wise, this method uses 2 key lookups instead of 1 GQL
query.  (It also uses more storage space, but I'm not too concerned
about space)

What I want to know is:

a). which one is faster? (1): a GQL query on a ListProperty holding
strings (with average list size = 2 elements) or (2): a
get_by_key_name lookup followed by dereferencing a ReferenceProperty
(2 key look-ups total).

b). which one is more robust (less likely to throw a datastore error
or timeout)?

c). how many Database API quota units does each one use?

and lastly, a more subjective question,

d). if (1) turns out to be better in all of the above comparisons (a,
b, c), is it worth using (2) just to enforce the uniqueness
constraint.

Thanks for your time.  Hope this discussion will help everyone utilize
the datastore more efficiently!
--~--~---------~--~----~------------~-------~--~----~
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