summaryrefslogtreecommitdiff
path: root/tests/cst.ur
blob: cbaa36ed232d71b36af690a3e82c1d48bc60de4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
table u : {C : int, D : int, E : option int}
  PRIMARY KEY C,
  CONSTRAINT U UNIQUE (C, D),
  CONSTRAINT U2 UNIQUE E

table t : {A : int, B : int, C : option int}
  PRIMARY KEY B,

  CONSTRAINT UniA UNIQUE A,
  CONSTRAINT UniB UNIQUE B,
  CONSTRAINT UniBoth UNIQUE (A, B),

  CONSTRAINT UniAm UNIQUE {#A},
  CONSTRAINT UniAm2 {unique [#A] [[]] ! !},
  {{one_constraint [#UniAm3] (unique [#A] [[]] ! !)}},

  CONSTRAINT UniBothm UNIQUE ({#A}, {#B}),
  CONSTRAINT UniBothm2 {unique [#A] [[B = _]] ! !},
  {{one_constraint [#UniBothm3] (unique [#A] [[B = _]] ! !)}},

  CONSTRAINT ForA FOREIGN KEY A REFERENCES u (C),
  CONSTRAINT ForAB FOREIGN KEY (A, B) REFERENCES u (D, C) ON DELETE CASCADE ON UPDATE RESTRICT,
  CONSTRAINT ForBA FOREIGN KEY (A, B) REFERENCES u (C, D) ON UPDATE NO ACTION,
  CONSTRAINT ForB FOREIGN KEY B REFERENCES u (E),
  CONSTRAINT ForC FOREIGN KEY C REFERENCES u (C)

  (*CONSTRAINT Self FOREIGN KEY B REFERENCES t (B)*)

table s : {B : option int}
  CONSTRAINT UniB UNIQUE B

table s2 : {B : option int}
  CONSTRAINT ForB FOREIGN KEY B REFERENCES s (B) ON DELETE SET NULL

fun main () : transaction page =
    queryI (SELECT * FROM t) (fn _ => return ());
    return <xml/>