Re: unique primary key shared between multiple tables.

From: --CELKO-- <>
Date: 20 Mar 2003 15:22:57 -0800
Message-ID: <>

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