Constraint, Rule, or Trigger?

Started by Randall Perryover 24 years ago3 messagesgeneral
Jump to latest
#1Randall Perry
rgp@systame.com

I've had experience with SQL and database design, but not much with rules &
triggers. What's the best method to accomplish the following it PGSQL:

_Table A_ has a boolean field 'status'

_Table B_ has a 1-1 child relationship to Table A.

The rule, trigger, or contraint would have to enforce that: no record could
be created in B if the 'status' field was false in the parent record in A

Just point me in the right direction.
Thanks

--
Randy Perry
sysTame
Mac Consulting/Sales

#2Joe Conway
mail@joeconway.com
In reply to: Randall Perry (#1)
Re: Constraint, Rule, or Trigger?

I've had experience with SQL and database design, but not much with rules

&

triggers. What's the best method to accomplish the following it PGSQL:

_Table A_ has a boolean field 'status'

_Table B_ has a 1-1 child relationship to Table A.

The rule, trigger, or contraint would have to enforce that: no record

could

be created in B if the 'status' field was false in the parent record in

A

Just point me in the right direction.
Thanks

Well start here: http://www.postgresql.org/idocs/index.php?plpgsql.html
and in particular look at
http://www.postgresql.org/idocs/index.php?plpgsql-trigger.html

Also, if you have the source tree available, look at

<path-to-pgsql-source>\src\pl\plpgsql\test\triggers.sql

for lots of examples.

Hope this helps,

-- Joe

#3Randall Perry
rgp@systame.com
In reply to: Joe Conway (#2)
Re: Constraint, Rule, or Trigger?

on 8/10/01 10:53 PM, Joe Conway at joseph.conway@home.com wrote:

I've had experience with SQL and database design, but not much with rules

&

triggers. What's the best method to accomplish the following it PGSQL:

_Table A_ has a boolean field 'status'

_Table B_ has a 1-1 child relationship to Table A.

The rule, trigger, or contraint would have to enforce that: no record

could

be created in B if the 'status' field was false in the parent record in

A

Just point me in the right direction.
Thanks

Well start here: http://www.postgresql.org/idocs/index.php?plpgsql.html
and in particular look at
http://www.postgresql.org/idocs/index.php?plpgsql-trigger.html

Also, if you have the source tree available, look at

<path-to-pgsql-source>\src\pl\plpgsql\test\triggers.sql

for lots of examples.

Hope this helps,

-- Joe

Thanks, it does.

--
Randy Perry
sysTame
Mac Consulting/Sales