Re: Is this bad design ?

From: Fabian Buettner <green_at_tzi.de>
Date: Tue, 09 Mar 2004 14:35:19 +0100
Message-ID: <404DC817.2090804_at_tzi.de>


If only valid mothers can have children, you could partition your Mother table as follows:

Mother( mother_id primary key, etc_fields ) -- all mothers

ValidMother( mother_id primary key + foreign key ref Mother(mother_id)) -- "valid mother" ids

Child( mother_id foreign key ref. ValidMother(mother_id), more_fields)

This way you can ensure that only valid mothers are referenced by children. Also (if referential integrity is available), a mother can not become invalid (i.e., delete entry from ValidMother) when there are still children referencing it.

Regards,
Fabian

ben brugman wrote:
> Mother table.
> fields:
> mother_id
> still_valid boolean
> etc_fields
>
> Child table
> fields:
> mother_id
> still_valid boolean
> more_fields
>
>
> The child.still_valid field always contains a true, because only mothers
> withs are still_valid can have children, to enforce this; a relation is
> defined on the fields mother_id and still_valid.
> (A child can not exist without its mother).
>
> Because a field in the child table always has the same value, I think
> there is something wrong. But if this field is taken away a mother might
> become un_valid by another action.
>
> Is this bad design ?
> what is a alternative ?
>
> (As I understand constraints should be implemented in the RDBMS and
> not in the code).
>
> ben brugman
>
>
>
>
>
Received on Tue Mar 09 2004 - 14:35:19 CET

Original text of this message