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 1erVPm-0002YC-HI for pgsql-general@arkaria.postgresql.org; Thu, 01 Mar 2018 21:06:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1erVPl-0000ll-Ld for pgsql-general@arkaria.postgresql.org; Thu, 01 Mar 2018 21:06:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1erVPl-0000la-Ao for pgsql-general@lists.postgresql.org; Thu, 01 Mar 2018 21:06:57 +0000 Received: from mail-pg0-x22e.google.com ([2607:f8b0:400e:c05::22e]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1erVPe-0003hy-6h for pgsql-general@lists.postgresql.org; Thu, 01 Mar 2018 21:06:56 +0000 Received: by mail-pg0-x22e.google.com with SMTP id y26so2839866pgv.4 for ; Thu, 01 Mar 2018 13:06:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=K34DgX+xllGehkdmiCABQ2QuPgLs3/MeX9oTe8oLNZw=; b=lrj2rBGF9+3wUbdLkZVC4ad5mSIp4Ju04TyJ722JoFDtsga5EzWpEn81rfTpoOmZ5T Fi2YaCde5EzvBHPz50HjPjcNeG/nKJvWgXaHA+hFSCtiPZ71vLyLba5lnnhLjIE9pP5p rMeMasJzQM/I39RQID3bgQ4oScEMmVKNk6qGWEcM3X0gxV8cr5rwumkcZ9TwzxpgIabs QZvuYy65cMVWZd7in9gwZukBCnpVJ30by3k6POpeH/YKnPWbUnm2GrUY/4RjRQPBtjAk KSgRgB96YAOn/sKgTlL1N+VMsYtRAQFDrI8wGju6Il+JS2bK2nFIss5CSuuJUH1ynC0S +Gcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=K34DgX+xllGehkdmiCABQ2QuPgLs3/MeX9oTe8oLNZw=; b=t6fneSH1x/9P/V8pHLC8ixjQygAo47BKXnaVfh0ilnG9mBzWv60RuKr7boTAhwH4+M oXX50MmIBtD1PGifEQqluFzD1BPDKIrtaLnIYjD2YJLS3CNUiYG7Jo6lvFBjm1NR+GRW XrhLErYGkVWZrOpQ1JqpDcduQLQfVCLASfvP3nJ1HcTB/YCA+Y3zM8oYS64G1xJyVXvD FSzpVfRNTmAws7pyacUpVr/26MVImH1WNSP7puTk/plh+rGnveD4p/JhnMtQXaznxZRS XmuEx5lPILc7xWUwHfWk4L0upxuwkqkmNcCG/RKhW2G/agDAM+GxLZh5O+zkpcSPEnY1 gIIQ== X-Gm-Message-State: APf1xPC44gqhiirPOkDEYSJwLb1bTjn5MfpXBmWcpE1AlM/XHeQJKZ5A 0R3I3OhyUX45/OEw0SrhxD+Odr6L X-Google-Smtp-Source: AG47ELuOzpTsm7PwJPQALRf32mlyBk2RBElycgIXsBF2B5KnsRvGVsgTtFQVNfnNOfZ7REwg3K7dBA== X-Received: by 10.98.233.3 with SMTP id j3mr3330200pfh.38.1519938407751; Thu, 01 Mar 2018 13:06:47 -0800 (PST) Received: from tim-desktop (2001-44b8-31f2-bb00-1c8f-7cb5-4997-84f1.static.ipv6.internode.on.net. [2001:44b8:31f2:bb00:1c8f:7cb5:4997:84f1]) by smtp.gmail.com with ESMTPSA id q15sm7287625pgv.38.2018.03.01.13.06.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Mar 2018 13:06:47 -0800 (PST) References: <161e1761560-58a6-18e4b@webjas-vad211.srv.aolmail.net> <5a1870db-7018-fe15-ac60-ffe37abb7077@cox.net> <796df4ca-62b8-c574-6b1b-742aa401250a@cox.net> User-agent: mu4e 0.9.18; emacs 25.3.1 From: Tim Cross To: Ron Johnson Cc: pgsql-general@lists.postgresql.org Subject: Re: Enforce primary key on every table during dev? In-reply-to: <796df4ca-62b8-c574-6b1b-742aa401250a@cox.net> Date: Fri, 02 Mar 2018 08:06:42 +1100 Message-ID: <87tvtzpkt9.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Ron Johnson writes: > On 03/01/2018 02:08 PM, marcelo wrote: >> >> >> On 01/03/2018 16:42 , Ron Johnson wrote: >>> On 03/01/2018 01:11 PM, marcelo wrote: >>>> >>>> On 01/03/2018 16:00 , Ron Johnson wrote: >>> [snip] >>>>> If your only unique index is a synthetic key, then you can insert the >>>>> same "business data" multiple times with different synthetic keys. >>>>> >>>>> >>>>> -- >>>>> Angular momentum makes the world go 'round. >>>> IMHO, business logic can and must preclude "garbage insertion". Except >>>> you are inserting data directly to database using SQL, any n-tier >>>> architecture will be checking data validity. >>> >>> Any n-tier architecture that's bug-free. >>> >> Do you know about unit testing? > > Way Back When Dinosaurs Still Roamed The Earth and I first learned the > trade, the focus was on proper design instead of throwing crud against the > wall and hoping tests caught any bugs. Because, of course, unit tests are > only as good as you imagination in devising tests. +1. And a good test of your underlying data model is whether you can identify a natural primary key. If you can't, chances are your model is immature/flawed and needs more analysis. -- Tim Cross