SQL 证明候选键约束在 R(ABCD) 中成立的语句

SQL statement to prove that a candidate key constraint holds in a R(ABCD)

如何编写 SQL 语句来证明候选键 ACD 在给定与属性 ABCD 和函数依赖关系 A → B 的关系的情况下成立? 我知道这里有类似的东西:SQL statement to prove that A->B in a R(ABCD), 但无法弄清楚如何编写此约束的查询。

\i tmp.sql
create table abcd(
        a integer not null
        ,b integer not null
        ,c integer not null
        ,d integer not null
        -- , PRIMARY KEY (a,b,c,d)
        );
INSERT INTO abcd(a,b,c,d)
select (s/4)%4, (s/4)%2,(s/2)%2,s%2
from generate_series(0,15) s
        ;
select *from abcd;

ALTER TABLE abcd ADD UNIQUE (a,b,c,d); --succeeds
ALTER TABLE abcd ADD UNIQUE (a,c,d); --succeeds
ALTER TABLE abcd ADD UNIQUE (b,c,d); --fails

结果:


DROP SCHEMA
CREATE SCHEMA
SET
CREATE TABLE
INSERT 0 16
 a | b | c | d 
---+---+---+---
 0 | 0 | 0 | 0
 0 | 0 | 0 | 1
 0 | 0 | 1 | 0
 0 | 0 | 1 | 1
 1 | 1 | 0 | 0
 1 | 1 | 0 | 1
 1 | 1 | 1 | 0
 1 | 1 | 1 | 1
 2 | 0 | 0 | 0
 2 | 0 | 0 | 1
 2 | 0 | 1 | 0
 2 | 0 | 1 | 1
 3 | 1 | 0 | 0
 3 | 1 | 0 | 1
 3 | 1 | 1 | 0
 3 | 1 | 1 | 1
(16 rows)

ALTER TABLE
ALTER TABLE
ERROR:  could not create unique index "abcd_b_c_d_key"
DETAIL:  Key (b, c, d)=(0, 0, 0) is duplicated.

B在这里在功能上依赖于A,但是多个A可以指向相同的B值.

顺便说一句:IMO 不可能 证明 SQL 中的某些东西(这取决于 table(s) 中的当前数据),但是可能 拒绝 它。 (通过编写示例)