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

Re: Discussion wanted: 'Trigger on Delete' cascade.

From: R(dot)Welz <linuxprodukte(at)gmx(dot)de>
To: Pierre-Frédéric Caillaud <lists(at)boutiquenumerique(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Discussion wanted: 'Trigger on Delete' cascade.
Date: 2004-07-28 12:45:17
Message-ID: FAA649CB-E093-11D8-B36A-0003936EF152@gmx.de (view raw or flat)
Thread:
Lists: pgsql-general
Yes.
A magazine can have several e-mail addresses, and one e-mail address 
can belong to several magazines. Well, the e-mail addresses belongs to 
the publisher but for simplification the e-mail address is linked with 
the magazine.


So what is really more important is that I don't know, is there a big 
performance penalty of the sort of "trigger calling another trigger" or 
would it be noticeable faster if the first trigger does all the 
checking and decides itself wheather to delete table B.

I think of writing a really large database, so performance is most 
important, or will there be no noticeable performance hit? It is my 
first big database.

Thank you
Robert

Am 28.07.2004 um 13:24 schrieb Pierre-Frédéric Caillaud:

>
>
> 	From what you say, your do not need a link table.
> 	A link table is useful to link several items of a table to several 
> items of another table (many-to-many relationship).
>
> 	Example : items and categories.
>
> 1- An item belongs to a category
> No need for a link table.
> table categories ( id serial primary key );
> table items ( category_id integer references categories( id ) on 
> delete cascade );
>
> 1- An item belongs to several categories
> table categories ( id serial primary key );
> table items ( id serial primary key );
> table links (
> 	category_id integer references categories( id ) on delete cascade,
> 	item_id integer references items( id ) on delete cascade,
>  );
> In this case you do need a link table.
>
> You also need triggers to delete items when
> 	- a link is deleted from the links table
> 	- no more links to this item exist
> which is, in fact, reference counting.
>
>
>
>
>
>
>
>
>
>
>
>
>


In response to

pgsql-general by date

Next:From: Geoff CaplanDate: 2004-07-28 12:57:23
Subject: Re: Sql injection attacks
Previous:From: Prabu SubrotoDate: 2004-07-28 12:09:33
Subject: Re: altering a table to set serial function

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group