Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iZ7qD-0004yb-AB for pgsql-general@arkaria.postgresql.org; Mon, 25 Nov 2019 06:27:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iZ7q9-0005DZ-CW for pgsql-general@arkaria.postgresql.org; Mon, 25 Nov 2019 06:27:17 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1iZ7q8-00058S-U4 for pgsql-general@lists.postgresql.org; Mon, 25 Nov 2019 06:27:17 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iZ7q5-0006oH-Hj for pgsql-general@lists.postgresql.org; Mon, 25 Nov 2019 06:27:16 +0000 Received: by mail-lf1-x135.google.com with SMTP id f18so10022897lfj.6 for ; Sun, 24 Nov 2019 22:27:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=Eb5zbW/AhTnEX165WRfCN5UEQIHpmq6tbgoUnuPYDpA=; b=aByPp6poFhABQg/gNJ5eP9OvCZjj8DBxD8OjZSfWj2QbQZRWo2Vc2mK3d++jumuirB +VMdYIjJovUcHmHkz6p9+lse4uK3YXdGklGZ5BcfVdJmHgarlhwdcGFljAafPPNNgprM bfTG/P5fk5pnYc96IQNa71w83WX+UeIcQhGxYP5iM1XiOPNuCf1/gblKeUTe02oS+3nu YlLNPaKgIMzGnQeLctSDhHmdcKz/LN51fLVBZBY2EU3vrS37A6+dusGrggJYQkcZD3q1 aAUoXJAllKUBak9QY6YeWBzg+ljJ1OTvYCCVUfQddgyssjViBNfiJ9a5O1Ldf2C/nQlP P5dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Eb5zbW/AhTnEX165WRfCN5UEQIHpmq6tbgoUnuPYDpA=; b=SVNVXUL+daIBxfPUa3ND/NA+IrxtRTGiA9ozLPOrrQOwitF6KulsHjY5CBmR/eiuuA 3p6nLimdTYbzD/JKQ+ojT1GKv/wpKcLlFpWwYcxFfeLjcPpJuLTSCWUi/rq1KxTwMfiW JggL8zqANfXGSBZBa6kbvPdKf1t0CTy4fdXe/Fhuha8FqOsk4CeoG4SGRvuDPiWJSJYc v0wkytKuQrQ6YBIWhV2T3OoO/G67bc97ZPh5cSrAshDd8gCOk7KHdTIi6Fl9St/HZQoz /ZzbQWJTCufehcd3lq3QJRKJPXTR8f+5MoNpeATUChBwssa7QEzdGLHdjozNYb6lR1Zd VDcA== X-Gm-Message-State: APjAAAU/m5yi9QhXry7VJc31udB5l5PN5dIZzzQjIasiLBExzTEdQjgX QE5RBkSJ266q/l+G/eWvwYsEhpxF X-Google-Smtp-Source: APXvYqyTL7ZANXEB890LbU/b1EouQADtDVPscVMt83hugAxRgll/H+Fv/DkWPQ1cZbooIctVRTbJYQ== X-Received: by 2002:a19:c697:: with SMTP id w145mr15288636lff.54.1574663230994; Sun, 24 Nov 2019 22:27:10 -0800 (PST) Received: from 127.0.0.1 ([77.89.245.35]) by smtp.googlemail.com with ESMTPSA id y9sm2967828lfl.16.2019.11.24.22.27.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Nov 2019 22:27:10 -0800 (PST) Subject: Re: Constants in the foreighn key constraints To: pgsql-general@lists.postgresql.org References: From: Mimiko Message-ID: Date: Mon, 25 Nov 2019 08:27:08 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk As a workaround, create a table with only one column and one value = `false` and foreign to it. On 22.11.2019 16:32, aleksey ksenzov wrote: > Latest time we faced several issues which wouldn't arise provided we have possibility to use constants in foreign key constraints. > brief example where it would be helpful: > > table_a > ( id uuid, > parent_id uuid, > is_deleted boolean > ) > having possibility of FK (parent_id, false) to (id, is_deleted) > would disallow setting parent record deleted flag to true if they have children, or insert record with is_deleted = true parent.