comparison tests/cst.ur @ 712:915ec60592d4

More flexible foreign keying
author Adam Chlipala <adamc@hcoop.net>
date Thu, 09 Apr 2009 13:59:34 -0400
parents 0406e9cccb72
children baaae037e7f6
comparison
equal deleted inserted replaced
711:7292bcb7c02d 712:915ec60592d4
1 table u : {C : int, D : int, E : int} 1 table u : {C : int, D : int, E : option int}
2 PRIMARY KEY C, 2 PRIMARY KEY C,
3 CONSTRAINT U UNIQUE (C, D) 3 CONSTRAINT U UNIQUE (C, D),
4 CONSTRAINT U2 UNIQUE E
4 5
5 table t : {A : int, B : int} 6 table t : {A : int, B : int, C : option int}
6 PRIMARY KEY B, 7 PRIMARY KEY B,
7 8
8 CONSTRAINT UniA UNIQUE A, 9 CONSTRAINT UniA UNIQUE A,
9 CONSTRAINT UniB UNIQUE B, 10 CONSTRAINT UniB UNIQUE B,
10 CONSTRAINT UniBoth UNIQUE (A, B), 11 CONSTRAINT UniBoth UNIQUE (A, B),
18 {{one_constraint [#UniBothm3] (unique [#A] [[B = _]] ! !)}}, 19 {{one_constraint [#UniBothm3] (unique [#A] [[B = _]] ! !)}},
19 20
20 CONSTRAINT ForA FOREIGN KEY A REFERENCES u (C), 21 CONSTRAINT ForA FOREIGN KEY A REFERENCES u (C),
21 CONSTRAINT ForAB FOREIGN KEY (A, B) REFERENCES u (D, C) ON DELETE CASCADE ON UPDATE RESTRICT, 22 CONSTRAINT ForAB FOREIGN KEY (A, B) REFERENCES u (D, C) ON DELETE CASCADE ON UPDATE RESTRICT,
22 CONSTRAINT ForBA FOREIGN KEY (A, B) REFERENCES u (C, D) ON UPDATE NO ACTION, 23 CONSTRAINT ForBA FOREIGN KEY (A, B) REFERENCES u (C, D) ON UPDATE NO ACTION,
24 CONSTRAINT ForB FOREIGN KEY B REFERENCES u (E),
25 CONSTRAINT ForC FOREIGN KEY C REFERENCES u (C)
23 26
24 CONSTRAINT Self FOREIGN KEY B REFERENCES t (B) 27 (*CONSTRAINT Self FOREIGN KEY B REFERENCES t (B)*)
25 28
26 table s : {B : option int} 29 table s : {B : option int}
27 CONSTRAINT UniB UNIQUE B 30 CONSTRAINT UniB UNIQUE B
28 31
29 table s2 : {B : option int} 32 table s2 : {B : option int}