-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.sql
324 lines (262 loc) · 8.69 KB
/
db.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
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
-- phpMyAdmin SQL Dump
-- version 5.1.1
-- https://www.phpmyadmin.net/
--
-- Host: mariadb
-- Generation Time: Oct 22, 2021 at 06:31 PM
-- Server version: 10.6.4-MariaDB-1:10.6.4+maria~focal
-- PHP Version: 7.4.20
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 */;
--
-- Database: `hoppala`
--
-- --------------------------------------------------------
--
-- Table structure for table `categories`
--
CREATE TABLE `categories` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `categories`
--
INSERT INTO `categories` (`id`, `name`) VALUES
(7, 'Kategori örnek'),
(8, 'Kategori örnek 2'),
(13, 'Örnek kategori haydar');
-- --------------------------------------------------------
--
-- Table structure for table `comments`
--
CREATE TABLE `comments` (
`id` int(11) NOT NULL,
`message` text NOT NULL,
`user_id` int(11) DEFAULT NULL,
`news_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `comments`
--
INSERT INTO `comments` (`id`, `message`, `user_id`, `news_id`) VALUES
(24, 'Önrek yorum', 11, 14);
-- --------------------------------------------------------
--
-- Table structure for table `news`
--
CREATE TABLE `news` (
`id` int(11) NOT NULL,
`title` varchar(255) NOT NULL,
`content` text NOT NULL,
`image` varchar(255) NOT NULL,
`category_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`created_at` date NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `news`
--
INSERT INTO `news` (`id`, `title`, `content`, `image`, `category_id`, `user_id`, `created_at`) VALUES
(12, 'Örnek Haber', 'Örnek Haber İçeriği', 'download-616746980fa0e.jpeg', 7, 3, '2021-10-13'),
(13, 'Örnek Haber 2 ', 'Örnek Haber 2 içeriği', 'big-616746ab93114.jpeg', 7, 3, '2021-10-13'),
(14, 'Örnek Haber 3', 'Örnek Haber 3 İçeriği', 'hardware-vs-software-616746f4c12ba.jpg', 7, 3, '2021-10-13');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`email` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
`role_level` int(11) NOT NULL DEFAULT 1,
`delete_request` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `email`, `password`, `name`, `role_level`, `delete_request`) VALUES
(1, '[email protected]', '$2y$10$mgYYGHvhJVR1IPRf7iaD4.46iPKQkiwjwugW6GzD.Gyi.C3OGDowa', 'admin kullanıcı', 4, 0),
(3, '[email protected]', '$2y$10$mgYYGHvhJVR1IPRf7iaD4.46iPKQkiwjwugW6GzD.Gyi.C3OGDowa', 'editör kullanıcı', 2, 0),
(4, '[email protected]', '$2y$10$mgYYGHvhJVR1IPRf7iaD4.46iPKQkiwjwugW6GzD.Gyi.C3OGDowa', 'mod kullanıcı', 3, 0),
(8, '[email protected]', '$2y$10$mgYYGHvhJVR1IPRf7iaD4.46iPKQkiwjwugW6GzD.Gyi.C3OGDowa', 'bahtsız kullanıcı', 1, 1),
(9, '[email protected]', '$2y$10$mgYYGHvhJVR1IPRf7iaD4.46iPKQkiwjwugW6GzD.Gyi.C3OGDowa', 'bahtsız Kullanıc', 1, 1),
(10, '[email protected]', '$2y$10$mgYYGHvhJVR1IPRf7iaD4.46iPKQkiwjwugW6GzD.Gyi.C3OGDowa', 'Örnek Kullanıcı', 1, 0),
(11, '[email protected]', '$2y$10$egQVmCm68ANHFbq0iMqMveOy43hCa1dOJqqsm1dyWeRJJTOpZhjLS', 'denemem ', 1, 0),
(12, '[email protected]', '$2y$10$gMXZaSJ2XXhGYbtvlJqwSe1ZThh0u4ChissBSMslMdpNKrQ3LpRyq', 'Alo deneme yapıyoruz', 1, 0);
-- --------------------------------------------------------
--
-- Table structure for table `users_categories`
--
CREATE TABLE `users_categories` (
`id` int(11) NOT NULL,
`category_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `users_categories`
--
INSERT INTO `users_categories` (`id`, `category_id`, `user_id`) VALUES
(16, 7, 3),
(17, 13, 3);
-- --------------------------------------------------------
--
-- Table structure for table `user_followed_categories`
--
CREATE TABLE `user_followed_categories` (
`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`category_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `user_followed_categories`
--
INSERT INTO `user_followed_categories` (`id`, `user_id`, `category_id`) VALUES
(4, 3, 7),
(7, 11, 8),
(8, 11, 7),
(10, 1, 7);
-- --------------------------------------------------------
--
-- Table structure for table `user_seen_news`
--
CREATE TABLE `user_seen_news` (
`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`news_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Dumping data for table `user_seen_news`
--
INSERT INTO `user_seen_news` (`id`, `user_id`, `news_id`) VALUES
(7, 3, 12),
(8, 11, 14);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `categories`
--
ALTER TABLE `categories`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `comments`
--
ALTER TABLE `comments`
ADD PRIMARY KEY (`id`),
ADD KEY `user_id` (`user_id`,`news_id`),
ADD KEY `news_comment` (`news_id`);
--
-- Indexes for table `news`
--
ALTER TABLE `news`
ADD PRIMARY KEY (`id`),
ADD KEY `user_iliski` (`user_id`),
ADD KEY `category_id` (`category_id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `users_categories`
--
ALTER TABLE `users_categories`
ADD PRIMARY KEY (`id`),
ADD KEY `category_iliski` (`category_id`),
ADD KEY `users_iliski` (`user_id`);
--
-- Indexes for table `user_followed_categories`
--
ALTER TABLE `user_followed_categories`
ADD PRIMARY KEY (`id`),
ADD KEY `user_followed_category_id` (`category_id`),
ADD KEY `user_followed_category_user_id` (`user_id`);
--
-- Indexes for table `user_seen_news`
--
ALTER TABLE `user_seen_news`
ADD PRIMARY KEY (`id`),
ADD KEY `user_seen_news_user` (`user_id`),
ADD KEY `user_seen_news_news` (`news_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `categories`
--
ALTER TABLE `categories`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
--
-- AUTO_INCREMENT for table `comments`
--
ALTER TABLE `comments`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;
--
-- AUTO_INCREMENT for table `news`
--
ALTER TABLE `news`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;
--
-- AUTO_INCREMENT for table `users_categories`
--
ALTER TABLE `users_categories`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;
--
-- AUTO_INCREMENT for table `user_followed_categories`
--
ALTER TABLE `user_followed_categories`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
--
-- AUTO_INCREMENT for table `user_seen_news`
--
ALTER TABLE `user_seen_news`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `comments`
--
ALTER TABLE `comments`
ADD CONSTRAINT `news_comment` FOREIGN KEY (`news_id`) REFERENCES `news` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `user_comment` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
--
-- Constraints for table `news`
--
ALTER TABLE `news`
ADD CONSTRAINT `iliski` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `user_iliski` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
--
-- Constraints for table `users_categories`
--
ALTER TABLE `users_categories`
ADD CONSTRAINT `category_iliski` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `users_iliski` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
--
-- Constraints for table `user_followed_categories`
--
ALTER TABLE `user_followed_categories`
ADD CONSTRAINT `user_followed_category_id` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `user_followed_category_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
--
-- Constraints for table `user_seen_news`
--
ALTER TABLE `user_seen_news`
ADD CONSTRAINT `user_seen_news_news` FOREIGN KEY (`news_id`) REFERENCES `news` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `user_seen_news_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE 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 */;