Re: partial "on-delete set null" constraint

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: Rafal Pietrak <rafal(at)ztk-rp(dot)eu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: partial "on-delete set null" constraint
Date: 2015-01-03 18:08:00
Message-ID: 65343F13-8D73-48DA-BFC7-5653630FAD7A@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> On 03 Jan 2015, at 18:05, Rafal Pietrak <rafal(at)ztk-rp(dot)eu> wrote:
> W dniu 03.01.2015 o 16:48, Alban Hertroys pisze:
>>> On 03 Jan 2015, at 15:20, Rafal Pietrak <rafal(at)ztk-rp(dot)eu> wrote:
>>>
> [-------------------------]
>>> Yes. This is precisely the "semantics" I'm trying to put into the schema: after a username is "released" from service, all it's messages become "from unknown user".... unless thoroughly investigated :)
>> It also makes a foreign key reference unusable: There is no unique parent record to match it to, so what exactly are you referencing?
>
> Nothing.
>
> That's precisely my point here. I'd like to have "objects" in mailboxes table left "hanging around" after it's "disconnected" from service. FK acting like a power cord of a vacuum cleaner: when in service: hooked into the wall; after that vacuum cleaner stays there, only disconnected (and the socket can be used by others).

Then you should make that reference to maildomains(domain) also NULLable. Otherwise you aren’t referencing ‘nothing’, but possibly every user in the domain (we won’t know, since NULL is ‘unknown’ after all and that could match anything).

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rafal Pietrak 2015-01-03 22:14:36 Re: partial "on-delete set null" constraint
Previous Message Alban Hertroys 2015-01-03 18:04:02 Re: partial "on-delete set null" constraint