Subject Re: [firebird-support] How to save a parent-child relation?
Author Ann Harrison
On Aug 20, 2011, at 6:25 AM, W O <sistemas2000profesional@...> wrote:

> Hello everybody
>
> I have two tables in a parent-child relation.
>
> How can I avoid to save a row in the parent table if there is not a row in
> the child table?
>
> If the parent table has a row and the child table has one (or several) rows,
> it is ok.
>
> If the parent table has a row and the child table has not one (or several)
> rows, reject.

OK, let me try to restate that. The foeeign key constraint requires that each child have qa parent. You also want to require that each parent have at least one child. The obvious question is how do you ever store a new parent, in the absence of deferred constraints. You could use triggers.

Good luck,

Ann