-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbdocs_sample.dbml
More file actions
463 lines (415 loc) · 17.7 KB
/
dbdocs_sample.dbml
File metadata and controls
463 lines (415 loc) · 17.7 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
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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
Project DBDocsSample{
database_type: 'MariaDB'
Note: '
Optinal한 항목입니다.
하지만 DBDocs를 활용할 경우 해당 정보를 바탕으로 문서가 생성됩니다.
해당 프로젝트는 DBDocs와 DBDiagram의 학습이므로 간단하게만 관계를 가져갑니다.
---
MarkDown형식을 지원하지만 HTML을 지원하지는 않습니다.
또한 스타일을 바꾸는것역시 제가알기로는 지원하지 않습니다.
'
}
//---------------------------------------------------------------------------
// 사용자
// Enum의 경우에는 현재 Enum자체에 note의 지정이 불가능하다.
enum auth.user_role{
GUEST [note: '게스트 권한']
USER [note: '사용자 권한']
ADMIN [note: '관리자']
}
// 계정 상태
enum auth.user_status{
WAITING [note: '메일인증 대기상태']
ACTIVE [note: '정상 사용']
DORMANT [note: '휴면']
BLOCKD [note: '정지']
LOCKED [note: '잠금']
DELETE [note: '삭제']
}
// MVP결제상태
enum auth.user_mvp_level {
BRONZE [note: '브론즈']
SILVER [note: '실버']
GOLD [note: '골드']
DIAMOND [note: '다이아몬드']
}
// 계정별 가입 서비스 종류
enum auth.user_provider_type {
HOMEPAGE [note:'홈페이지를 통한 가입, 해당 방식을 Default로 한다']
KAKAO [note: '카카오 가입']
NAVER [note: '네아로 가입']
GOOGLE [note: '구글로 가입']
APPLE [note: '애플로 가입']
}
// 사용자 관련은 #EB801B로 ...!
Table auth.t_user as U[
headercolor: #EB801B,
note:'
사용자 정보 Table
'] {
id bigint(20) [pk, increment, note: '사용자 계정 고유 정보']
login_id varchar(255) [unique, not null, note:'
사용자 접속 ID
']
name varchar(255) [not null, note: '사용자 명']
password varchar(255) [not null, note: '사용자 패스워드']
provider_type auth.user_provider_type [not null, default: 'HOMEPAGE', note: '
Enum의 Default의 경우에는 값을 넣어줘야 하며, 연결이 되진 않습니다.
기본 가입은 HOMEPAGE로 생각합니다.
']
role auth.user_role [not null, default:'USER', note: '사용자 Role']
status auth.user_status [not null, default:'WAITING', note:'사용자 계정 상태']
mvp_level auth.user_mvp_level [not null, default: 'BRONZE', note:'사용자 결제 상태']
email varchar(255) [note:'사용자 메일']
login_at datetime(6) [default: `now`, note: '마지막 로그인']
lock_count int [default: 0, note: '로그인 실패 횟수']
created_at datetime(6) [not null, default: `now()`, note:'계정 생성일']
updated_at datetime(6) [not null, default: `now()`, note:'계정 정보 최종 수정일']
updated_user bigint(20) [ref: > U.id ,default: null, note:'
auth.t_user.id를 OneToMany로 관계한다. 관리자 수정을 통해 여러명이 나올 수 있기 때문
최종 계정 정보 수정자, 해당 정보는 관리자가 수정 할 수도 있으므로...
']
Indexes{
(id, status) [name:'t_user_id_status_idx', note: '계정 가입순서, 상태로 인덱식, 상태값을 기준으로 찾을일이 많으므로..']
}
}
Table auth.t_user_profile_resource [
headercolor: #EB801B,
note:'사용자의 프로필 이미지 Resource Mapping Table']
{
user_id bigint(20) [ref: - U.id, not null, note: '사용자 ID']
resource_id bigint(20) [ref: - common.tbl_resource.id, not null, note: 'Resource ID']
Indexes {
(user_id, resource_id) [pk]
user_id [name:'i_resource_user_id_order']
}
}
Table auth.t_user_provider_key[
headercolor: #EB801B,
note:'
사용자 정보 Table
']{
id bigint(20) [increment]
user_id bigint(20) [ref:- U.id ,not null, note: '사용자 계정 고유 ID']
provider_type auth.user_provider_type [not null, note: '
auth.t_user정보를 그대로 가져온다. 꼭 필요하진 않은 컬럼이고 조인해서 가져와도 좋을듯함
']
refresh_token varchar(255) [not null, note: '사용자 refresh Token Value']
expired_time datetime [not null, note:'provider에서 받은 payload영역의 expired_date시간']
need_delete tinyint(1) [default: 0, note:'
삭제 필요 여부, 0:미삭제, 1:삭제 , expired_time이 Over되면 true로 바꾸고 특정 시간에 batch로 전체 Delete
']
Indexes{
(id, user_id, provider_type) [pk] //Multiple로 Pk 가 필요할것 같아서..
(id, user_id, provider_type) [name:'i_provider_key_default_idx']
(need_delete) [name: 'i_provider_key_delete_order', note:'삭제 여부 확인을 위한 Idx']
}
}
//---------------------------------------------------------------------------
// 게시판
// 게시물 상태
enum board.article_status {
WRITING
WAITING [note: '대기']
POST
HIDING [note: '숨김처리']
DELETE [note: '삭제']
}
enum board.reply_status {
POST
HIDING [note: '숨김처리']
DELETE [note: '삭제처리']
}
// 게시판 타입
enum board.board_type {
ONEONONE [note: '1:1 게시판']
SECRET [note: '비밀 게시판, 특정 지정한 사용자만 접속 가능하다.']
QUESTION [note: '질문 게시판']
ONEONMANY [note: '전체 게시판']
}
// 게시판 상태
enum board.board_status{
HIDE [note: '숨김처리']
USE [note: '현재 사용중']
NOT_USE [note: '현재 사용중 X']
DELETE [note: '삭제 처리']
}
Table board.category [
headercolor: #79AD51,
note: '게시판 : 대단원 - 카테고리'
]{
id bigint(20) [pk, not null, increment]
category_name varchar(255) [not null, note: '게시판 카테고리']
description longtext [null, note:'카테고리 소개']
sort_no int [not null, note: '카테고리 리스트 출력 순서']
is_use board.board_status [not null, default: 'USE', note:'카테고리 상태']
created_at datetime(6) [not null, default: `now()`, note:'최초 생성일']
created_user bigint(20) [ref:> U.id, not null, note: '생성한 관리자 ID']
updated_at datetime [not null, default:`now()`, note: '최종 수정일']
updated_user bigint(20) [ref:> U.id, not null, note: '최종 수정한 관리자 ID']
}
Table board.board [
headercolor: #79AD51,
note: '게시판 : 중단원 - 게시판 리스트'
]{
id bigint(20) [pk, not null, increment, note: '게시판 ID']
category_id bigint(20) [ref:> board.category.id, not null, note: '게시판이 포함된 카테고리ID']
board_name varchar(255) [not null, note: '게시판 이름']
description longtext [null, note: '게시판 세부 설명']
sort_no int [not null, note:'게시판 출력 순서, category별로 0부터 시작한다.']
type board.board_type [not null, default: 'ONEONMANY', note:'
게시판 사용 형태
게시판마다 컬럼이 다르게 필요하면, 해당 컬럼과 연계해서 제작하면 된다.
필자의 경우 간단한 Sample만 제작하는 것이기에 추가하지는 않았다.
']
is_use board.board_status [not null, default: 'USE',note:'게시판 사용 상태']
created_at datetime(6) [not null, default: `now()`, note:'최초 생성일']
created_user bigint(20) [ref:> U.id, not null, note: '생성한 관리자 ID']
updated_at datetime [not null, default:`now()`, note: '최종 수정일']
updated_user bigint(20) [ref:> U.id, not null, note: '최종 수정한 관리자 ID']
}
Table board.article [
headercolor: #79AD51,
note: '게시판 : 게시물 - 게시물'
]{
id bigint(20) [pk, not null, increment, note:'게시물 ID']
board_id bigint(20) [ref:> board.board.id, not null, note: '게시물 ID']
title varchar(255) [not null, note: '게시물 제목']
content longtext [not null, note: '게시물 내용']
view_cnt int [not null, default: 0, note: '게시물 조회수']
reply_cnt int [not null, default: 0, note: '게시믈 총 댓글 수']
recommend_cnt int [not null, default: 0, note: '게시물 추천 갯수']
not_recommend_cnt int [not null, default: 0, note: '게시물 비추천 갯수']
status board.article_status [not null, default: 'POST', note: '게시물 상태']
created_at datetime(6) [not null, default: `now()`, note:'최초 생성일']
created_user bigint(20) [ref:> U.id, not null, note: '작성자']
updated_at datetime [not null, default:`now()`, note: '최종 수정일']
updated_user bigint(20) [ref:> U.id, not null, note: '최종 수정자, 관리자인지, 본인인지 구별을 위함']
}
Table board.article_resource [
headercolor: #79AD51,
note: '게시판 : 게시물 - 첨부파일'
]{
article_id bigint(20) [pk, ref: - board.article.id, not null, note: '사용자 ID']
resource_id bigint(20) [pk, ref: - common.tbl_resource.id, not null, note: 'Resource ID']
Indexes {
article_id [name: 'i_article_resource_idx']
}
}
Table board.article_recommend [
headercolor: #79AD51,
note: '게시판 : 게시물 - 추천 비추천'
]{
id bigint(20) [pk, not null, increment, note: '']
user_id bigint(20) [pk, ref:> U.id, not null, note:'추천한 사용자 ID']
article_id bigint(20) [pk, ref:> board.article.id ,not null, note: '게시물 ID']
recommend tinyint(1) [not null, default: 1, note: '추천여부, 0: 비추천, 1:추천']
recommend_at datetime(6) [not null, default: `now()`, note:'추천일']
Indexes{
article_id [name: "i_article_recommend_article_id_idx"]
user_id [name: "i_article_recommend_user_id_idx"]
}
}
Table board.article_reply [
headercolor: #79AD51,
note: '게시판 : 게시물 - 댓글'
]{
id bigint(20) [pk, not null, increment, note:'댓글 ID']
article_id bigint(20) [ref:> board.article.id ,not null]
parent_reply_id bigint(20) [ref:> board.article_reply.id, null, note: '대댓글을 위한 부모 ID']
depth int [not null, note:'댓글 깊이, 쓰고싶으면 쓰자..']
sort_no int [not null,note: '게시물 순서, 해당 depth에서 1부터 시작함']
content longtext [not null, note: '댓글 내용']
status board.reply_status [not null, default: 'POST', note: '게시물의 상태']
recommend_cnt int [not null, default: 0, note: '댓글 추천 갯수']
reply_at datetime [not null, default: `now()`, note: '댓글 작성일']
Indexes{
(article_id, depth, sort_no) [name: "i_article_reply_article_id_idx"]
}
}
Table board.article_reply_recent[
headercolor: #79AD51,
note: '게시판 : 게시물 - 댓글 - 추천
댓글의 경우에는 추천만 존재한다
'
]{
id bigint(20) [pk, not null, increment, note:'댓글 ID']
user_id bigint(20) [pk, ref:> U.id, not null, note:'추천한 사용자 ID']
reply_id bigint(20) [pk, ref:> board.article_reply.id ,not null]
recent_at datetime(6) [not null, default: `now()`, note:'추천일']
Indexes{
reply_id [name: "i_article_reply_recent_reply_id_idx"]
user_id [name: "i_article_reply_recent_user_id_idx"]
}
}
Table board.article_view_history [
headercolor: #79AD51,
note: '게시판 : 게시물 - 조회이력 (로그인시)'
]{
id bigint(20) [pk, not null, increment, note:'댓글 ID']
article_id bigint(20) [ref:> board.article.id ,not null, note: '게시물 ID']
user_id bigint(20) [ref:> U.id, not null , note: '게시물을 확인한 사용자 ID']
article_view_at datetime [not null, note: '게시물을 확인한 시간']
}
Table board.article_tags [
headercolor: #79AD51,
note: '게시판 : 게시물 - 추천 비추천'
]{
id bigint(20) [pk, not null, increment, note: '']
article_id bigint(20) [ref:> board.article.id ,not null]
tag varchar(255) [not null, note: '간단한 태그']
sort_no int [not null]
}
//---------------------------------------------------------------------------
//공통 기능 테이블
Table common.tbl_resource [
headercolor: #24BAB1,
note: '파일의 저장 정보 테이블'
]{
id bigint(20) [pk, not null, increment]
created_at datetime(6) [not null, default: `now()`, note:'최초 생성일']
created_user bigint(20) [ref:> U.id, not null, note: '생성한 사용자 ID']
updated_at datetime [not null, default:`now()`, note: '최종 수정일']
updated_user bigint(20) [ref:> U.id, not null, note: '최종 수정한 사용자 ID']
org_file_name varchar(255) [default: null, note: '원본 파일 명']
now_file_name varchar(255) [not null, note: '현재 파일 명']
path varchar(255) [not null, note: '파일 경로']
tpye varchar(255) [not null, note: '확장자']
size bigint(20) [not null, note: '파일 사이즈']
}
//---------------------------------------------------------------------------
//관리자 기능
//유료 기능인점 주의
TableGroup Admin{
codes.t_code_category
codes.t_code_key
codes.t_code_value
logs.t_logs
logs.t_user_login_logs
}
Table codes.t_code_category [
headercolor: #A15CF5,
note:'
기능들에서 사용하는 Key, Value의 카테고리
테이블 인덱싱을 하기 위해서 사용한다
'
]{
id bigint(20) [pk, increment, note: '코드 카테고리 id']
name varchar(255) [not null, note: '카테고리 명']
is_use tinyint(1) [not null, default: 1, note:'
사용여부
1(true) : 사용, 0(false) : 미사용
']
created_at datetime [not null, default:`now()`, note: '생성일']
created_user bigint(20) [ref:> U.id, not null, note: '생성한 관리자 ID']
updated_at datetime [not null, default:`now()`, note: '최종 수정일']
updated_user bigint(20) [ref:> U.id, not null, note: '최종 수정한 관리자 ID']
}
//다음과 같이 중복해서 ref도 가능하나 ERD의 GUI모습이 더러워지기 떄문에 하지는 않겠다..
//Ref: auth.t_user.(id, id) > codes.t_code_category.(created_user, updated_user)
Table codes.t_code_key [
headercolor: #A15CF5,
note:'
모든 기능들에서 사용할 코드 키를 만드는 테이블
'
]{
id bigint(20) [pk, increment, note: '키 리스트 고유값']
category bigint(20) [ref: > codes.t_code_category.id, not null,
note: 'code를 사용할 카테고리 지정'
]
key_id varchar(255) [unique, note: '사용자가 지정한 코드 키']
description longtext [null, note: '해당 키에 대한 설명']
is_use tinyint(1) [not null, default: 1, note:'
사용여부
1(true) : 사용, 0(false) : 미사용
']
created_at datetime [not null, default:`now()`, note: '생성일']
created_user bigint(20) [ref:> U.id, not null, note: '생성한 관리자 ID']
updated_at datetime [not null, default:`now()`, note: '최종 수정일']
updated_user bigint(20) [ref:> U.id, not null, note: '최종 수정한 관리자 ID']
Indexes {
category [name: 't_code_key_category_idx']
key_id [name: 't_code_key_key_id_idx']
}
}
Table codes.t_code_value [
headercolor: #A15CF5,
note:'
모든 기능들에서 사용할 코드 값를 만드는 테이블
일단 기본적으로 1:다로 생각하고 여러개의 Row를 만들어서 데이터를 추출하는 방식을 생각하였다.
하지만 Param을 여러개 만든 이유는 한개의 Row에서 여러개의 값을 써야하는 경우를 위해서 여분의 컬럼으로 추가제작하였다.
'
]{
id bigint(20) [pk, increment, note: 'Value 리스트 고유값']
category bigint(20) [ref: > codes.t_code_category.id, not null,
note: 'code를 사용할 카테고리 지정'
]
key_id varchar(255) [ref:> codes.t_code_key.key_id ,not null,
note: '
t_code_key의 id를 가져올지 아니면 key_id를 가져올지 심각하게 고민을 많이 했다.
근데 직관적인건 텍스트 가져오는거라 생각해서 여기서는 텍스트를 가져왔다.
'
]
description longtext [note: '해당 데이터 설명']
is_use tinyint(1) [not null, default:1, note:'
사용여부
1(true) : 사용, 0(false) : 미사용
']
param1 varchar(255) [not null, note:'첫번쨰는 무조건 값이 있어야함.']
param2 varchar(255) [null, note: '예비컬럼1']
param3 varchar(255) [null, note: '예비컬럼2']
param4 varchar(255) [null, note: '예비컬럼3']
param5 varchar(255) [null, note: '예비컬럼4']
created_at datetime [not null, default:`now()`, note: '생성일']
created_user bigint(20) [ref:> U.id, not null, note: '생성한 관리자 ID']
updated_at datetime [not null, default:`now()`, note: '최종 수정일']
updated_user bigint(20) [ref:> U.id, not null, note: '최종 수정한 관리자 ID']
Indexes {
(category, key_id, id) [ name: 't_code_value_category_default']
}
}
Table logs.t_logs[
headercolor: #DE65C3,
note:'
관리차원 로그 메세지를 담을 수 있는 테이블
'
]{
id bigint(20) [pk, increment, note:'id']
table_name varchar(255) [not null, note: '작업 테이블']
logmessage longtext [not null, note:'작업내역']
created_at datetime [not null, default: `now()`, note: '생성일']
}
Table logs.t_user_login_logs[
headercolor: #DE65C3,
note:'관리차원 사용자 접속정보 확인'
]{
id bigint(20) [pk, increment, note:'id']
user_id bigint(20) [not null, note: '사용자 ID, 관계를 엮진 않았으나, 사용자 ID를 기입한다.']
request_time datetime [not null,default:`now()`, note:'로그인 요청 시간']
Indexes {
(user_id, request_time) [name: 'i_userloginlogs_userid_idx']
}
}
//---------------------------------------------------------------------------
// Sample로 제작해본 GW
/*
enum GW.docs_status {
DRAFT [note: '상신']
REDRAFT [note: '재상신']
WITHDRAW [note: '회수']
WRITING [note: '작성중']
RETURN [note: '반려']
PROCESS [note: '처리중']
END [note: '결제 완료']
}
Table GW.docs {
id bigint(20) [pk, not null, increment]
title varchar(255) [not null, note: '문서 제목']
content longtext [not null, note: '문서 내용']
status GW.docs_status [not null, note: '문서 진행 상태']
created_at datetime [not null, default:`now()`, note: '문서 생성일']
created_user bigint(20) [ref:> U.id, not null, note: '생성한 사용자 ID']
updated_at datetime [not null, default:`now()`, note: '최종 수정일']
updated_user bigint(20) [ref:> U.id, not null, note: '최종 수정한 사용자 ID']
}
*/