Har_Shan:
I have been thinking about this topic also (but sadly, am not much of
an expert). I am using Objectify as a layer on top of the Datastore.
Their website has a lot of good information on structuring data in the
Datastore - see http://code.google.com/p/objectify-appengine/wiki/Concepts?tm=6
).
There is also a good post on the various ways of handling 1 to many
relationships using Objectify. What appeared to be something that
would work in your situation (which is like my situation) is what I
think of as the "database approach". What I mean by that is, if you
had a 1 to many relationship, how would you model that in a database?
Specifically if 1 User can have Many Exams, you would have...
User table
* userId
* Other user fields
Exam table
* examId
* userId
* Other exam fields
So, turning this into GWT/Objectify, it would be....
public class User {
@Id private Long id;
// Other user fields
}
public class Exam{
@Id private Long id;
private Key<User> userKey;
// Other exam fields
}
The way to find all the exams for a particular user (represented by
"this") is:
Objectify ofy = ObjectifyService.begin();
Key<User> userKey = new Key<User>(User.class, this.id);
List<Exam> result = ofy.query(Exam.class).filter("userKey",
userKey).list();
This is explained (much better than I could do) at:
http://code.google.com/p/objectify-appengine/wiki/IntroductionToObjectify#Relationships
This may not solve all (or any) of your use cases, but it has worked
for me in my admittedly very limited usage.
Also check out:
http://groups.google.com/group/objectify-appengine/browse_frm/thread/102ede7022c7d7cf/30e6070900d5d523?lnk=gst&q=relationships#30e6070900d5d523
Enjoy,
RB
On Dec 19, 12:17 am, Matej <[email protected]> wrote:
> I am not expert in dataStore this is just what I would do:
> Add new entity with fields:
> ID OrderID UserID ExamID PageID QuestionID AnswerID
>
> Yes it is a lot of redundant data, but simple.
> When user starts new Exam, all data are created with AnswerID set to
> general answer unAnswer. After that you just update AnswerID.
>
> What are obstacle in design like this?
>
> Best, M
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" 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-java?hl=en.