Springboot系列 1 - 簡單個人博客數據庫結構設計


要搭建博客系統,首先要做的就是搭建一個數據庫。

我們選擇的數據庫是MySQL5.7,安裝教程請自行百度。

數據庫建模工具是PowerDesigner16.6,下載及安裝教程也請自行百度。

既然是簡單的博客系統,我只簡單的建立了幾張必要的表(為了保持系統簡潔,og表什么暫時不添加了,后期需要再添加),分別為:

sys_user:系統用戶表

t_article:文章表

t_content:文章內容表

t_comment:文章評論表

t_category:文章分類表

數據庫結構見下圖

SQL建表語句

 1 /*==============================================================*/
 2 /* Table: sys_user                                              */
 3 /*==============================================================*/
 4 create table sys_user
 5 (
 6    id                   int not null auto_increment  comment '',
 7    user_name            varchar(20)  comment '',
 8    hashed_password      varchar(50)  comment '',
 9    primary key (id)
10 );
11 
12 /*==============================================================*/
13 /* Table: t_article                                             */
14 /*==============================================================*/
15 create table t_article
16 (
17    id                   int(11) not null auto_increment  comment '',
18    title                varchar(50)  comment '',
19    submit               varchar(300)  comment '',
20    is_top               tinyint  comment '',
21    category_id          int  comment '',
22    create_time          datetime  comment '',
23    modified_time        char(10)  comment '',
24    primary key (id)
25 );
26 
27 /*==============================================================*/
28 /* Table: t_category                                            */
29 /*==============================================================*/
30 create table t_category
31 (
32    id                   int(11) not null auto_increment  comment '',
33    category_name        varchar(50)  comment '',
34    article_number       int  comment '',
35    primary key (id)
36 );
37 
38 /*==============================================================*/
39 /* Table: t_comment                                             */
40 /*==============================================================*/
41 create table t_comment
42 (
43    id                   int(11) not null auto_increment comment '',
44    comment_content      text  comment '',
45    name                 varchar(20)  comment '',
46    email                varchar(50)  comment '',
47    ip_address           varchar(15)  comment '',
48    volt_number          int  comment '',
49    article_id           int(11)  comment '',
50    parent_id            int(11)  comment '',
51    is_auther            tinyint  comment '',
52    primary key (id)
53 );
54 
55 /*==============================================================*/
56 /* Table: t_content                                             */
57 /*==============================================================*/
58 create table t_content
59 (
60    id                   int(11) not null auto_increment comment '',
61    article_id           int(11)  comment '',
62    content              text  comment '',
63    primary key (id)
64 );
65 
66 alter table t_article add constraint FK_T_ARTICL_REFERENCE_T_CATEGO foreign key (category_id)
67       references t_category (id) on delete restrict on update restrict;
68 
69 alter table t_comment add constraint FK_T_COMMEN_REFERENCE_T_ARTICL foreign key (article_id)
70       references t_article (id) on delete restrict on update restrict;
71 
72 alter table t_comment add constraint FK_T_COMMEN_REFERENCE_T_COMMEN foreign key (parent_id)
73       references t_comment (id) on delete restrict on update restrict;
74 
75 alter table t_content add constraint FK_T_CONTEN_REFERENCE_T_ARTICL foreign key (article_id)
76       references t_article (id) on delete restrict on update restrict;

基礎工作就到這里了,下一步馬上進入我們正式的springboot學習了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM