-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsheepyourhack4.sql
More file actions
364 lines (297 loc) · 10 KB
/
sheepyourhack4.sql
File metadata and controls
364 lines (297 loc) · 10 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
-- phpMyAdmin SQL Dump
-- version 5.2.0
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Czas generowania: 31 Gru 2022, 14:47
-- Wersja serwera: 10.4.27-MariaDB
-- Wersja PHP: 8.1.12
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Baza danych: `sheepyourhack4`
--
CREATE DATABASE IF NOT EXISTS `sheepyourhack4` DEFAULT CHARACTER SET utf8 COLLATE utf8_polish_ci;
USE `sheepyourhack4`;
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `degree_courses`
--
CREATE TABLE `degree_courses` (
`id` int(11) NOT NULL,
`id_university` int(11) NOT NULL,
`name` varchar(200) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;
--
-- Zrzut danych tabeli `degree_courses`
--
INSERT INTO `degree_courses` (`id`, `id_university`, `name`) VALUES
(1, 1, 'Informatyka i Systemy Inteligentne'),
(2, 2, 'Informatyka Analityczna'),
(3, 3, 'Informatyka'),
(4, 4, 'Technik Informatyk');
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `notes`
--
CREATE TABLE `notes` (
`id` int(11) NOT NULL,
`id_author` int(11) NOT NULL,
`id_degree_course` int(11) NOT NULL,
`id_subject` int(11) NOT NULL,
`title` varchar(200) NOT NULL,
`url` text NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
`upvotes` int(11) NOT NULL DEFAULT 0,
`approved` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;
--
-- Zrzut danych tabeli `notes`
--
INSERT INTO `notes` (`id`, `id_author`, `id_degree_course`, `id_subject`, `title`, `url`, `timestamp`, `upvotes`, `approved`) VALUES
(1, 3, 2, 1, 'Niezależność liniowa wektorów', 'https://www.entnet.org/wp-content/uploads/2021/04/Instructions-for-Adding-Your-Logo-2.pdf', '2022-12-17 04:20:11', 37, 0),
(2, 3, 2, 3, 'Jak korzystać z Adobe Acrobat', 'https://unec.edu.az/application/uploads/2014/12/pdf-sample.pdf', '2022-12-17 04:20:30', 68, 1),
(3, 6, 4, 1, 'Macierze', '/media/pdf/W14.pdf', '2022-12-17 06:43:03', 12, 0),
(8, 3, 1, 2, 'Całki wymierne', 'uerrel', '2022-12-17 10:37:59', 130, 1),
(13, 3, 2, 2, 'etaewrat', 'aewgawe', '2022-12-18 15:40:42', 0, 0),
(14, 3, 3, 1, 'efwfaew', 'waer', '2022-12-19 19:33:22', 0, 0);
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `questions`
--
CREATE TABLE `questions` (
`id` int(11) NOT NULL,
`id_author` int(11) NOT NULL,
`id_degree_course` int(11) NOT NULL,
`id_subject` int(11) NOT NULL,
`title` varchar(200) NOT NULL,
`content` text NOT NULL,
`points` int(11) NOT NULL,
`excercise_set` varchar(200) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;
--
-- Zrzut danych tabeli `questions`
--
INSERT INTO `questions` (`id`, `id_author`, `id_degree_course`, `id_subject`, `title`, `content`, `points`, `excercise_set`, `timestamp`) VALUES
(2, 3, 1, 1, 'Zadanie od Domki', 'Udowodnij, że 2+2 = 5', 2, 'zestaw 1', '2022-12-17 02:59:41'),
(3, 4, 2, 2, 'Trudna całka', 'Oblicz całkę niewymierną', 5, 'zestaw b', '2022-12-17 03:00:08'),
(4, 3, 1, 1, 'Nowe zadanie', 'Zawartość nowego zadania', 10, 'zestawe afhalewjkajal', '2022-12-17 06:44:25');
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `question_answers`
--
CREATE TABLE `question_answers` (
`id` int(11) NOT NULL,
`id_author` int(11) NOT NULL,
`id_question` int(11) NOT NULL,
`content` text NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT current_timestamp(),
`upvotes` int(11) NOT NULL DEFAULT 0,
`best_answer` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;
--
-- Zrzut danych tabeli `question_answers`
--
INSERT INTO `question_answers` (`id`, `id_author`, `id_question`, `content`, `timestamp`, `upvotes`, `best_answer`) VALUES
(1, 3, 3, 'Trzeba to zrobić metodą podstawiania', '2022-12-17 04:27:25', -1, 0),
(2, 4, 3, 'Musisz do tego użyć wzoru na całkę niewłaściwą', '2022-12-17 04:27:55', 1, 0),
(3, 5, 3, 'Dziwna ta całka. Nie umiem tego zrobić', '2022-12-17 07:04:30', 0, 0);
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `subjects`
--
CREATE TABLE `subjects` (
`id` int(11) NOT NULL,
`name` varchar(200) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;
--
-- Zrzut danych tabeli `subjects`
--
INSERT INTO `subjects` (`id`, `name`) VALUES
(1, 'Algebra'),
(2, 'Analiza matematyczna'),
(3, 'Narzędzia informatyczne\r\n');
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `subscriptions`
--
CREATE TABLE `subscriptions` (
`id` int(11) NOT NULL,
`id_user` int(11) NOT NULL,
`start_date` timestamp NOT NULL DEFAULT current_timestamp(),
`expire_date` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `universities`
--
CREATE TABLE `universities` (
`id` int(11) NOT NULL,
`name` varchar(200) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;
--
-- Zrzut danych tabeli `universities`
--
INSERT INTO `universities` (`id`, `name`) VALUES
(1, 'Akademia Górniczo Hutnicza'),
(2, 'Uniwersytet Jagieloński'),
(3, 'Politechnika Krakowska'),
(4, 'Technikum Łączności');
-- --------------------------------------------------------
--
-- Struktura tabeli dla tabeli `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`username` varchar(100) NOT NULL,
`password` varchar(256) NOT NULL,
`type` enum('user','admin') NOT NULL DEFAULT 'user',
`points` int(11) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci;
--
-- Zrzut danych tabeli `users`
--
INSERT INTO `users` (`id`, `username`, `password`, `type`, `points`) VALUES
(3, 'admin', 'admin', 'admin', 0),
(4, 'admin2', 'admin', 'user', 0),
(5, 'test', 'test', 'user', 0),
(6, 'test1', 'test1', 'user', 0);
--
-- Indeksy dla zrzutów tabel
--
--
-- Indeksy dla tabeli `degree_courses`
--
ALTER TABLE `degree_courses`
ADD PRIMARY KEY (`id`),
ADD KEY `id_university` (`id_university`);
--
-- Indeksy dla tabeli `notes`
--
ALTER TABLE `notes`
ADD PRIMARY KEY (`id`),
ADD KEY `id_author` (`id_author`),
ADD KEY `id_subject` (`id_subject`),
ADD KEY `id_degree_course` (`id_degree_course`);
--
-- Indeksy dla tabeli `questions`
--
ALTER TABLE `questions`
ADD PRIMARY KEY (`id`),
ADD KEY `id_author` (`id_author`),
ADD KEY `id_degree_course` (`id_degree_course`),
ADD KEY `id_subject` (`id_subject`);
--
-- Indeksy dla tabeli `question_answers`
--
ALTER TABLE `question_answers`
ADD PRIMARY KEY (`id`),
ADD KEY `id_question` (`id_question`),
ADD KEY `id_author` (`id_author`);
--
-- Indeksy dla tabeli `subjects`
--
ALTER TABLE `subjects`
ADD PRIMARY KEY (`id`);
--
-- Indeksy dla tabeli `subscriptions`
--
ALTER TABLE `subscriptions`
ADD PRIMARY KEY (`id`),
ADD KEY `id_user` (`id_user`);
--
-- Indeksy dla tabeli `universities`
--
ALTER TABLE `universities`
ADD PRIMARY KEY (`id`);
--
-- Indeksy dla tabeli `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT dla zrzuconych tabel
--
--
-- AUTO_INCREMENT dla tabeli `degree_courses`
--
ALTER TABLE `degree_courses`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT dla tabeli `notes`
--
ALTER TABLE `notes`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;
--
-- AUTO_INCREMENT dla tabeli `questions`
--
ALTER TABLE `questions`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT dla tabeli `question_answers`
--
ALTER TABLE `question_answers`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT dla tabeli `subjects`
--
ALTER TABLE `subjects`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT dla tabeli `subscriptions`
--
ALTER TABLE `subscriptions`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT dla tabeli `universities`
--
ALTER TABLE `universities`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT dla tabeli `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- Ograniczenia dla zrzutów tabel
--
--
-- Ograniczenia dla tabeli `degree_courses`
--
ALTER TABLE `degree_courses`
ADD CONSTRAINT `degree_courses_ibfk_1` FOREIGN KEY (`id_university`) REFERENCES `universities` (`id`);
--
-- Ograniczenia dla tabeli `notes`
--
ALTER TABLE `notes`
ADD CONSTRAINT `notes_ibfk_1` FOREIGN KEY (`id_author`) REFERENCES `users` (`id`),
ADD CONSTRAINT `notes_ibfk_2` FOREIGN KEY (`id_degree_course`) REFERENCES `degree_courses` (`id`),
ADD CONSTRAINT `notes_ibfk_3` FOREIGN KEY (`id_subject`) REFERENCES `subjects` (`id`);
--
-- Ograniczenia dla tabeli `questions`
--
ALTER TABLE `questions`
ADD CONSTRAINT `questions_ibfk_1` FOREIGN KEY (`id_author`) REFERENCES `users` (`id`),
ADD CONSTRAINT `questions_ibfk_2` FOREIGN KEY (`id_degree_course`) REFERENCES `degree_courses` (`id`),
ADD CONSTRAINT `questions_ibfk_3` FOREIGN KEY (`id_subject`) REFERENCES `subjects` (`id`);
--
-- Ograniczenia dla tabeli `question_answers`
--
ALTER TABLE `question_answers`
ADD CONSTRAINT `question_answers_ibfk_1` FOREIGN KEY (`id_question`) REFERENCES `questions` (`id`),
ADD CONSTRAINT `question_answers_ibfk_2` FOREIGN KEY (`id_author`) REFERENCES `users` (`id`);
--
-- Ograniczenia dla tabeli `subscriptions`
--
ALTER TABLE `subscriptions`
ADD CONSTRAINT `subscriptions_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `users` (`id`);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;