On 3/31/06, Joseph Kocherhans <[EMAIL PROTECTED]> wrote: > > On 3/31/06, Andy Dustman <[EMAIL PROTECTED]> wrote:
> > I have some notes on the ModelInheritance page about possibly using > > views to simplify reading, and while none of the databases I could > > find could do a multi-table update through a view without writing > > stored procecures and triggers, I realized that individually updating > > the underlying tables is no worse than if you didn't use views. So > > views seem to be a win for reading and neutral for writing. > > I thought the same thing, but I was both pessimistic and lazy. I > didn't beleive that the 3 main players (postgres, mysql, sqlite) would > all let you update and insert on views, and I didn't reasearch it to > make sure :) I'm not sure if this was clear, but at least MySQL-5.0, MS-SQL, DB2, and Oracle appear to allow you to update views that are based on joins, provided you only update underlying one table at a time. To update multiple tables, you need to use triggers (rules in the case of PostgreSQL, and I'm not sure views are updatable in PostgreSQL at all without writing a rule for each view) and stored procedures. However, the alternatives are updating the underlying tables with individual queries, or updating them using the view, but then you have to make sure you aren't touching more than one table at a time. I.e. if your class is spread across three tables, you'd have to make up to three queries when making an update, depending on what attributes/columns changed. The simpler alternative is close to what it does now: A subclass gets it's own tables, and inherits fields from the parent class. Right now it inherits the fields, but it seems like it also inherits the table name as well for select. And they don't inherit ManyToMany relations yet, but should. -- The Pythonic Principle: Python works the way it does because if it didn't, it wouldn't be Python. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" 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/django-developers -~----------~----~----~----~------~----~------~--~---
