-
Notifications
You must be signed in to change notification settings - Fork 1
/
pvo_v1_2023_202305232253.sql
1196 lines (1074 loc) · 41.7 KB
/
pvo_v1_2023_202305232253.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
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
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--
-- Script was generated by Devart dbForge Studio for MySQL, Version 9.2.34.0
-- Product home page: http://www.devart.com/dbforge/mysql/studio
-- Script date 23-May-23 10:53:28 PM
-- Server version: 10.6.13
-- Client version: 4.1
--
--
-- Disable foreign keys
--
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
--
-- Set SQL mode
--
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
--
-- Set character set the client will use to send SQL statements to the server
--
SET NAMES 'utf8';
--
-- Set default database
--
USE pvo_v1_2023;
--
-- Drop table `example_relationship`
--
DROP TABLE IF EXISTS example_relationship;
--
-- Drop procedure `Proc_CreateActivatedAccountData`
--
DROP PROCEDURE IF EXISTS Proc_CreateActivatedAccountData;
--
-- Drop table `example_link`
--
DROP TABLE IF EXISTS example_link;
--
-- Drop table `sys_example_link`
--
DROP TABLE IF EXISTS sys_example_link;
--
-- Drop table `tone`
--
DROP TABLE IF EXISTS tone;
--
-- Drop table `sys_tone`
--
DROP TABLE IF EXISTS sys_tone;
--
-- Drop table `mode`
--
DROP TABLE IF EXISTS mode;
--
-- Drop table `sys_mode`
--
DROP TABLE IF EXISTS sys_mode;
--
-- Drop table `register`
--
DROP TABLE IF EXISTS register;
--
-- Drop table `sys_register`
--
DROP TABLE IF EXISTS sys_register;
--
-- Drop table `nuance`
--
DROP TABLE IF EXISTS nuance;
--
-- Drop table `sys_nuance`
--
DROP TABLE IF EXISTS sys_nuance;
--
-- Drop table `dialect`
--
DROP TABLE IF EXISTS dialect;
--
-- Drop table `sys_dialect`
--
DROP TABLE IF EXISTS sys_dialect;
--
-- Drop view `view_concept_relationship`
--
DROP VIEW IF EXISTS view_concept_relationship CASCADE;
--
-- Drop table `concept_relationship`
--
DROP TABLE IF EXISTS concept_relationship;
--
-- Drop table `concept_link`
--
DROP TABLE IF EXISTS concept_link;
--
-- Drop table `sys_concept_link`
--
DROP TABLE IF EXISTS sys_concept_link;
--
-- Drop procedure `Proc_GetLogsFilterPaging`
--
DROP PROCEDURE IF EXISTS Proc_GetLogsFilterPaging;
--
-- Drop table `audit_log`
--
DROP TABLE IF EXISTS audit_log;
--
-- Drop table `concept`
--
DROP TABLE IF EXISTS concept;
--
-- Drop table `example`
--
DROP TABLE IF EXISTS example;
--
-- Drop table `dictionary`
--
DROP TABLE IF EXISTS dictionary;
--
-- Drop table `user_setting`
--
DROP TABLE IF EXISTS user_setting;
--
-- Drop table `user`
--
DROP TABLE IF EXISTS user;
--
-- Set default database
--
USE pvo_v1_2023;
--
-- Create table `user`
--
CREATE TABLE user (
user_id char(36) NOT NULL COMMENT 'id khóa chính',
user_name varchar(100) DEFAULT NULL COMMENT 'Tên đăng nhập',
password char(60) DEFAULT NULL COMMENT 'Mã hash mật khẩu',
email varchar(50) DEFAULT NULL,
full_name varchar(255) DEFAULT NULL COMMENT 'Tên đầy đủ',
display_name varchar(100) DEFAULT NULL COMMENT 'Tên hiển thị',
birthday datetime DEFAULT NULL COMMENT 'Ngày sinh',
`position` varchar(255) DEFAULT NULL COMMENT 'Công việc',
avatar text DEFAULT NULL COMMENT 'Link ảnh đại diện',
status int(11) DEFAULT NULL COMMENT 'Trạng thái tài khoản',
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (user_id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 8192,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng chứa thông tin người dùng';
--
-- Create index `email` on table `user`
--
ALTER TABLE user
ADD UNIQUE INDEX email (email);
--
-- Create index `user_name` on table `user`
--
ALTER TABLE user
ADD UNIQUE INDEX user_name (user_name);
--
-- Create table `user_setting`
--
CREATE TABLE user_setting (
user_setting_id char(36) NOT NULL COMMENT 'id khóa chính',
user_id char(36) DEFAULT NULL COMMENT 'id người dùng',
setting_key varchar(255) DEFAULT NULL COMMENT 'key',
setting_value varchar(255) DEFAULT NULL COMMENT 'value',
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (user_setting_id)
)
ENGINE = INNODB,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng chứa thông tin cấu hình của người dùng';
--
-- Create foreign key
--
ALTER TABLE user_setting
ADD CONSTRAINT FK_user_setting_user_id FOREIGN KEY (user_id)
REFERENCES user (user_id) ON DELETE CASCADE;
--
-- Create table `dictionary`
--
CREATE TABLE dictionary (
dictionary_id char(36) NOT NULL COMMENT 'id khóa chính',
user_id char(36) DEFAULT NULL COMMENT 'id người dùng (tham chiếu bảng user)',
dictionary_name varchar(255) DEFAULT NULL COMMENT 'Tên dictionary',
last_view_at datetime DEFAULT NULL COMMENT 'Thời điểm truy cập gần nhất',
created_at datetime DEFAULT NULL,
modified_at datetime DEFAULT NULL,
PRIMARY KEY (dictionary_id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 16384,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng chứa thông tin dictionary';
--
-- Create foreign key
--
ALTER TABLE dictionary
ADD CONSTRAINT FK_dictionary_user_id FOREIGN KEY (user_id)
REFERENCES user (user_id) ON DELETE CASCADE;
--
-- Create table `example`
--
CREATE TABLE example (
example_id char(36) NOT NULL,
dictionary_id char(36) DEFAULT NULL,
detail text DEFAULT NULL,
detail_html text DEFAULT NULL,
note varchar(255) DEFAULT NULL,
tone_id char(36) DEFAULT NULL,
register_id char(36) DEFAULT NULL,
dialect_id char(36) DEFAULT NULL,
mode_id char(36) DEFAULT NULL,
nuance_id char(36) DEFAULT NULL,
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (example_id)
)
ENGINE = INNODB,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng chứa thông tin example';
--
-- Create foreign key
--
ALTER TABLE example
ADD CONSTRAINT FK_example_dictionary_id FOREIGN KEY (dictionary_id)
REFERENCES dictionary (dictionary_id) ON DELETE CASCADE;
--
-- Create table `concept`
--
CREATE TABLE concept (
concept_id char(36) NOT NULL COMMENT 'id khóa chính',
dictionary_id char(36) DEFAULT NULL COMMENT 'id dictionary (tham chiếu bảng dictionary)',
title varchar(255) DEFAULT NULL COMMENT 'Tên concept',
description varchar(500) DEFAULT NULL COMMENT 'Mô tả concept',
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (concept_id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 1260,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng chứa thông tin concept';
--
-- Create foreign key
--
ALTER TABLE concept
ADD CONSTRAINT FK_concept_dictionary_id FOREIGN KEY (dictionary_id)
REFERENCES dictionary (dictionary_id) ON DELETE CASCADE;
--
-- Create table `audit_log`
--
CREATE TABLE audit_log (
audit_log_id int(11) NOT NULL AUTO_INCREMENT COMMENT 'id khóa chính',
user_id char(36) DEFAULT NULL COMMENT 'id người dùng',
screen_info varchar(255) DEFAULT NULL COMMENT 'Thông tin màn hình',
action_type int(11) DEFAULT NULL COMMENT 'Loại hành động',
reference varchar(255) DEFAULT NULL COMMENT 'Thông tin tham chiếu, vd: id dictionary',
description varchar(500) DEFAULT NULL COMMENT 'Mô tả',
user_agent varchar(255) DEFAULT NULL,
created_date datetime DEFAULT NULL,
modified_date varchar(255) DEFAULT NULL,
PRIMARY KEY (audit_log_id)
)
ENGINE = INNODB,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng chứa thông tin lịch sử truy cập';
--
-- Create foreign key
--
ALTER TABLE audit_log
ADD CONSTRAINT FK_audit_log_user_id FOREIGN KEY (user_id)
REFERENCES user (user_id) ON DELETE CASCADE;
DELIMITER $$
--
-- Create procedure `Proc_GetLogsFilterPaging`
--
CREATE
DEFINER = 'dev'@'%'
PROCEDURE Proc_GetLogsFilterPaging (IN $UserId char(36), IN $SearchFilter varchar(255), IN $PageIndex int, IN $PageSize int, IN $DateFrom datetime, IN $DateTo datetime, OUT $TotalRecord int, OUT $TotalPage int)
BEGIN
IF $PageSize > 0 THEN
SELECT
al.audit_log_id,
al.user_id,
al.screen_info,
al.action_type,
al.reference,
al.description,
al.user_agent,
al.created_date
FROM audit_log al
WHERE al.user_id = $UserId
AND (
$SearchFilter IS NULL
OR $SearchFilter = ""
OR (
al.screen_info LIKE CONCAT('%', $SearchFilter, '%')
OR al.description LIKE CONCAT('%', $SearchFilter, '%')
OR al.user_agent LIKE CONCAT('%', $SearchFilter, '%')
-- action_type ???
))
AND ($DateFrom IS NULL
OR al.created_date >= $DateFrom)
AND ($DateTo IS NULL
OR al.created_date <= $DateTo)
ORDER BY al.created_date DESC
LIMIT $PageSize OFFSET $PageIndex;
-- Tổng số bản ghi
SET $TotalRecord = (SELECT
COUNT(al.audit_log_id)
FROM audit_log al
WHERE al.user_id = $UserId
AND (
$SearchFilter IS NULL
OR $SearchFilter = ""
OR ($SearchFilter IS NOT NULL
AND (al.screen_info LIKE CONCAT('%', $SearchFilter, '%')
OR al.description LIKE CONCAT('%', $SearchFilter, '%')
OR al.user_agent LIKE CONCAT('%', $SearchFilter, '%')
-- action_type ???
))));
-- Tổng số trang
SET $TotalPage = CEILING(1.0 * $TotalRecord / $PageSize);
END IF;
END
$$
DELIMITER ;
--
-- Create table `sys_concept_link`
--
CREATE TABLE sys_concept_link (
sys_concept_link_id char(36) NOT NULL COMMENT 'id khóa chính',
concept_link_name varchar(255) DEFAULT NULL COMMENT 'Tên loại liên kết',
concept_link_type int(11) DEFAULT NULL COMMENT 'Loại liên kết',
sort_order int(11) DEFAULT NULL COMMENT 'Thứ tự sắp xếp',
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (sys_concept_link_id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 5461,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng sys loại liên kết giữa concept với concept';
--
-- Create table `concept_link`
--
CREATE TABLE concept_link (
concept_link_id char(36) NOT NULL COMMENT 'id khóa chính',
sys_concept_link_id char(36) DEFAULT NULL COMMENT 'id bảng sys',
user_id char(36) DEFAULT NULL COMMENT 'id người dùng',
concept_link_name varchar(255) DEFAULT NULL COMMENT 'Tên loại liên kết',
concept_link_type int(11) DEFAULT NULL COMMENT 'Loại liên kết',
sort_order int(11) DEFAULT NULL COMMENT 'Thứ tự sắp xếp',
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (concept_link_id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 5461,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng chứa thông tin loại liên kết concept-concept';
--
-- Create foreign key
--
ALTER TABLE concept_link
ADD CONSTRAINT FK_concept_link_sys_concept_link_id FOREIGN KEY (sys_concept_link_id)
REFERENCES sys_concept_link (sys_concept_link_id) ON DELETE CASCADE;
--
-- Create foreign key
--
ALTER TABLE concept_link
ADD CONSTRAINT FK_concept_link_user_id FOREIGN KEY (user_id)
REFERENCES user (user_id) ON DELETE CASCADE;
--
-- Create table `concept_relationship`
--
CREATE TABLE concept_relationship (
concept_relationship_id int(11) NOT NULL AUTO_INCREMENT COMMENT 'id khóa chính',
dictionary_id char(36) DEFAULT NULL COMMENT 'id dictionảy',
concept_id char(36) DEFAULT NULL COMMENT 'id concept',
parent_id char(36) DEFAULT NULL COMMENT 'id concept cha',
concept_link_id char(36) DEFAULT NULL COMMENT 'id loại liên kết concept-concept',
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (concept_relationship_id)
)
ENGINE = INNODB,
AUTO_INCREMENT = 16,
AVG_ROW_LENGTH = 1092,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng chứa liên kết concept-concept';
--
-- Create foreign key
--
ALTER TABLE concept_relationship
ADD CONSTRAINT FK_concept_relationship_concept_id FOREIGN KEY (concept_id)
REFERENCES concept (concept_id) ON DELETE CASCADE;
--
-- Create foreign key
--
ALTER TABLE concept_relationship
ADD CONSTRAINT FK_concept_relationship_concept_link_id FOREIGN KEY (concept_link_id)
REFERENCES concept_link (concept_link_id) ON DELETE NO ACTION;
--
-- Create foreign key
--
ALTER TABLE concept_relationship
ADD CONSTRAINT FK_concept_relationship_dictionary_id FOREIGN KEY (dictionary_id)
REFERENCES dictionary (dictionary_id) ON DELETE CASCADE;
--
-- Create foreign key
--
ALTER TABLE concept_relationship
ADD CONSTRAINT FK_concept_relationship_parent_id FOREIGN KEY (parent_id)
REFERENCES concept (concept_id) ON DELETE CASCADE;
--
-- Create view `view_concept_relationship`
--
CREATE
DEFINER = 'root'@'localhost'
VIEW view_concept_relationship
AS
SELECT
`c`.`dictionary_id` AS `dictionary_id`,
`c`.`concept_id` AS `child_id`,
`c`.`title` AS `child_name`,
`c1`.`concept_id` AS `parent_id`,
`c1`.`title` AS `parent_name`,
`cl`.`concept_link_name` AS `concept_link_name`
FROM (((`concept_relationship` `cr`
JOIN `concept` `c`
ON (`cr`.`concept_id` = `c`.`concept_id`))
JOIN `concept` `c1`
ON (`cr`.`parent_id` = `c1`.`concept_id`))
JOIN `concept_link` `cl`
ON (`cr`.`concept_link_id` = `cl`.`concept_link_id`));
--
-- Create table `sys_dialect`
--
CREATE TABLE sys_dialect (
sys_dialect_id char(36) NOT NULL COMMENT 'id khóa chính',
dialect_name varchar(255) DEFAULT NULL COMMENT 'Tên dialect',
dialect_type int(11) DEFAULT NULL COMMENT 'Loại dialect',
sort_order int(11) DEFAULT NULL COMMENT 'Thứ tự sắp xếp',
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (sys_dialect_id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 4096,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng sys loại dialect';
--
-- Create table `dialect`
--
CREATE TABLE dialect (
dialect_id char(36) NOT NULL,
sys_dialect_id char(36) DEFAULT NULL,
user_id char(36) DEFAULT NULL,
dialect_name varchar(255) DEFAULT NULL,
dialect_type int(11) DEFAULT NULL,
sort_order int(11) DEFAULT NULL,
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (dialect_id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 4096,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng danh sách dialect';
--
-- Create foreign key
--
ALTER TABLE dialect
ADD CONSTRAINT FK_dialect_sys_dialect_id FOREIGN KEY (sys_dialect_id)
REFERENCES sys_dialect (sys_dialect_id) ON DELETE CASCADE;
--
-- Create foreign key
--
ALTER TABLE dialect
ADD CONSTRAINT FK_dialect_user_id FOREIGN KEY (user_id)
REFERENCES user (user_id) ON DELETE CASCADE;
--
-- Create table `sys_nuance`
--
CREATE TABLE sys_nuance (
sys_nuance_id char(36) NOT NULL COMMENT 'id khóa chính',
nuance_name varchar(255) DEFAULT NULL COMMENT 'Tên nuance',
nuance_type int(11) DEFAULT NULL COMMENT 'Loại nuance',
sort_order int(11) DEFAULT NULL COMMENT 'Thứ tự sắp xếp',
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (sys_nuance_id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 3276,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng sys loại nuance';
--
-- Create table `nuance`
--
CREATE TABLE nuance (
nuance_id char(36) NOT NULL,
sys_nuance_id char(36) DEFAULT NULL,
user_id char(36) DEFAULT NULL,
nuance_name varchar(255) DEFAULT NULL,
nuance_type int(11) DEFAULT NULL,
sort_order int(11) DEFAULT NULL,
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (nuance_id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 3276,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng danh sách nuance';
--
-- Create foreign key
--
ALTER TABLE nuance
ADD CONSTRAINT FK_nuance_sys_nuance_id FOREIGN KEY (sys_nuance_id)
REFERENCES sys_nuance (sys_nuance_id) ON DELETE CASCADE;
--
-- Create foreign key
--
ALTER TABLE nuance
ADD CONSTRAINT FK_nuance_user_id FOREIGN KEY (user_id)
REFERENCES user (user_id) ON DELETE CASCADE;
--
-- Create table `sys_register`
--
CREATE TABLE sys_register (
sys_register_id char(36) NOT NULL COMMENT 'id khóa chính',
register_name varchar(255) DEFAULT NULL COMMENT 'Tên register',
register_type varchar(255) DEFAULT NULL COMMENT 'Loại register',
sort_order int(11) DEFAULT NULL COMMENT 'Thứ tự sắp xếp',
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (sys_register_id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 1820,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng sys loại register';
--
-- Create table `register`
--
CREATE TABLE register (
register_id char(36) NOT NULL,
sys_register_id char(36) DEFAULT NULL,
user_id char(36) DEFAULT NULL,
register_name varchar(255) DEFAULT NULL,
register_type int(11) DEFAULT NULL,
sort_order int(11) DEFAULT NULL,
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (register_id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 1820,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng danh sách register';
--
-- Create foreign key
--
ALTER TABLE register
ADD CONSTRAINT FK_register_sys_register_id FOREIGN KEY (sys_register_id)
REFERENCES sys_register (sys_register_id) ON DELETE CASCADE;
--
-- Create foreign key
--
ALTER TABLE register
ADD CONSTRAINT FK_register_user_id FOREIGN KEY (user_id)
REFERENCES user (user_id) ON DELETE CASCADE;
--
-- Create table `sys_mode`
--
CREATE TABLE sys_mode (
sys_mode_id char(36) NOT NULL COMMENT 'id khóa chính',
mode_name varchar(255) DEFAULT NULL COMMENT 'Tên mode',
mode_type int(11) DEFAULT NULL COMMENT 'Loại mode',
sort_order int(11) DEFAULT NULL COMMENT 'Thứ tự sắp xếp',
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (sys_mode_id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 5461,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng sys loại mode';
--
-- Create table `mode`
--
CREATE TABLE mode (
mode_id char(36) NOT NULL,
sys_mode_id char(36) DEFAULT NULL,
user_id char(36) DEFAULT NULL,
mode_name varchar(255) DEFAULT NULL,
mode_type int(11) DEFAULT NULL,
sort_order int(11) DEFAULT NULL,
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (mode_id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 5461,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng danh sách mode';
--
-- Create foreign key
--
ALTER TABLE mode
ADD CONSTRAINT FK_mode_sys_mode_id FOREIGN KEY (sys_mode_id)
REFERENCES sys_mode (sys_mode_id) ON DELETE CASCADE;
--
-- Create foreign key
--
ALTER TABLE mode
ADD CONSTRAINT FK_mode_user_id FOREIGN KEY (user_id)
REFERENCES user (user_id) ON DELETE CASCADE;
--
-- Create table `sys_tone`
--
CREATE TABLE sys_tone (
sys_tone_id char(36) NOT NULL COMMENT 'id khóa chính',
tone_name varchar(255) DEFAULT NULL COMMENT 'Tên tone',
tone_type int(11) DEFAULT NULL COMMENT 'Loại tone',
sort_order int(11) DEFAULT NULL COMMENT 'Thứ tự sắp xếp',
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (sys_tone_id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 3276,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng sys loại tone';
--
-- Create table `tone`
--
CREATE TABLE tone (
tone_id char(36) NOT NULL,
sys_tone_id char(36) DEFAULT NULL,
user_id char(36) DEFAULT NULL,
tone_name varchar(255) DEFAULT NULL,
tone_type int(11) DEFAULT NULL,
sort_order int(11) DEFAULT NULL,
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (tone_id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 3276,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng danh sách tone';
--
-- Create foreign key
--
ALTER TABLE tone
ADD CONSTRAINT FK_tone_sys_tone_id FOREIGN KEY (sys_tone_id)
REFERENCES sys_tone (sys_tone_id) ON DELETE CASCADE;
--
-- Create foreign key
--
ALTER TABLE tone
ADD CONSTRAINT FK_tone_user_id FOREIGN KEY (user_id)
REFERENCES user (user_id) ON DELETE CASCADE;
--
-- Create table `sys_example_link`
--
CREATE TABLE sys_example_link (
sys_example_link_id char(36) NOT NULL COMMENT 'id khóa chính',
example_link_name varchar(255) DEFAULT NULL COMMENT 'Tên loại liên kết',
example_link_type int(11) DEFAULT NULL COMMENT 'Loại liên kết',
sort_order int(11) DEFAULT NULL COMMENT 'Thứ tự sắp xếp',
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (sys_example_link_id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 1820,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng sys loại liên kết giữa example với concept';
--
-- Create table `example_link`
--
CREATE TABLE example_link (
example_link_id char(36) NOT NULL COMMENT 'id khóa chính',
sys_example_link_id char(36) DEFAULT NULL COMMENT 'sys id',
user_id char(36) DEFAULT NULL COMMENT 'id người dùng',
example_link_name varchar(255) DEFAULT NULL COMMENT 'tên loại liên kết',
example_link_type int(11) DEFAULT NULL COMMENT 'loại liên kết',
sort_order int(11) DEFAULT NULL COMMENT 'thứ tự sắp xếp',
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (example_link_id)
)
ENGINE = INNODB,
AVG_ROW_LENGTH = 1820,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng chứa thông tin loại liên kết example-content';
--
-- Create foreign key
--
ALTER TABLE example_link
ADD CONSTRAINT FK_example_link_sys_example_link_id FOREIGN KEY (sys_example_link_id)
REFERENCES sys_example_link (sys_example_link_id) ON DELETE CASCADE;
--
-- Create foreign key
--
ALTER TABLE example_link
ADD CONSTRAINT FK_example_link_user_id FOREIGN KEY (user_id)
REFERENCES user (user_id) ON DELETE CASCADE;
DELIMITER $$
--
-- Create procedure `Proc_CreateActivatedAccountData`
--
CREATE
DEFINER = 'dev'@'%'
PROCEDURE Proc_CreateActivatedAccountData (IN $UserId char(36))
COMMENT 'Store khởi tạo bộ dữ liệu người dùng'
BEGIN
UPDATE user
SET status = 1
WHERE user_id = $UserId;
INSERT INTO dictionary (dictionary_id, user_id, dictionary_name, last_view_at, created_at, modified_at)
VALUES (UUID(), $UserId, 'My PVO', NULL, NOW(), NULL);
INSERT INTO concept_link (concept_link_id, sys_concept_link_id, user_id, concept_link_name, concept_link_type, sort_order, created_date, modified_date)
SELECT
UUID(),
scl.sys_concept_link_id,
$UserId,
scl.concept_link_name,
scl.concept_link_type,
scl.sort_order,
NOW(),
NULL
FROM sys_concept_link scl;
INSERT INTO example_link (example_link_id, sys_example_link_id, user_id, example_link_name, example_link_type, sort_order, created_date, modified_date)
SELECT
UUID(),
sel.sys_example_link_id,
$UserId,
sel.example_link_name,
sel.example_link_type,
sel.sort_order,
NOW(),
NULL
FROM sys_example_link sel;
INSERT INTO tone (tone_id, sys_tone_id, user_id, tone_name, tone_type, sort_order, created_date, modified_date)
SELECT
UUID(),
st.sys_tone_id,
$UserId,
st.tone_name,
st.tone_type,
st.sort_order,
NOW(),
NULL
FROM sys_tone st;
INSERT INTO mode (mode_id, sys_mode_id, user_id, mode_name, mode_type, sort_order, created_date, modified_date)
SELECT
UUID(),
sm.sys_mode_id,
$UserId,
sm.mode_name,
sm.mode_type,
sm.sort_order,
NOW(),
NULL
FROM sys_mode sm;
INSERT INTO register (register_id, sys_register_id, user_id, register_name, register_type, sort_order, created_date, modified_date)
SELECT
UUID(),
sr.sys_register_id,
$UserId,
sr.register_name,
sr.register_type,
sr.sort_order,
NOW(),
NULL
FROM sys_register sr;
INSERT INTO nuance (nuance_id, sys_nuance_id, user_id, nuance_name, nuance_type, sort_order, created_date, modified_date)
SELECT
UUID(),
sn.sys_nuance_id,
$UserId,
sn.nuance_name,
sn.nuance_type,
sn.sort_order,
NOW(),
NULL
FROM sys_nuance sn;
INSERT INTO dialect (dialect_id, sys_dialect_id, user_id, dialect_name, dialect_type, sort_order, created_date, modified_date)
SELECT
UUID(),
sd.sys_dialect_id,
$UserId,
sd.dialect_name,
sd.dialect_type,
sd.sort_order,
NOW(),
NULL
FROM sys_dialect sd;
END
$$
DELIMITER ;
--
-- Create table `example_relationship`
--
CREATE TABLE example_relationship (
example_relationship_id int(11) NOT NULL AUTO_INCREMENT COMMENT 'id khóa chính',
dictionary_id char(36) DEFAULT NULL COMMENT 'id dictionary',
content_id char(36) DEFAULT NULL,
example_id char(36) DEFAULT NULL,
example_link_id char(36) DEFAULT NULL,
created_date datetime DEFAULT NULL,
modified_date datetime DEFAULT NULL,
PRIMARY KEY (example_relationship_id)
)
ENGINE = INNODB,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = 'Bảng chứa liên kết example-content';
--
-- Create foreign key
--
ALTER TABLE example_relationship
ADD CONSTRAINT FK_example_relationship_content_id FOREIGN KEY (content_id)
REFERENCES concept (concept_id) ON DELETE CASCADE;
--
-- Create foreign key
--
ALTER TABLE example_relationship
ADD CONSTRAINT FK_example_relationship_dictionary_id FOREIGN KEY (dictionary_id)
REFERENCES dictionary (dictionary_id) ON DELETE CASCADE;
--
-- Create foreign key
--
ALTER TABLE example_relationship
ADD CONSTRAINT FK_example_relationship_example_id FOREIGN KEY (example_id)
REFERENCES example (example_id) ON DELETE CASCADE;
--
-- Create foreign key
--
ALTER TABLE example_relationship
ADD CONSTRAINT FK_example_relationship_example_link_id FOREIGN KEY (example_link_id)
REFERENCES example_link (example_link_id) ON DELETE CASCADE;
--
-- Dumping data for table user
--
INSERT INTO user VALUES
('8c38ae6f-223c-493a-b7a3-6a4122986848', 'hieu.pt183535@gmail.com', '$2a$11$AFRMhDiyFknixU019YEKiucLrfNLWD2A4AWXjwjOlO3gaItG4IKZW', 'hieu.pt183535@gmail.com', 'Phạm Trung Hiếu', 'Hieu Pham 1', '2000-11-03 00:00:00', 'Lập trình viên', 'https://firebasestorage.googleapis.com/v0/b/hust-pvo.appspot.com/o/Development%2Favatar%2F6cb65792-abbe-4bf3-a058-170d4cb780f3.png?alt=media&token=b75c28fa-57a2-47a6-990c-dd9f4095581e', 1, '2023-05-21 21:13:08', NULL),
('d2a85e00-4fc4-4cc9-845d-4ad90da292d5', 'thienthan.bayvut@gmail.com', '$2a$11$brGDuTjZh1oPvOnuw1V90ObBY8Kkyu0yzCZobw.sx80E18E5niyw6', 'thienthan.bayvut@gmail.com', NULL, NULL, NULL, NULL, NULL, 1, '2023-05-03 18:30:35', NULL);
--
-- Dumping data for table sys_example_link
--
INSERT INTO sys_example_link VALUES
('2d1bbd1d-dbfd-11ed-a1e6-a44cc8756a37', 'No link', 1, 1, '2023-04-16 09:19:32', NULL),
('2d1bc576-dbfd-11ed-a1e6-a44cc8756a37', 'Idiom', 2, 2, '2023-04-16 09:19:32', NULL),
('2d1bc640-dbfd-11ed-a1e6-a44cc8756a37', 'Nominal', 3, 3, '2023-04-16 09:19:32', NULL),
('2d1bc69a-dbfd-11ed-a1e6-a44cc8756a37', 'Agent', 4, 4, '2023-04-16 09:19:32', NULL),
('2d1bc6d7-dbfd-11ed-a1e6-a44cc8756a37', 'Patient', 5, 5, '2023-04-16 09:19:32', NULL),
('2d1bc70f-dbfd-11ed-a1e6-a44cc8756a37', 'Action', 6, 6, '2023-04-16 09:19:32', NULL),
('2d1bc745-dbfd-11ed-a1e6-a44cc8756a37', 'Described by', 7, 7, '2023-04-16 09:19:32', NULL),
('2d1bc783-dbfd-11ed-a1e6-a44cc8756a37', 'Describing', 8, 8, '2023-04-16 09:19:32', NULL),
('2d1bc88c-dbfd-11ed-a1e6-a44cc8756a37', 'Other phrase', 9, 9, '2023-04-16 09:19:32', NULL);
--
-- Dumping data for table dictionary
--
INSERT INTO dictionary VALUES
('753b1529-e9ae-11ed-9acb-a44cc8756a37', 'd2a85e00-4fc4-4cc9-845d-4ad90da292d5', 'My PVO', NULL, '2023-05-03 19:31:24', NULL);
--
-- Dumping data for table sys_concept_link
--