-
Notifications
You must be signed in to change notification settings - Fork 34
/
nastenka.sql
144 lines (114 loc) · 3.52 KB
/
nastenka.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
-- phpMyAdmin SQL Dump
-- version 4.9.4
-- https://www.phpmyadmin.net/
--
-- Počítač: localhost
-- Vytvořeno: Sob 21. bře 2020, 01:57
-- Verze serveru: 10.3.21-MariaDB-log
-- Verze PHP: 7.3.14
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
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 */;
--
-- Databáze: `xvojs03`
--
-- --------------------------------------------------------
--
-- Struktura tabulky `categories`
--
CREATE TABLE `categories` (
`category_id` smallint(6) NOT NULL,
`name` varchar(30) COLLATE utf8mb4_czech_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_czech_ci COMMENT='Tabulka s přehledem kategorií';
--
-- Vypisuji data pro tabulku `categories`
--
INSERT INTO `categories` (`category_id`, `name`) VALUES
(1, 'Novinky');
-- --------------------------------------------------------
--
-- Struktura tabulky `posts`
--
CREATE TABLE `posts` (
`post_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`category_id` smallint(6) NOT NULL,
`text` text COLLATE utf8mb4_czech_ci NOT NULL,
`updated` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_czech_ci COMMENT='Tabulka s příspěvky';
--
-- Vypisuji data pro tabulku `posts`
--
INSERT INTO `posts` (`post_id`, `user_id`, `category_id`, `text`, `updated`) VALUES
(1, 1, 1, 'Testovací příspěvek', '2020-03-21 00:54:12');
-- --------------------------------------------------------
--
-- Struktura tabulky `users`
--
CREATE TABLE `users` (
`user_id` int(11) NOT NULL,
`name` varchar(30) COLLATE utf8mb4_czech_ci NOT NULL,
`email` varchar(200) COLLATE utf8mb4_czech_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_czech_ci COMMENT='Tabulka s daty uživatelů';
--
-- Vypisuji data pro tabulku `users`
--
INSERT INTO `users` (`user_id`, `name`, `email`) VALUES
(1, 'Adam', '[email protected]'),
(2, 'Eva', '[email protected]');
--
-- Klíče pro exportované tabulky
--
--
-- Klíče pro tabulku `categories`
--
ALTER TABLE `categories`
ADD PRIMARY KEY (`category_id`);
--
-- Klíče pro tabulku `posts`
--
ALTER TABLE `posts`
ADD PRIMARY KEY (`post_id`),
ADD KEY `user_id` (`user_id`),
ADD KEY `category_id` (`category_id`);
--
-- Klíče pro tabulku `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`user_id`);
--
-- AUTO_INCREMENT pro tabulky
--
--
-- AUTO_INCREMENT pro tabulku `categories`
--
ALTER TABLE `categories`
MODIFY `category_id` smallint(6) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT pro tabulku `posts`
--
ALTER TABLE `posts`
MODIFY `post_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT pro tabulku `users`
--
ALTER TABLE `users`
MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- Omezení pro exportované tabulky
--
--
-- Omezení pro tabulku `posts`
--
ALTER TABLE `posts`
ADD CONSTRAINT `posts_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `categories` (`category_id`) ON UPDATE CASCADE,
ADD CONSTRAINT `posts_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
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 */;