Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1erV87-0000yv-SM for pgsql-general@arkaria.postgresql.org; Thu, 01 Mar 2018 20:48:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1erV86-0006Jk-Bj for pgsql-general@arkaria.postgresql.org; Thu, 01 Mar 2018 20:48:42 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1erV86-0006Jb-05 for pgsql-general@lists.postgresql.org; Thu, 01 Mar 2018 20:48:42 +0000 Received: from mail-qt0-x22d.google.com ([2607:f8b0:400d:c0d::22d]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1erV83-0003KT-BF for pgsql-general@lists.postgresql.org; Thu, 01 Mar 2018 20:48:40 +0000 Received: by mail-qt0-x22d.google.com with SMTP id g60so9327254qtd.11 for ; Thu, 01 Mar 2018 12:48:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=vf6+qt/eiddSJFOHFuUs0gqp0XkbZu5rAx7PFimTXko=; b=fS1WHk3nuX0QL3Z7A/sUFghoyXecueMLIryqM9Xr0bxh+3jxzWdAUHz/YQSLBMU6Zt gYF50yPuN5+h7mUQEkgqKAzrwD5/jtr2sniIBr61ZJK9xXjl50B9Sv/9WuZXhEPf++fC os7pSUe+q5q20QGrHHJ3lNrHE83gEdGXi+AY0uabM7TRugMWFkLxptpNIExlw5T+5GYD GuLOM9PiIb6ySLcxjiuTdnhUFaFcd6UOhCuvylRub/7MBOQgptqOBQuY7ezBlHd+WaaD vSuovd14GJ4vXOz8IBoIES237swbOrWbO51bL1wfyt+dJx6Gl+7zU8IauElHDxg+tT+r 3bkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=vf6+qt/eiddSJFOHFuUs0gqp0XkbZu5rAx7PFimTXko=; b=YfXfSRHiWQqa1bAPhgn4ONu6Ap+Zlrb5EnisaBXULmiZDKcGeFMDG6Hhf020Zrqzsq 3cW2Vqf4Mdm/Zx9q8DBvTk29TPMzbWnEPLdMBDP+6dyUsKxEZNezXbbvYc9pwgwCMr4q b6TX88Mo0VjvgBWmUhIARnU9ygOqmuZduT8XifYJ8N6o2nIadU9hPJTPQskSCZQblJpL RxfRIOQmrIiN5hbQMGNKhuTDgUG3nJ+pC46yxiLOMJ+GQTP9X99mPHi+mv1GUGskiwfD bimCPXiDrW5q2EeghxGr8pQCDqnZeMwEAdvlJVXR0anNrf/FN1Z2S9zRPMfzIYPDF/TQ 9n7Q== X-Gm-Message-State: AElRT7G7pPfErGXIpjLe0wKRuLFPl6Kc7K5e8keMqsvUEZXKFfH20iXe jnOspkmZVUZOTPcL4EdT6dT33mtJ X-Google-Smtp-Source: AG47ELujgLTbJmYI/uCHcZg9ie0n7laLOdMisABntJmi4KIhoMPVu/H/xm73ZnLqidHFfrxcQLW+2g== X-Received: by 10.200.43.78 with SMTP id 14mr5067755qtv.265.1519937318147; Thu, 01 Mar 2018 12:48:38 -0800 (PST) Received: from [192.168.1.250] (host63.190-229-77.telecom.net.ar. [190.229.77.63]) by smtp.gmail.com with ESMTPSA id c66sm3229212qke.42.2018.03.01.12.48.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Mar 2018 12:48:37 -0800 (PST) Subject: Re: Enforce primary key on every table during dev? To: pgsql-general@lists.postgresql.org References: <161e1761560-58a6-18e4b@webjas-vad211.srv.aolmail.net> <5a1870db-7018-fe15-ac60-ffe37abb7077@cox.net> <5da96fe6-666b-1107-ee76-b464417bd1b7@cox.net> <80d9a83d-fbf4-e4fa-9ccf-9272a074c50d@cox.net> From: marcelo Message-ID: <6057ff27-b072-2827-1ca5-943ca423026f@gmail.com> Date: Thu, 1 Mar 2018 17:48:34 -0300 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------0AAB5E96A51140441BCC9927" Content-Language: en-US X-Antivirus: Avast (VPS 180228-6, 28/02/2018), Outbound message X-Antivirus-Status: Clean List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------0AAB5E96A51140441BCC9927 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 01/03/2018 17:32 , David G. Johnston wrote: > On Thu, Mar 1, 2018 at 1:24 PM, Ron Johnson >wrote: > > Why have the overhead of a second unique index?  If it's "ease of > joins", then I agree with Francisco Olarte and use the business > logic keys in your joins even though it's a bit of extra work. > > > ​The strongest case, for me, when a surrogate key is highly desirable > is when there is no truly natural key and the best key for the model > is potentially alterable. Specific, the "name" of something.  If I add > myself to a database and make name unique, so David Johnston, then > someone else comes along with the same name and now I want to add the > new person as, say David A. Johnston AND rename my existing record to > David G. Johnston.  I keep the needed uniqueness ​and don't need to > cobble together other data elements.  Or, if I were to use email > address as the key the same physical entity can now change their > address without me having to cascade update all FK instances too. > Avoiding the FK cascade when enforcing a non-ideal PK is a major good > reason to assign a surrogate. > > David J. > I suffered myself what David said as an example... --- El software de antivirus Avast ha analizado este correo electrónico en busca de virus. https://www.avast.com/antivirus --------------0AAB5E96A51140441BCC9927 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

On 01/03/2018 17:32 , David G. Johnston wrote:
On Thu, Mar 1, 2018 at 1:24 PM, Ron Johnson <ron.l.johnson@cox.net> wrote:
Why have the overhead of a second unique index?  If it's "ease of joins", then I agree with Francisco Olarte and use the business logic keys in your joins even though it's a bit of extra work.

​The strongest case, for me, when a surrogate key is highly desirable is when there is no truly natural key and the best key for the model is potentially alterable.  Specific, the "name" of something.  If I add myself to a database and make name unique, so David Johnston, then someone else comes along with the same name and now I want to add the new person as, say David A. Johnston AND rename my existing record to David G. Johnston.  I keep the needed uniqueness ​and don't need to cobble together other data elements.  Or, if I were to use email address as the key the same physical entity can now change their address without me having to cascade update all FK instances too.  Avoiding the FK cascade when enforcing a non-ideal PK is a major good reason to assign a surrogate.

David J.

I suffered myself what David said as an example...



Avast logo

El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
www.avast.com


--------------0AAB5E96A51140441BCC9927--