-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDDL.sql
199 lines (172 loc) · 4.86 KB
/
DDL.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
CREATE TABLE `member` (
`user_id` bigint NOT NULL COMMENT '멤버',
`username` varchar(255) NULL COMMENT '이메일 (학교 이메일)',
`display_name` varchar(255) NULL COMMENT '닉네임',
`real_name` varchar(255) NULL COMMENT '본명',
`password` varchar(255) NULL COMMENT '비밀번호',
`phone_number` char(13) NULL COMMENT '전화번호',
`role` enum('ROLE_ADMIN', 'ROLE_USER') NULL,
`affiliation` varchar(255) NULL COMMENT '소속된 학교',
`created_at` datetime(6) NULL COMMENT '가입 일시',
`updated_at` datetime(6) NULL COMMENT '정보 수정 일시'
);
CREATE TABLE `club` (
`club_id` bigint NOT NULL COMMENT '동아리',
`club_name` varchar(255) NULL COMMENT '동아리 이름',
`manager_id` bigint NULL COMMENT '동아리 대표자 id',
`logo_image` varchar(255) NULL COMMENT '로고 이미지',
`detail_image` varchar(255) NULL COMMENT '상세 이미지',
`join_info` VARCHAR(255) NULL,
`created_at` datetime(6) NULL COMMENT '생성 일시',
`updated_at` datetime(6) NULL COMMENT '정보 수정 일시'
);
CREATE TABLE `club_recruitment` (
`recruitment_id` bigint NOT NULL,
`club_id` bigint NOT NULL,
`title` varchar(255) NULL,
`content` text NULL,
`writer_id` bigint NULL,
`maxMembers` int NULL,
`application_deadline` datetime(6) NULL,
`status` enum('RECRUITING', 'CLOSED') NULL,
`views` int NULL,
`created_at` datetime(6) NULL,
`updated_at` datetime(6) NULL
);
CREATE TABLE `comment` (
`comment_id` bigint NOT NULL,
`recruitment_id` bigint NOT NULL,
`user_id` bigint NOT NULL COMMENT '멤버',
`content` text NULL,
`created_at` datetime(6) NULL,
`updated_at` datetime(6) NULL
);
CREATE TABLE `notification` (
`notification_id` bigint NOT NULL,
`member_id` bigint NOT NULL,
`message` varchar(255) NULL,
`is_read` boolean NULL,
`created_at` datetime(6) NULL
);
CREATE TABLE `application` (
`application_id` bigint NOT NULL,
`recruitment_id` bigint NOT NULL,
`user_id` bigint NOT NULL COMMENT '멤버',
`status` enum('PENDING', 'APPROVED', 'REJECTED') NULL,
`application_content` text NULL COMMENT '지원서 내용',
`submitted_at` datetime(6) NULL COMMENT '지원서 제출 일시',
`updated_at` datetime(6) NULL COMMENT '지원서 상태 변경 일시'
);
CREATE TABLE `favorite_club` (
`favorite_id` bigint NOT NULL,
`member_id` bigint NOT NULL,
`club_id` bigint NOT NULL COMMENT '동아리',
`created_at` datetime(6) NULL
);
CREATE TABLE `like` (
`like_id` bigint NOT NULL,
`user_id` bigint NOT NULL COMMENT '멤버',
`recruitment_id` bigint NOT NULL,
`club_id` bigint NOT NULL
);
ALTER TABLE `member` ADD CONSTRAINT `PK_MEMBER` PRIMARY KEY (
`user_id`
);
ALTER TABLE `club` ADD CONSTRAINT `PK_CLUB` PRIMARY KEY (
`club_id`
);
ALTER TABLE `club_recruitment` ADD CONSTRAINT `PK_CLUB_RECRUITMENT` PRIMARY KEY (
`recruitment_id`,
`club_id`
);
ALTER TABLE `comment` ADD CONSTRAINT `PK_COMMENT` PRIMARY KEY (
`comment_id`,
`recruitment_id`,
`user_id`
);
ALTER TABLE `notification` ADD CONSTRAINT `PK_NOTIFICATION` PRIMARY KEY (
`notification_id`,
`member_id`
);
ALTER TABLE `application` ADD CONSTRAINT `PK_APPLICATION` PRIMARY KEY (
`application_id`,
`recruitment_id`,
`user_id`
);
ALTER TABLE `favorite_club` ADD CONSTRAINT `PK_FAVORITE_CLUB` PRIMARY KEY (
`favorite_id`,
`member_id`,
`club_id`
);
ALTER TABLE `like` ADD CONSTRAINT `PK_LIKE` PRIMARY KEY (
`like_id`,
`user_id`,
`recruitment_id`,
`club_id`
);
ALTER TABLE `club_recruitment` ADD CONSTRAINT `FK_club_TO_club_recruitment_1` FOREIGN KEY (
`club_id`
)
REFERENCES `club` (
`club_id`
);
ALTER TABLE `comment` ADD CONSTRAINT `FK_club_recruitment_TO_comment_1` FOREIGN KEY (
`recruitment_id`
)
REFERENCES `club_recruitment` (
`recruitment_id`
);
ALTER TABLE `comment` ADD CONSTRAINT `FK_member_TO_comment_1` FOREIGN KEY (
`user_id`
)
REFERENCES `member` (
`user_id`
);
ALTER TABLE `notification` ADD CONSTRAINT `FK_member_TO_notification_1` FOREIGN KEY (
`member_id`
)
REFERENCES `member` (
`user_id`
);
ALTER TABLE `application` ADD CONSTRAINT `FK_club_recruitment_TO_application_1` FOREIGN KEY (
`recruitment_id`
)
REFERENCES `club_recruitment` (
`recruitment_id`
);
ALTER TABLE `application` ADD CONSTRAINT `FK_member_TO_application_1` FOREIGN KEY (
`user_id`
)
REFERENCES `member` (
`user_id`
);
ALTER TABLE `favorite_club` ADD CONSTRAINT `FK_member_TO_favorite_club_1` FOREIGN KEY (
`member_id`
)
REFERENCES `member` (
`user_id`
);
ALTER TABLE `favorite_club` ADD CONSTRAINT `FK_club_TO_favorite_club_1` FOREIGN KEY (
`club_id`
)
REFERENCES `club` (
`club_id`
);
ALTER TABLE `like` ADD CONSTRAINT `FK_member_TO_like_1` FOREIGN KEY (
`user_id`
)
REFERENCES `member` (
`user_id`
);
ALTER TABLE `like` ADD CONSTRAINT `FK_club_recruitment_TO_like_1` FOREIGN KEY (
`recruitment_id`
)
REFERENCES `club_recruitment` (
`recruitment_id`
);
ALTER TABLE `like` ADD CONSTRAINT `FK_club_recruitment_TO_like_2` FOREIGN KEY (
`club_id`
)
REFERENCES `club_recruitment` (
`club_id`
);