pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tim Cross <theophilusx@gmail.com>
To: Ron Johnson <ron.l.johnson@cox.net>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Enforce primary key on every table during dev?
Date: Fri, 02 Mar 2018 08:06:42 +1100
Message-ID: <87tvtzpkt9.fsf@gmail.com> (raw)
In-Reply-To: <796df4ca-62b8-c574-6b1b-742aa401250a@cox.net>
References: <C9EFC294-83B5-41FD-9542-60FDBB2588C6@gmail.com>
	<161e1761560-58a6-18e4b@webjas-vad211.srv.aolmail.net>
	<5a1870db-7018-fe15-ac60-ffe37abb7077@cox.net>
	<GiZ41x00v1DF5NZ01iZ5Ez>
	<Gk991x09V1DF5NZ01k9BG0>
	<796df4ca-62b8-c574-6b1b-742aa401250a@cox.net>


Ron Johnson <ron.l.johnson@cox.net> 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




view thread (59+ messages)  latest in thread

Message-ID: <87tvtzpkt9.fsf@gmail.com>
Permalink:  ../87tvtzpkt9.fsf@gmail.com/
Also on:    postgresql.org/message-id/87tvtzpkt9.fsf@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: theophilusx@gmail.com, ron.l.johnson@cox.net
  Subject: Re: Enforce primary key on every table during dev?
  In-Reply-To: <87tvtzpkt9.fsf@gmail.com>
  References: <C9EFC294-83B5-41FD-9542-60FDBB2588C6@gmail.com> <161e1761560-58a6-18e4b@webjas-vad211.srv.aolmail.net> <5a1870db-7018-fe15-ac60-ffe37abb7077@cox.net> <GiZ41x00v1DF5NZ01iZ5Ez> <Gk991x09V1DF5NZ01k9BG0> <796df4ca-62b8-c574-6b1b-742aa401250a@cox.net> <87tvtzpkt9.fsf@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox