Note that there are some explanatory texts on larger screens.

plurals
  1. POAppEngine entity modeling - minimizing entity groups and achieving atomic cascading update/delete
    text
    copied!<p>Am learning AppEngine and have started developing new app and want to clarify something.</p> <p>I understood that a. To achieve atomicity of update/delete of several entities we need to do it in a transaction and hence all should fall under same entity group b. Having big entity groups is not scalable as it causes contention. (Q1: Correct?) </p> <p>So here is an entity model of an online examination system for sake of discussion:</p> <p>Entities: Subject Exam Page Question Answer</p> <p>As you can see from top, each entity 1 - many relationship with the immediate bottom one i.e 1 Subject can have many exams, 1 exam -> many pages, 1 page can have many questions...</p> <p>As you can see, i would like to establish cascading update/delete relationship among these entities (JPA datanucleus appengine implemention supports this (under the hood) by putting all entities under same entity group (Q2: Correct?) though AppEngine natively doesn't support this constraint) so naturally all would go under same entity group so that a. i can delete a Page (if my user does) in a transaction and be sure that all pages, questions, answers are all deleted b. or i can delete a subject altogether in a transaction all clear all stuff underneath it</p> <p>So when i extend this to my real app, i see that all of my (or atleast most) entities are interrelated and fit into same entity group to be able to transact them altogether - making my model inefficient. </p> <p>Q3: Please advice on how to rethink this design (and the best practice) and still achieve what i need. Ask me more if needed. Would be great if you could point me to relevant examples.</p> <p>p.s. 1 solution i could think of is having each entity in a separate entity group and a separate persistent field in each entity (say Exam) named 'IS_DELETED' defaulting to FALSE (value 0). Once a user deletes an Exam, i will set the field to 1 (TRUE) and that i don't load them anymore. I shall write a Cron job which clears all related entities in separate separate transaction in the backend which will retry upon failures if needed. But am sure this is not elegant and not sure whether this will work out..</p> <p>Thanks all for your responses, Hari </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload