Re: Surrogate primary key plus unique constraint vs. natural primary key: data integrity?
From: <compdb_at_hotmail.com>
Date: Wed, 20 Mar 2013 11:41:14 -0700 (PDT)
Message-ID: <2f20dd7d-ee72-4b58-8a84-5cc4d581283e_at_googlegroups.com>
Date: Wed, 20 Mar 2013 11:41:14 -0700 (PDT)
Message-ID: <2f20dd7d-ee72-4b58-8a84-5cc4d581283e_at_googlegroups.com>
On Wednesday, March 20, 2013 11:31:56 AM UTC-7, com..._at_hotmail.com wrote:
> Eg. Suppose you have S{a,...} and T{x,...} with constraint (among others) S(a,...) IMPLIES T(f(a),...). Ie for row s in S EXISTS t in T [f(s.a)=t.x]. You add surrogate k as key in S and fk in T to get S{k,a,...} and T{k,x,...}. Then the new constraint is S(k,a,...) IMPLIES T(k,f(a),...). Ie for row s in S EXISTS t in T [f(s.a)=t.x AND s.k=t.k]. So in the SQL style you have to add the "AND s.k=t.k". This is independent of whether S origninally had any fk into T.
I meant: add surrogate k as key in T (target) and fk in S (source). (This is reflected in the rest.)
philip Received on Wed Mar 20 2013 - 19:41:14 CET