Hi Tim, I would suggest dividing articles into three categories (for each user): 1) Unread articles 2) Read articles 3) 'Unseen' articles.
The first two can be implemented by means of a 'UserArticle' entity that represents the read/unread status of an article. I would suggest making them child entities of a User entity. Category 3 exists to encompass articles that were created after the last time the user fetched articles. Thus, the process for getting a list of unread articles would go as follows: - Get the timestamp of the most recent article seen by the user - Fetch and return all articles more recent than that timestamp - For each returned article, add a UserArticle entry marking it as unread - Fetch and return articles with UserArticle entries marking them as unread. -Nick Johnson On Tue, Apr 6, 2010 at 3:01 PM, timwhunt <[email protected]> wrote: > Hi, > > I'm having trouble deciding the best way to use the datastore for a > new app, so I am hoping I can get some advice. I'm trying to decide > the best way to keep my app fast and scalable. > > You can think of it as an RSS reader. I'm trying to find a good way > of keeping track of what articles each user has read so they can > choose to see just the unread ones. Here are the options I've thought > of: > > Option A - One object for each article with a list property that holds > the userIDs of all the users who have read it. To get the list of > unread articles for a user, I'd query with a filter that the list > property != theUserID. I'm starting to doubt this would work, as it > sounds like the query would match if ANY list entry was != theUserID > (rather than ALL list entries != theUserID.) Also, adding userIDs to > the list for that one object whenever a user reads the article might > lead to contention. > > Option B - similar to Option A, but sharding the object for each > article. That is, instead of 1 object per article, have multiple > (e.g., 10) and map each user to always use the same shard. That might > help the contention issue for marking which articles are read, but if > Option A's query fundamentally won't work, the same problem exists > here. > > Option C - Create a separate article object for each user. So if I > (am lucky to) have 10,000 users, there would be 10,000 objects for > each article, with each object specific to one user and holding just > their read status. I think this would work, but it seems very > wasteful. It might also be a challenge to create all those objects > (when articles are added or next time each user logs in), perhaps > being a problem or the 30 second task limit. I realize I could save > some space by using objects that had only partial article info for > each user (e.g., The article's key and any other properties for > filtering), but then I think showing the list of unread articles would > be a two step process (get the list of article keys, and then get the > article content for display) > > Option D - One object per article, but separate objects to mark which > have been read by individual users. Since the Datastore is different > than a relational database, I think getting a list of unread articles > would be a two step process: First get the list of articles, then get > a list of all the read articles and remove them. > > So those are the best ideas I've come up with, but none seem very > idea. Any suggestions would be greatly appreciated. > > Thanks! > Tim > > -- > 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. > > -- Nick Johnson, Developer Programs Engineer, App Engine Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number: 368047 Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number: 368047 -- 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.
