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