AppEngine / Non Relational Messaging System with Message Status - Design Pattern
I'm building a Threaded Messaging System that will be hosted on Google AppEngine

I've modeled it after the technique described by Brett Slatkin in [Building Scalable, Complex Apps on App Engine][1]

    class Message(db.Model):
      sender = db.StringProperty()
      body = db.TextProperty()
    
    class MessageIndex(db.Model):
      receivers = db.StringListProperty()

The issue I'm having to determining the most efficient way to track the message state for a User.
For example is a message `read`, `archived`, `deleted` for a particular user.

Here are the solution I have come up with so far.

I'm using [Datastore+][2]'s StructuredProperty to add a state to the message `MessageIndex`

    class Message(model.Model):
      sender = model.StringProperty()
      body = model.TextProperty()

    class _DisplayState(model.Model):
      user_key = model.KeyProperty()
      state = model.IntegerProperty(default=0) # 0-unread, 1-read, 2-archived

    class MessageIndex(model.Model):
      receivers = model.StructuredProperty(_DisplayState, repeated=True)

This solution, while simple, negates the benefit of the MessageIndex. Additionally since the the MessageIndex is in the same entity group as the message datastore writes will be limited.

[Full Source Code][3]

What would be the most efficient way to accomplish this? Would adding an additional entity group be a better solution?

    class MessageState(model.Model):
      user_key = model.KeyProperty()
      message_key = model.KeyPropery()
      message_state = model.IntegerProperty(default=0) # 0-unread, 1-read, 2-archived


  [1]: http://www.google.com/events/io/2009/sessions/BuildingScalableComplexApps.html
  [2]: http://code.google.com/p/appengine-ndb-experiment/
  [3]: https://gist.github.com/1025736
AppEngine / Non Relational Messaging System with Message Status - Design Pattern
===

I'm building a Threaded Messaging System that will be hosted on Google AppEngine

I've modeled it after the technique described by Brett Slatkin in [Building Scalable, Complex Apps on App Engine][1]

    class Message(db.Model):
      sender = db.StringProperty()
      body = db.TextProperty()
    
    class MessageIndex(db.Model):
      receivers = db.StringListProperty()

The issue I'm having to determining the most efficient way to track the message state for a User.
For example is a message `read`, `archived`, `deleted` for a particular user.

Here are the solution I have come up with so far.

I'm using [Datastore+][2]'s StructuredProperty to add a state to the message `MessageIndex`

    class Message(model.Model):
      sender = model.StringProperty()
      body = model.TextProperty()

    class _DisplayState(model.Model):
      user_key = model.KeyProperty()
      state = model.IntegerProperty(default=0) # 0-unread, 1-read, 2-archived

    class MessageIndex(model.Model):
      receivers = model.StructuredProperty(_DisplayState, repeated=True)

This solution, while simple, negates the benefit of the MessageIndex. Additionally since the the MessageIndex is in the same entity group as the message datastore writes will be limited.

[Full Source Code][3]

What would be the most efficient way to accomplish this? Would adding an additional entity group be a better solution?

    class MessageState(model.Model):
      user_key = model.KeyProperty()
      message_key = model.KeyPropery()
      message_state = model.IntegerProperty(default=0) # 0-unread, 1-read, 2-archived


  [1]: http://www.google.com/events/io/2009/sessions/BuildingScalableComplexApps.html
  [2]: http://code.google.com/p/appengine-ndb-experiment/
  [3]: https://gist.github.com/1025736