0

I am trying to create a simple app on GAE/J. The data model consists of a list of notes, each with a few tags.

In the relational world, this would be a many-to-many - since each note can have several tags, and every tag can "belong" to several notes. However, this doesn't fit GAE datastore environment very well. So, I'm considering saving with each note, its list of tags as well. If indexed properly, searching by tag should be quick too.

My question: How to model this using Siena? Documentation is sparse and I saw the examples, but got confused.

curioustechizen
  • 10,572
  • 10
  • 61
  • 110

1 Answers1

1

Siena doc is sparsed as I don't have time to work on it anymore... I'm busy on other projects and if anyone wants to contribute and maintain Siena, he/she's welcome ;)

Considering your question, yes you should use a simple List (aka properties list) which is managed by Siena and works in GAE.

Add a field such as : (no annotation)

List<String> tags

It should work!

mandubian
  • 4,427
  • 1
  • 22
  • 15
  • I'm sorry if the comment about documentation sounded like a rant. I didn't mean to offend! Now, what if my tag is a model in itself and not just a String? Can I just do `List tags`? I read about embedding and thought I should use `@Embedded` annotation with this. My understanding was that if you don't want `JOIN`s to be performed (the scenario that I described in my question), then one should use `@Embedded`. Is this understanding correct? – curioustechizen Mar 22 '12 at 03:20
  • 1
    Don't worry, I'm not offended :D It's just that I'm sadly aware about it and can't work anymore on Siena as I did last year as I work on other projects... Concerning Tags, no you can't use List but List as GAE only manages primitive types for List properties. @Embedded would be a solution also but there are limitations in GAE about the number of updates you can do in an entity group (embedded entities). You can't modify this group more than 1times/sec. So I would advise you to use List and write your Tag key as a String so that you can find the corresponding very easily. – mandubian Mar 22 '12 at 09:50
  • Ok - I get it now. I'll probably stick to using simple `String`s as tags (that's what tags are anyway!). I still need to actually try out how the "Find notes with so-and-so tag" works out. I'll update my findings here. – curioustechizen Mar 22 '12 at 14:16
  • I got this working - but still couldn't figure out one thing: The most efficient way to search for all `notes` which contain a given `tag`. In particular, how do I make the `filter()` method look inside the `List`? – curioustechizen Mar 23 '12 at 11:39
  • read this (operator = searches in the list) http://code.google.com/intl/en/appengine/docs/python/datastore/typesandpropertyclasses.html#ListProperty – mandubian Mar 23 '12 at 15:51
  • Ah I see. As simple as that :) – curioustechizen Mar 23 '12 at 16:41