-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery.sql
More file actions
69 lines (63 loc) · 2.18 KB
/
query.sql
File metadata and controls
69 lines (63 loc) · 2.18 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
-- CREATE DATABASE purgo;
-- USE purgo;
-- [users] 사용자 정보 테이블
CREATE TABLE users (
userId INT AUTO_INCREMENT PRIMARY KEY,
id VARCHAR(20) NOT NULL,
username VARCHAR(50) NOT NULL,
email VARCHAR(100) NOT NULL UNIQUE,
pw VARCHAR(255) NOT NULL,
profileImage VARCHAR(255),
createdAt DATETIME DEFAULT CURRENT_TIMESTAMP,
updatedAt DATETIME DEFAULT CURRENT_TIMESTAMP
);
-- [posts] 게시글 테이블
CREATE TABLE posts (
postId INT AUTO_INCREMENT PRIMARY KEY,
userId INT NOT NULL,
title VARCHAR(255) NOT NULL,
content VARCHAR(1000),
count INT DEFAULT 0,
createdAt DATETIME DEFAULT CURRENT_TIMESTAMP,
updatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (userId) REFERENCES users(userId)
);
-- [comments] 댓글 테이블
CREATE TABLE comments (
commentId INT AUTO_INCREMENT PRIMARY KEY,
postId INT NOT NULL,
userId INT NOT NULL,
content VARCHAR(1000),
createdAt DATETIME DEFAULT CURRENT_TIMESTAMP,
updatedAt DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (postId) REFERENCES posts(postId),
FOREIGN KEY (userId) REFERENCES users(userId)
);
-- [badwordLogs] 비속어 필터링 기록 테이블
CREATE TABLE badwordLogs (
logId INT AUTO_INCREMENT PRIMARY KEY,
userId INT NOT NULL,
postId INT NULL,
commentId INT NULL,
originalWord VARCHAR(50) NOT NULL,
filteredWord VARCHAR(50) NOT NULL,
createdAt DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (userId) REFERENCES users(userId),
FOREIGN KEY (postId) REFERENCES posts(postId) ON DELETE SET NULL,
FOREIGN KEY (commentId) REFERENCES comments(commentId) ON DELETE SET NULL
);
-- [penaltyCounts] 사용자 비속어 누적 통계
CREATE TABLE penaltyCounts (
userId INT PRIMARY KEY,
penaltyCount INT DEFAULT 0,
lastUpdate DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (userId) REFERENCES users(userId)
);
-- [limits] 이용 제한 테이블
CREATE TABLE limits (
userId INT PRIMARY KEY,
startDate DATETIME DEFAULT CURRENT_TIMESTAMP,
endDate DATETIME,
isActive BOOLEAN DEFAULT TRUE,
FOREIGN KEY (userId) REFERENCES users(userId)
);