By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE test (
IsUnlisted BOOLEAN,
IsPrivate BOOLEAN,
CHECK (IsUnlisted <> TRUE OR IsPrivate <=> TRUE)
);
INSERT IGNORE INTO test VALUES
(NULL, NULL),
(NULL, TRUE),
(NULL, FALSE),
(TRUE, NULL),
(TRUE, TRUE),
(TRUE, FALSE),
(FALSE, NULL),
(FALSE, TRUE),
(FALSE, FALSE);
Records: 7 Duplicates: 0 Warnings: 2
SHOW WARNINGS;
Level | Code | Message |
---|---|---|
Warning | 4025 | CONSTRAINT `CONSTRAINT_1` failed for `fiddle`.`test` |
Warning | 4025 | CONSTRAINT `CONSTRAINT_1` failed for `fiddle`.`test` |
SELECT * FROM test;
IsUnlisted | IsPrivate |
---|---|
null | null |
null | 1 |
null | 0 |
1 | 1 |
0 | null |
0 | 1 |
0 | 0 |