Re: unique primary key shared between multiple tables.

From: --CELKO-- <71062.1056_at_compuserve.com>
Date: 20 Mar 2003 15:22:57 -0800
Message-ID: <c0d87ec0.0303201522.29a7367f_at_posting.google.com>


I just could not stand those names. Try this bit of SQL, which I am not recommending in practice:

CREATE TABLE RentalProperties
(property_nbr INTEGER NOT NULL
 private_owner_nbr INTEGER

     REFERENCES PrivateOwners(owner_nbr),  business_owner_nbr INTEGER

     REFERENCES BusinessOwners(owner_nbr),

  • at least one owner CHECK (COALESCE (private_owner_nbr, business_owner_nbr) IS NOT NULL),
  • at most one owner CHECK (COALESCE (private_owner_nbr, business_owner_nbr)
    • COALESCE (business_owner_nbr, private_owner_nbr)), ... );
Received on Fri Mar 21 2003 - 00:22:57 CET

Original text of this message