一个菜鸟正在用SSH写一个论坛(1)
嗯。。搞定了注册和登录,说明我的SSH整合已经没有问题了,那么我就继续折腾了。
我的目的是用SSH框架写一个论坛(当然是功能最简单的那种),搞定了整合之后我打算先做出一些基本的功能,于是我就先简单的设计了一下数据库。
1 /*==============================================================*/ 2 /* DBMS name: MySQL 5.0 */ 3 /* Created on: 2015/9/17 17:21:07 */ 4 /*==============================================================*/ 5 6 7 drop table if exists BM; 8 9 drop table if exists borad; 10 11 drop table if exists post; 12 13 drop table if exists reply; 14 15 drop table if exists userinfo; 16 17 /*==============================================================*/ 18 /* Table: BM */ 19 /*==============================================================*/ 20 create table BM 21 ( 22 BM_id int not null, 23 user_id int, 24 borad_id int, 25 primary key (BM_id) 26 ); 27 28 /*==============================================================*/ 29 /* Table: borad */ 30 /*==============================================================*/ 31 create table borad 32 ( 33 borad_id int not null, 34 borad_name char(20) not null, 35 primary key (borad_id) 36 ); 37 38 /*==============================================================*/ 39 /* Table: post */ 40 /*==============================================================*/ 41 create table post 42 ( 43 post_id int not null, 44 user_id int, 45 borad_id int, 46 post_title char(20) not null, 47 post_createtime timestamp not null, 48 post_updatetime timestamp not null, 49 post_replytime timestamp not null, 50 post_readtimes int not null, 51 post_content char(200), 52 primary key (post_id) 53 ); 54 55 /*==============================================================*/ 56 /* Table: reply */ 57 /*==============================================================*/ 58 create table reply 59 ( 60 reply_id int not null, 61 post_id int, 62 user_id int, 63 reply_content char(200) not null, 64 reply_createtime timestamp not null, 65 primary key (reply_id) 66 ); 67 68 /*==============================================================*/ 69 /* Table: userinfo */ 70 /*==============================================================*/ 71 create table userinfo 72 ( 73 user_id int not null, 74 user_name char(20) not null, 75 user_passwrod char(20) not null, 76 user_nickname char(20) not null, 77 user_image char(50) not null, 78 primary key (user_id) 79 ); 80 81 alter table BM add constraint FK_Relationship_1 foreign key (user_id) 82 references userinfo (user_id) on delete restrict on update restrict; 83 84 alter table BM add constraint FK_Relationship_2 foreign key (borad_id) 85 references borad (borad_id) on delete restrict on update restrict; 86 87 alter table post add constraint FK_Relationship_4 foreign key (user_id) 88 references userinfo (user_id) on delete restrict on update restrict; 89 90 alter table post add constraint FK_Relationship_5 foreign key (borad_id) 91 references borad (borad_id) on delete restrict on update restrict; 92 93 alter table reply add constraint FK_Relationship_6 foreign key (post_id) 94 references post (post_id) on delete restrict on update restrict; 95 96 alter table reply add constraint FK_Relationship_7 foreign key (user_id) 97 references userinfo (user_id) on delete restrict on update restrict;
这是用PowerDesigner创建了LogicalModel然后生成的MySql代码。*.hbm.xml就不放上来了。