Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: Why can't I put a BEFORE EACH ROW trigger on a view?




On 02/24/2007 06:55:45 PM, Webb Sprague wrote:
I also think that a view is supposed to be just that -- a *view* of
underlying data, which in no way modifies the data.  I don't know much
about the design ideas behind  SQL, but I think this view of views
(haha) is an underlying assumption.  If you are modifying data when
you do a select on a view, you are probably not using SQL the way it
was intended (not that that is a bad thing, but ...)

The postgresql docs say something like: Having lots of views
is the mark of good database design.

That's because views present the same data in various ways,
to different users as each user thinks of the data.  In general,
they allow good db design, and in a well designed db will
be incomprensibe to the average user, partly because it contains lots
of foreign keys to manage 1-to-many relationships.  If it
makes sense to make a view so the user can see the data
in a form they can understand, then it makes sense to
allow the user to update the same view of the data.

Postgresql has "rules" which I *think* can rewrite select statements.
Rules are kind of a pain, but maybe what you want.

You can't rewrite select statments.  That's where I started.
Trying to do so turns your table into a view, which then
can't have triggers.

Karl <kop(at)meme(dot)com>
Free Software:  "You don't pay back, you pay forward."
                 -- Robert A. Heinlein




Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group