Adequate Entity Design In App Engine Datastore

Hi, 
I would like to know if there is an adequate of efficiently modeling the 
following basic relationship in the Non Relational Data Model of the Data 
Store App Engine.

Say we have a data model with the following two concepts:

(1) DayType, which is defined recursively based on itself.
E.g. Of Day Type Tree Structure
(a) Rainy Day
(a.a) Typical UK Day
(a.b) Diluge
(b) Sunny Day
(a.a) Hell of a Day
(a.b) Snuy cloudy

And using JDO we could illustrate the entity as follows.
@PersistenceCapable
public class DayType  {
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key; 
@Persistent()
private String name; 
@Persistent
DayType parent;
@Persistent (mappingto = "parent")
Set<DayType> childre = new ...;
}


(2) We would also have the concep of DayRecord to keep track of days during 
the year.
@PersistenceCapable
public class DayRecord  {
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key; 
@Persistent()
private Date day; 
@Persistent
DayTpe type;
}


First problem,
With code like this we would only go as far as writing our DayType 
hierarchy.
After that, we would get an Exception telling us that DayRecords could not 
be persisted with the given DayTypes because the given DayTypes has already 
been stamped with their own parents. In a Relational Model we would just be 
creating a F.K on the DayRecord entity pointing to DayType. 

Anyway, To solve this enforced parent concept that is implied in the above 
code, and apparently in every App. Engine Entity Relationship, we would 
have to enrich the DayType entity wtih a new property so that it would own 
the relationship with DayRecord.
Thus DayType would be given
@Persistent
Set<DayRecord> dayRecords;

And the DayRecord with have to say
@Persient (mappedbz dayRecods)
DayType type;

This way we would be able to solve all our entities.
But at the same time, this is scary, for it seems to imply that once I 
manpulate a DayType record, I will be loading almost the entire database 
along with because of its dayRecords property.


Is there a solution for this?
Or do I simply have to query the database, making that instead of loading 
the DayType entity I only read the relevant properties of DayType?


My kindest regards,
G. de M.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine/-/J6_wcGmpL5EJ.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to