Search Postgresql Archives

Re: Is this correct behavior for ON DELETE rule?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



on 2/25/05 4:09 PM, rschumeyer@xxxxxxxx purportedly said:

> I have two related tables, ³item² and ³book².  I have defined
> a view, ³bookview² that contains fields from item and book.
> My goal was to have all inserts, updates, and deletes performed
> on bookview rather than on the tables directly.  I was able
> to do this with ON INSERT and ON UPDATE rules easily.

You may have better luck letting foreign key constraints work for you, and
specify ON DELETE CASCADE in your constraint. If, however, you don't always
want to delete related "book" rows when "item" rows are deleted, you may
want to re-think your relation.

> -- "child" table
> create table book
>     (id    integer references item primary key,
>     title varchar(20),
>     author varchar(20)
> );

Best,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux