Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: Normalization and Design Question

Re: Normalization and Design Question

From: andrewst <member14183_at_dbforums.com>
Date: Tue, 22 Apr 2003 16:58:48 +0000
Message-ID: <2793545.1051030728@dbforums.com>

Originally posted by Absinthe
> ...
> ContactAddresses(
> ID, <-- uniq id
> ContactID, <-- fkey to Contacts.ID
> Address,
> City,
> State,
> Zip,
> DefaultYN
> )
>
> Other than interface-wise I can see no way of enforcing this to
> have only
> one default address/phone. Though perhaps a trigger may handle it.
>
>

You could use a unique function-based index to enforce the rule:

create unique index ContactAddresses_index on ContactAddresses ( decode( DefaultYN, 'Y', ContactID) );

This would permit 0 or 1 defaults per Contact, and to change the default you would have to update the old record's DefaultYN to 'N' BEFORE changing the new record's DefaultYN to 'Y'.

--
Posted via http://dbforums.com
Received on Tue Apr 22 2003 - 11:58:48 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US