summaryrefslogtreecommitdiff
path: root/docs/db-structure.sql
blob: d7945324ef3fe851b7706cf20372945f05e5d9e2 (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
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
-- --------------------------------------------------------

--
-- Struktura tabeli dla tabeli `players`
--
-- Obraz CSV z Cezara, jeden-do-jednego.
-- Do tej tabeli można (i należy) importować CSV z Cezara.
-- W PHPMyAdminie:
--  * wybrać import z CSV
--  * zaznaczyć aktualizację rekordu w przypadku duplikatu klucza głównego
--  * wybrać separator pól - średnik
--

CREATE TABLE `players` (
  `id` int(11) NOT NULL,
  `name` varchar(50) COLLATE utf8_unicode_520_ci NOT NULL,
  `surname` varchar(50) COLLATE utf8_unicode_520_ci NOT NULL,
  `rank` decimal(3,1) NOT NULL,
  `region` varchar(2) COLLATE utf8_unicode_520_ci NOT NULL,
  `flags` varchar(2) COLLATE utf8_unicode_520_ci NOT NULL,
  `club` varchar(100) COLLATE utf8_unicode_520_ci NOT NULL,
  `discount` varchar(1) COLLATE utf8_unicode_520_ci NOT NULL,
  `paid` varchar(1) COLLATE utf8_unicode_520_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_520_ci;

-- --------------------------------------------------------

--
-- Struktura tabeli dla tabeli `rankings`
--
-- Tabela źródłowa dla generatorów tabelek.
--

CREATE TABLE `rankings` (
  `pid` int(11) NOT NULL,
  `date` date NOT NULL,
  `place` int(11) NOT NULL,
  `score` decimal(8,4) NOT NULL,
  `region` varchar(2) COLLATE utf8_unicode_520_ci NOT NULL,
  `flags` varchar(2) COLLATE utf8_unicode_520_ci NOT NULL,
  `rank` decimal(3,1) NOT NULL,
  `club` varchar(100) COLLATE utf8_unicode_520_ci NOT NULL,
  `hidden` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_520_ci;

-- --------------------------------------------------------

--
-- Struktura tabeli dla tabeli `temp_rankings`
--
-- Tabela, do której można importować ranking bez potrzeby wypełniania
-- w CSV źródłowej województw, płci i wieku.
--

CREATE TABLE `temp_rankings` (
  `pid` int(11) NOT NULL,
  `date` date NOT NULL,
  `place` int(11) NOT NULL,
  `score` decimal(8,4) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_520_ci;

-- --------------------------------------------------------

--
-- Struktura tabeli dla tabeli `hidden_players`
--

CREATE TABLE `hidden_players` (
  `pid` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_520_ci;

--
-- Indeksy dla zrzutów tabel
--

--
-- Indexes for table `players`
--
ALTER TABLE `players`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `rankings`
--
ALTER TABLE `rankings`
  ADD PRIMARY KEY (`pid`,`date`);

--
-- Indexes for table `temp_rankings`
--
ALTER TABLE `temp_rankings`
  ADD PRIMARY KEY (`pid`,`date`);

--
-- Indexes for table `hidden_players`
--
ALTER TABLE `hidden_players`
  ADD PRIMARY KEY (`pid`);

--
-- Ograniczenia dla zrzutów tabel
--

--
-- Ograniczenia dla tabeli `rankings`
--
ALTER TABLE `rankings`
  ADD CONSTRAINT `rankings_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `players` (`id`) ON UPDATE CASCADE;

--
-- Ograniczenia dla tabeli `temp_rankings`
--
ALTER TABLE `temp_rankings`
  ADD CONSTRAINT `temp_rankings_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `players` (`id`) ON UPDATE CASCADE;

--
-- Ograniczenia dla tabeli `hidden_players`
--
ALTER TABLE `hidden_players`
  ADD CONSTRAINT `hidden_players_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `players` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;