-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfindog-db.sql
120 lines (105 loc) · 3.9 KB
/
findog-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
-- Exported from QuickDBD: https://www.quickdatabasediagrams.com/
-- Link to schema: https://app.quickdatabasediagrams.com/#/d/nS64AK
-- NOTE! If you have used non-SQL datatypes in your design, you will have to change these here.
CREATE TABLE `User` (
`userId` int AUTO_INCREMENT NOT NULL ,
`email` varchar(30) NOT NULL ,
`nickname` varchar(20) NOT NULL ,
`password` varchar(400) NOT NULL ,
`phoneNum` varchar(15) NOT NULL ,
`profileUrl` text NULL ,
`userStatus` varchar(10) NOT NULL DEFAULT 'active',
`userCreateAt` timestamp NOT NULL DEFAULT current_timestamp,
`userUpdateAt` timestamp NOT NULL DEFAULT current_timestamp,
PRIMARY KEY (
`userId`
)
);
CREATE TABLE `Animal` (
`animalId` int AUTO_INCREMENT NOT NULL ,
`desertionNo` varchar(15) NOT NULL ,
`filename` varchar(200) NOT NULL ,
`happenDt` varchar(10) NOT NULL ,
`happenPlace` varchar(100) NOT NULL ,
`kindCd` varchar(50) NOT NULL ,
`colorCd` varchar(30) NOT NULL ,
`age` varchar(30) NOT NULL ,
`weight` varchar(30) NOT NULL ,
`noticeNo` varchar(30) NOT NULL ,
`noticeSdt` varchar(10) NOT NULL ,
`noticeEdt` varchar(10) NOT NULL ,
`popfile` varchar(200) NOT NULL ,
`processState` varchar(10) NOT NULL ,
`sexCd` varchar(1) NOT NULL ,
`neuterYn` varchar(1) NOT NULL ,
`specialMark` varchar(200) NOT NULL ,
`careNm` varchar(50) NOT NULL ,
`careTel` varchar(14) NOT NULL ,
`careAddr` varchar(200) NOT NULL ,
`orgNm` varchar(30) NOT NULL,
PRIMARY KEY (
`animalId`
)
);
CREATE TABLE `Post` (
`postId` int AUTO_INCREMENT NOT NULL ,
`userId` int NOT NULL ,
`title` varchar(70) NOT NULL ,
`category` int DEFAULT 1
`region` int DEFAULT 1
`content` text NOT NULL ,
`hits` int NOT NULL DEFAULT 0,
`postCreateAt` timestamp NOT NULL DEFAULT current_timestamp,
`postUpdateAt` timestamp NOT NULL DEFAULT current_timestamp,
PRIMARY KEY (
`postId`
)
);
CREATE TABLE `Like` (
`likeId` int AUTO_INCREMENT NOT NULL ,
`userId` int NOT NULL ,
`animalId` int NULL ,
`postId` int NULL ,
`likeCreateAt` timestamp NOT NULL DEFAULT current_timestamp,
`likeUpdateAt` timestamp NOT NULL DEFAULT current_timestamp,
PRIMARY KEY (
`likeId`
)
);
CREATE TABLE `Comment` (
`commentId` int AUTO_INCREMENT NOT NULL ,
`parentCommentId` int NOT NULL DEFAULT 0,
`userId` int NOT NULL ,
`postId` int NOT NULL ,
`content` text NOT NULL ,
'commentStatus' varchar(10) NOT NULL DEFAULT 'active',
`commentCreateAt` timestamp NOT NULL DEFAULT current_timestamp,
`commentUpdateAt` timestamp NOT NULL DEFAULT current_timestamp,
PRIMARY KEY (
`commentId`
)
);
CREATE TABLE `Image` (
`imageId` int AUTO_INCREMENT NOT NULL ,
`postId` int NOT NULL ,
`imgUrl` text NOT NULL ,
`imageCreateAt` timestamp NOT NULL DEFAULT current_timestamp,
`imageUpdateAt` timestamp NOT NULL DEFAULT current_timestamp,
PRIMARY KEY (
`imageId`
)
);
ALTER TABLE `Post` ADD CONSTRAINT `fk_Post_userId` FOREIGN KEY(`userId`)
REFERENCES `User` (`userId`);
ALTER TABLE `Like` ADD CONSTRAINT `fk_Like_userId` FOREIGN KEY(`userId`)
REFERENCES `User` (`userId`);
ALTER TABLE `Like` ADD CONSTRAINT `fk_Like_animalId` FOREIGN KEY(`animalId`)
REFERENCES `Animal` (`animalId`);
ALTER TABLE `Like` ADD CONSTRAINT `fk_Like_postId` FOREIGN KEY(`postId`)
REFERENCES `Post` (`postId`);
ALTER TABLE `Comment` ADD CONSTRAINT `fk_Comment_userId` FOREIGN KEY(`userId`)
REFERENCES `User` (`userId`);
ALTER TABLE `Comment` ADD CONSTRAINT `fk_Comment_postId` FOREIGN KEY(`postId`)
REFERENCES `Post` (`postId`);
ALTER TABLE `Image` ADD CONSTRAINT `fk_Image_postId` FOREIGN KEY(`postId`)
REFERENCES `Post` (`postId`);