Re: Referential Integrity across Multiple Databases? Please Help!
Posted in 1997
Chris Collins wrote: > > Hello All, > > I have two separate databases for two applications. I need to enforce > referential integrity across the two databases - I would rather not > have to use single database, but rather keep the databases separate. > > Is there a way to create a foreign key relationship between tables > that do not reside in the same database. Chris, years ago, when I had some time on my hands, I tried it as well. The answer is that (at least in Informix) there is no way to define a referential integrity constraint across databases. This restriction is pretty clear in the error message. HOWEVER, you can still resort to triggers to enforce your integrities. This means.. 1. Delete trigger on the master table 2. Update trigger on the primary key columns of the master table. (Yes, I know you're not supposed to update the primary key columns. But I have never seen anyone enforce this rule.) 3. Insert trigger on the detail table. Yeeeeeoooowwwww! IMO As a matter of principle, if two tables are so closely related as to have integrity rules between them, they really belong in the same database. -- -- Jake (In pursuit of undomesticated aquatic avians) +----------------------------------------------------------+ |Aside from that, how did you enjoy the play, Mrs. Lincoln?| +----------------------------------------------------------+