I think it's not reasonable. The datastore is used to store entities, they should be real objects. And "red" or "green" should be an abstract class, how can you reference to a "red" object?
Other side, when you want save a food entity, you have to get or create a parent class's object. That means when you want save an apple, you need get or save a "red", make sure it's the only entity of "red" class, and reference to it. And if one day, you like add a new class named "FujiApple", which apple entity you want to reference to? 2009/5/1 Pranav Prakash <pra...@gmail.com> > > Hi Vijay, > > You can try the following database model. > > class FoodAndAll(db.Model): > name = db.StringProperty() > parent = db.SelfReferenceProperty() > ... > ... > > In my view, this class does all your needs. The class has two > properties > 1. Name > 2. Reference to Parent Class > 3. Other optional things > > So, for the bottom level entities (those who are sub-category of a > category), the "parent" will refer to the category. > This will go on. It is not at all necessary for a parent to know his > child, but it is necessary that a child knows his parents. This is how > things will proceed here. I think this Model is best suited for you. > > For searching, you can do whatever you feel like. Now you have just > one Model, one attribute (name). Use judiciously. > > There is no SMS API. > > Cheers, > -- > Pranav Prakash > > http://codecontrol.bogspot.com > > On May 1, 10:08 am, 风笑雪 <kea...@gmail.com> wrote: > > Why don't you let the category to be a property of your model? > > class Food(db.Model): > > category1 = ... > > category2 = ... > > ... > > > > Food(category1=fruit, category2=red, ...) > > > > 2009/5/1 Max Ross <maxr+appeng...@google.com<maxr%2bappeng...@google.com>< > maxr%2bappeng...@google.com <maxr%252bappeng...@google.com>>> > > > > > Hi Vijay, > > > > > Your questions are going to take some time to answer. Some are easier > than > > > others. I'd recommend splitting them up into separate posts. > > > > > Max > > > > > On Thu, Apr 30, 2009 at 9:27 PM, vijay <mymail.vi...@gmail.com> wrote: > > > > >> Ping!! > > > > >> On Thu, Apr 30, 2009 at 5:03 PM, vijay <mymail.vi...@gmail.com> > wrote: > > > > >>> Hello All,I am working on an application and got stuck in design > phase I > > >>> hope you guyz can help me out. I have several doubts related to > performance > > >>> and modelling. > > > > >>> 1# > > >>> In my application i store some hierarchical data and not sure how to > do > > >>> it. > > > > >>> for e.g. say you have data organized as > > > > >>> food > > >>> |____fruit > > >>> | |___red---Iron----apples > > >>> | | | |____something > > >>> | | | > > >>> | | |___Viatamins ---- litchies > > >>> | | > > >>> | |___green----Iron-----apples > > >>> | |_____Vitamin E ----- guava > > >>> | > > >>> |____vegetable-------category1 -----category2----category3 > > >>> | |________________ > > >>> | | |________ > > >>> | |________________________________ > > >>> | |____ |____ > > >>> |____fried |_______ > > >>> |__similarly here > > > > >>> Is there a clean way to store this kind of data in appengine. I mean > what > > >>> should be classes , their properties etc. > > > > >>> In my case the sub categories can upto a depth of 10, with each level > > >>> having 100s of categories. > > >>> I will be executing queries to lookup by any node, so basically i can > do > > >>> lookup by fruit or apple or food as a whole. > > > > >>> 2# > > >>> My applcation is going to have a search box where user will be > writing > > >>> his search items, I would like to suggest them the correct word if > they do a > > >>> spelling mistake, so if they type frut i wil suggest them to type > fruit. > > >>> The way i am thinking of implementing it is to for each word entered > do a > > >>> comparison with each node element with a relaxation of 2, so if the > word > > >>> matched except at two points i will go ahead and suggest it. I think > as i > > >>> need to have sequential traversal of all the nodes, which may take a > lot of > > >>> time and resources, I should store it somewhere to do faster lookup > like in > > >>> memcache, what are your suggestions. > > > > >>> 3# > > >>> Are there any standard APIs to send sms from application. I asked > about > > >>> this in other thread but haven't got any reply, I hope I will get > some > > >>> answers this time. > > > > >>> I am quiet new to web site designing and any other suggestion or some > > >>> pointers to general design principles would be great. > > > > >>> Regards, > > >>> Vijay > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. 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 -~----------~----~----~----~------~----~------~--~---