Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.sqlserver.programming > #31270

Re: Unique Constraint Based on Dual GUID

X-Received by 10.70.41.102 with SMTP id e6mr27055563pdl.10.1439332219311; Tue, 11 Aug 2015 15:30:19 -0700 (PDT)
X-Received by 10.182.116.197 with SMTP id jy5mr136238obb.24.1439332219216; Tue, 11 Aug 2015 15:30:19 -0700 (PDT)
Path csiph.com!xmission!news.glorb.com!se8no2190908igc.0!news-out.google.com!nt1ni5857igb.0!nntp.google.com!se8no2190897igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups microsoft.public.sqlserver.programming
Date Tue, 11 Aug 2015 15:30:18 -0700 (PDT)
In-Reply-To <mqbsbp$9va$1@dont-email.me>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=2602:306:bcf4:c240:4d2:5906:583:81f3; posting-account=eTE9_AoAAAD1dS9O9Ccywd_vfKFzS40A
NNTP-Posting-Host 2602:306:bcf4:c240:4d2:5906:583:81f3
References <mqbsbp$9va$1@dont-email.me>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <a6978bfd-b275-468c-9c7d-a4a64b2e9f4a@googlegroups.com> (permalink)
Subject Re: Unique Constraint Based on Dual GUID
From --CELKO-- <jcelko212@earthlink.net>
Injection-Date Tue, 11 Aug 2015 22:30:19 +0000
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Xref csiph.com microsoft.public.sqlserver.programming:31270

Show key headers only | View raw


>> I have a table with a GUID as PK (created via NewId()) <<

The purpose of a GUID is to locate a GLOBAL resource, not to serve as an attribute inside the schema. Since it is not an attribute of anything, it cannot be a key by definition. Keys are not created in RDBMS; they are discovered in the data itself.  

What you are doing is trying to mimic a 1970's network database with fake pointer chains. 

>> I also have a table to indicate links [sic] between records [sic] in this table, with a dual [sic: compound?] PK of GUIDS (for the two records [sic] that connect [sic: we reference] to each other)<<

In RDBMS, we have references, not links. That is more terminology from pointer chains. Rows are nothing like records. Records are physical, have no constraints, etc. Rows are logical and might not be physical at all, have DRI and CHECK() constraints, etc. Event eh term "connect" is a pointer chain term! 

>> Putting a constraint on these two fields [sic] will limit it to only one combination of the two fields [sic], i.e., a link [sic] of A to B, but I also need to ensure that the link [sic] is not duplicated as B to A - the link [sic] is non-directional. <<

Again, fields are nothing like columns. It is that "physical versus logical" concept again. There is no direction in SQL; it is based on sets and not pointer chains or vectors. 

In SQL, we would have UNIQUE (a, b) and CHECK (a < b) instead. 

>>My idea was to include a calculated field [sic] of the two GUIDs XORed together, and place a constraint on this calculated field [sic]. Can anyone see any issues with this idea? <<

This is even bad from a network database model. The first rule was never do pointer arithmetic; always let the DB handle housekeeping and pointer allocations.  

Everything you are doing is completely wrong, based on a lack of any understanding of RDBMS. Will your boss pay for an intro course of some kind? I miss the 1970's, too, but not IMS, IDMS, TOTAL, Image/300 and all the other zombie products you are trying to revive :) 

Back to microsoft.public.sqlserver.programming | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Unique Constraint Based on Dual GUID Michael Cole <invalid@invalid.com> - 2015-08-11 14:07 +1000
  Re: Unique Constraint Based on Dual GUID Erland Sommarskog <esquel@sommarskog.se> - 2015-08-11 21:35 +0200
  Re: Unique Constraint Based on Dual GUID rpresser <rpresser@gmail.com> - 2015-08-11 12:46 -0700
  Re: Unique Constraint Based on Dual GUID --CELKO-- <jcelko212@earthlink.net> - 2015-08-11 15:30 -0700
    Re: Unique Constraint Based on Dual GUID rpresser <rpresser@gmail.com> - 2015-08-11 20:13 -0700
  Re: Unique Constraint Based on Dual GUID --CELKO-- <jcelko212@earthlink.net> - 2015-08-12 18:26 -0700
    Re: Unique Constraint Based on Dual GUID Michael Cole <invalid@invalid.com> - 2015-08-13 11:59 +1000

csiph-web