Re: Enforce primary key on every table during dev?

From: Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net>
To: marcelo <marcelo(dot)nicolet(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Enforce primary key on every table during dev?
Date: 2018-03-01 20:55:57
Message-ID: 3dfe103d-b6fe-6613-f9f7-31eab0363c26@cox.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 03/01/2018 02:32 PM, marcelo wrote:
>
>
> On 01/03/2018 17:21 , Ron Johnson wrote:
>> 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.
>>>> bl
>>>> 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.
>>
>>
> So, you are fully convinced that there´s no bug free software... Same as I
> (and you) can code following the business rules, you (and me) can design
> unit tests not from "imagination" but from same rules.
> Moreover: you can have a surrogate key (to speedup foreign keys) and
> simultaneously put a unique constraint on the columns requiring it. What´s
> the question?

Implementing tests to cover edge cases is much harder than implementing
business rules in natural (and foreign) keys.

--
Angular momentum makes the world go 'round.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2018-03-01 20:59:25 Re: Enforce primary key on every table during dev?
Previous Message marcelo 2018-03-01 20:48:34 Re: Enforce primary key on every table during dev?