Re: Enforce primary key on every table during dev?

From: Tim Cross <theophilusx(at)gmail(dot)com>
To: Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Enforce primary key on every table during dev?
Date: 2018-03-01 21:06:42
Message-ID: 87tvtzpkt9.fsf@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2018-03-01 21:14:38 Re: Enforce primary key on every table during dev?
Previous Message Ron Johnson 2018-03-01 21:03:33 Re: Enforce primary key on every table during dev?