-
Notifications
You must be signed in to change notification settings - Fork 0
/
alter.sql
159 lines (151 loc) · 3.8 KB
/
alter.sql
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
drop table cards;
drop table decks;
drop table decks_cards;
drop table hands;
drop table tricks;
drop table draws;
drop table games;
drop table players;
create table cards (
id integer primary key,
color TEXT not null,
value TEXT not null,
image TEXT not null
);
create table decks (
id integer primary key,
description TEXT,
cardsPerPlayer INT
);
create table decks_cards (
id integer primary key,
deckId int,
cardId int,
rank int,
points int,
trump boolean
);
create table hands (
id integer primary key,
gameId int,
playerId int,
cardId int,
ordr int
);
create table draws (
id integer primary key,
gameId int,
round int,
position int,
playerId int,
cardId int,
winner int, -- -> player.id
handId int -- -> from which handId was that draw
);
create table games (
id integer primary key,
gamedate TEXT,
giver int, -- -> player.id
tableId int -- -> table.id
);
create table players (
id integer primary key,
email TEXT,
nickname TEXT,
password TEXT,
currentTable int,
inCurrentRound int,
);
create table tables (
id integer primary key,
description TEXT,
createdate TEXT,
deckId int
);
create view v_hands as
select h.gameId, h.playerId, p.nickname, c.color, c.value, h.cardId
from cards c join hands h on h.cardId=c.id
join players p on p.id=h.playerId
order by p.id, h.ordr;
insert into cards (color, value, image)
values ('Karo', '9', 'DIAMOND-9.svg'),
('Karo', '10', 'DIAMOND-10.svg'),
('Karo', 'Bube', 'DIAMOND-11-JACK.svg'),
('Karo', 'Dame', 'DIAMOND-12-QUEEN.svg'),
('Karo', 'König', 'DIAMOND-13-KING.svg'),
('Karo', 'Ass', 'DIAMOND-1.svg');
insert into cards (color, value, image)
select 'Herz', value, replace(image,'DIAMOND','HEART') from cards where color='Karo';
insert into cards (color, value, image)
select 'Pik', value, replace(image,'DIAMOND','SPADE') from cards where color='Karo';
insert into cards (color, value, image)
select 'Kreuz', value, replace(image,'DIAMOND','CLUB') from cards where color='Karo';
insert into decks (description, cardsPerPlayer)
values ('Doppelkopf', 12);
insert into decks_cards (deckId, cardId, rank, points, trump)
values
--karo 9,10,B,D,K,A
(1, 1, 1, 0, 1),
(1, 2, 3, 10, 1),
(1, 3, 5, 2, 1),
(1, 4, 9, 3, 1),
(1, 5, 2, 4, 1),
(1, 6, 4, 11, 1),
(1, 1, 1, 0, 1),
(1, 2, 3, 10, 1),
(1, 3, 5, 2, 1),
(1, 4, 9, 3, 1),
(1, 5, 2, 4, 1),
(1, 6, 4, 11, 1),
--herz 9,10,B,D,K,A
(1, 7, 1, 0, 0),
(1, 8, 13, 10, 1),
(1, 9, 6, 2, 1),
(1, 10, 10, 3, 1),
(1, 11, 2, 4, 0),
(1, 12, 4, 11, 0),
(1, 7, 1, 0, 0),
(1, 8, 13, 10, 1),
(1, 9, 6, 2, 1),
(1, 10, 10, 3, 1),
(1, 11, 2, 4, 0),
(1, 12, 4, 11, 0),
--pik 9,10,B,D,K,A
(1, 13, 1, 0, 0),
(1, 14, 3, 10, 0),
(1, 15, 7, 2, 1),
(1, 16, 11, 3, 1),
(1, 17, 2, 4, 0),
(1, 18, 4, 11, 0),
(1, 13, 1, 0, 0),
(1, 14, 3, 10, 0),
(1, 15, 7, 2, 1),
(1, 16, 11, 3, 1),
(1, 17, 2, 4, 0),
(1, 18, 4, 11, 0),
--kreuz 9,10,B,D,K,A
(1, 19, 1, 0, 0),
(1, 20, 3, 10, 0),
(1, 21, 8, 2, 1),
(1, 22, 12, 3, 1),
(1, 23, 2, 4, 0),
(1, 24, 4, 11, 0),
(1, 19, 1, 0, 0),
(1, 20, 3, 10, 0),
(1, 21, 8, 2, 1),
(1, 22, 12, 3, 1),
(1, 23, 2, 4, 0),
(1, 24, 4, 11, 0);
-- Doppelkopfspiel:
--select c.color, c.value, d.points, d.trump
--from cards c join decks_cards d on d.cardId=c.id
--order by trump asc, rank ASC
insert into players (email, nickname, password) VALUES
('alexschmitt@arcor.de','Lexi','a307fa10fd93e16a0f62f1bf4c2c33c30738074b0546e0ca7ed5a6d07a7ee28b'),
('Christian','Christian','a307fa10fd93e16a0f62f1bf4c2c33c30738074b0546e0ca7ed5a6d07a7ee28b'),
('Hans-Joachim','Hans-J.','a307fa10fd93e16a0f62f1bf4c2c33c30738074b0546e0ca7ed5a6d07a7ee28b'),
('Frank','Frank','a307fa10fd93e16a0f62f1bf4c2c33c30738074b0546e0ca7ed5a6d07a7ee28b'),
('Jochen','Jochen','a307fa10fd93e16a0f62f1bf4c2c33c30738074b0546e0ca7ed5a6d07a7ee28b'),
('Stephan Horn','Stephan H.','a307fa10fd93e16a0f62f1bf4c2c33c30738074b0546e0ca7ed5a6d07a7ee28b');
insert into tables (description, creationdate, deckId)
values ('DoKo von Alex', '2022-04-04', 1);