Ok. I am dealing with GAE. And that i want create something similar to this:

I've types "group" "subject" "tag":

  1. each "group" might have as numerous "subjects" when needed

  2. each "subject" might have as numerous "tags" when needed

  3. each "group" might have as numerous "tags" when needed

it is something like circle.

at this time i've something similar to this:

class TopicGroup(db.Model):
    value = db.StringProperty(required=True)

class Topic(db.Model):
    title = db.StringProperty(required=True)
    group = db.ReferenceProperty(TopicGroup, 'group', 'topics', required=True)

class TopicTag(db.Model):
    topic = db.ReferenceProperty(Topic, 'topic', 'tags', required=True)
    group = db.ReferenceProperty(TopicGroup, 'group', 'tags', required=True)
    value = db.StringProperty(required=True)

but this really is not good (during my model "subject" might have just one tag, however i nead "subject" to possess as numerous tags when needed)

well i curently have a crack during my mind... can there be somebody that may help?

Many-to-many joins could be implemented as join tables (or Relationship Models). Within the solution below, there's one that holds all the tags which are put on individual Groups (GroupTags) along with a model store the tags which are put on Topics (TopicTags).

Decoupling the Tag itself from references towards the Tag enables you to definitely do such things as alter the spelling of the tag without requiring to update every Group or Topic that that Tag is used.

Also, this model takes good advantage to the fact that AppEngine produces automatic backreferences on organizations which have other organizations referencing them. Within the models below, an organization entity may have a house known as topics that's a question which will fetch all Topic organizations who's group reference indicates that Group. Similarly, each Group will get a tags property in the GroupsTags model that provides all the Tag organizations owed into it. Every Tag entity will get a groups and topics property that's a question its the organizations of individuals types which have the give Tag designated, making searching by tag (a really typical operation) fairly simple.

It is a very effective and versatile method of modeling systems for example yours.

class Group(db.Model):
    # All of my group-specific data here.

class Topic(db.Model):
    title = db.StringProperty(required=True)
    group = db.ReferenceProperty(Group, collection='topics')
    # other topic-specific data here.

class Tag(db.Model):
    text = db.StringProperty(required=True)

class GroupTags(db.Model):
    group = db.ReferenceProperty(Group, collection='tags')
    tag = db.ReferenceProperty(Tag, collection='groups')

class TopicTags(db.Model):
    topic = db.ReferenceProperty(Topic, collection='tags')
    tag = db.ReferenceProperty(Tag, collection='topics')

The answer is by using a db.ListProperty with a kind of db.Key. see: http://code.google.com/appengine/articles/modeling.html (section many to a lot of)