On 9 déc, 20:18, HUANG Dong <huangdong...@gmail.com> wrote: > Thank you, Bruno. Your answer is really helpful and covered another > issue I hadn't noticed yet. But my question may be related to > different topic. In my example, number of "libraries" is unknown in > develop time, neither does the classification of "books".
You explicitely mentionned that the reason to "partition" the books in different tables was to speed up queries - and FWIW, I can't think of any other reason to do so. If all you want is classification then using different tables is not the correct solution. > To be more specific, I want to employ some kind of "introspective" > class in python to model my data, and these dynamic classes should be > associated to individual TABLEs in the database respectively. Yes, that's clearly what I understood. But this looks like a wrong solution to a (potentially) real problem, hence my mention of RDBMS- level table partitionning. > So far what I know about Django is that each class inheriting from > models.Model will be associated to a TABLE, and each instance of the > class becomes an item when calling instance.save(). What if I create > an introspective object in run-time? And when to call synchronization > function to write the table into database? How to sync if there's > concurrent creation of classes? What about the performance? All > above are still unknown to me... Creating model classes at runtime is of course possible - if a bit involved - since Python's "class" statement is an executable statement. I'll even give you a couple hint: read the doc for the 'type' type, and google for "metaclass". But I do insist on the fact that whether your _real_ problem is sql queries performances tuning or classification, what you're trying to achieve is _not_ the appropriate solution. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.