adamc@709
|
1 table u : {C : int, D : int, E : int}
|
adamc@709
|
2 PRIMARY KEY C,
|
adamc@709
|
3 CONSTRAINT U UNIQUE (C, D)
|
adamc@709
|
4
|
adamc@704
|
5 table t : {A : int, B : int}
|
adamc@707
|
6 PRIMARY KEY B,
|
adamc@707
|
7
|
adamc@704
|
8 CONSTRAINT UniA UNIQUE A,
|
adamc@704
|
9 CONSTRAINT UniB UNIQUE B,
|
adamc@704
|
10 CONSTRAINT UniBoth UNIQUE (A, B),
|
adamc@704
|
11
|
adamc@704
|
12 CONSTRAINT UniAm UNIQUE {#A},
|
adamc@705
|
13 CONSTRAINT UniAm2 {unique [#A] [[]] ! !},
|
adamc@705
|
14 {{one_constraint [#UniAm3] (unique [#A] [[]] ! !)}},
|
adamc@705
|
15
|
adamc@705
|
16 CONSTRAINT UniBothm UNIQUE ({#A}, {#B}),
|
adamc@705
|
17 CONSTRAINT UniBothm2 {unique [#A] [[B = _]] ! !},
|
adamc@709
|
18 {{one_constraint [#UniBothm3] (unique [#A] [[B = _]] ! !)}},
|
adamc@709
|
19
|
adamc@709
|
20 CONSTRAINT ForA FOREIGN KEY A REFERENCES u (C),
|
adamc@709
|
21 CONSTRAINT ForAB FOREIGN KEY (A, B) REFERENCES u (D, C) ON DELETE CASCADE ON UPDATE RESTRICT,
|
adamc@709
|
22 CONSTRAINT ForBA FOREIGN KEY (A, B) REFERENCES u (C, D) ON UPDATE NO ACTION,
|
adamc@709
|
23
|
adamc@709
|
24 CONSTRAINT Self FOREIGN KEY B REFERENCES t (B)
|
adamc@709
|
25
|
adamc@709
|
26 table s : {B : option int}
|
adamc@709
|
27 CONSTRAINT UniB UNIQUE B
|
adamc@709
|
28
|
adamc@709
|
29 table s2 : {B : option int}
|
adamc@709
|
30 CONSTRAINT ForB FOREIGN KEY B REFERENCES s (B) ON DELETE SET NULL
|
adamc@704
|
31
|
adamc@704
|
32 fun main () : transaction page =
|
adamc@704
|
33 queryI (SELECT * FROM t) (fn _ => return ());
|
adamc@704
|
34 return <xml/>
|