1
|
CREATE TABLE player
|
2
|
(
|
3
|
username CHAR(20) not null,
|
4
|
firstName CHAR(20) not null,
|
5
|
lastName CHAR(20) not null,
|
6
|
tokens BIGINT not null default 0,
|
7
|
password CHAR(20) not null,
|
8
|
primary key (username)
|
9
|
);
|
10
|
|
11
|
CREATE TABLE bet
|
12
|
(
|
13
|
id BIGINT not null,
|
14
|
type ENUM ('winner', 'podium') not null,
|
15
|
competition CHAR(50) not null REFERENCES competition (name) ,
|
16
|
player CHAR(20) not null REFERENCES player (username),
|
17
|
amount BIGINT not null CHECK >0,
|
18
|
successful BIT default Null,
|
19
|
first BIGINT not null REFERENCES participant (id),
|
20
|
second BIGINT REFERENCES participant (id),
|
21
|
third BIGINT REFERENCES participant (id),
|
22
|
primary key (id)
|
23
|
);
|
24
|
|
25
|
|
26
|
|
27
|
____________________________________________________
|
28
|
|
29
|
|
30
|
input
|
31
|
CREATE TABLE player
|
32
|
(
|
33
|
username CHAR(20) not null,
|
34
|
firstName CHAR(20) not null,
|
35
|
lastName CHAR(20) not null,
|
36
|
tokens BIGINT not null,
|
37
|
password CHAR(20) not null,
|
38
|
primary key (username)
|
39
|
);
|
40
|
|
41
|
CREATE TYPE betType AS ENUM ('winner', 'podium');
|
42
|
|
43
|
|
44
|
CREATE TABLE bet
|
45
|
(
|
46
|
id BIGINT not null,
|
47
|
type betType not null,
|
48
|
competition CHAR(50) not null,
|
49
|
player CHAR(20) not null,
|
50
|
amount BIGINT not null,
|
51
|
successful BIT default null,
|
52
|
first BIGINT not null,
|
53
|
second BIGINT ,
|
54
|
third BIGINT ,
|
55
|
primary key (id)
|
56
|
);
|
57
|
|
58
|
|
59
|
SELECT * FROM player;
|
60
|
|
61
|
|