使用SSM开发博客网站

一、需求分析,形成数据库图

  1. 分析功能模块:

 

  1. 数据库模型


二、建立数据库表:

DROP DATABASE IF EXISTS blog;
create database blog DEFAULT CHARACTER SET utf8;
USE blog;
CREATE TABLE user (
  id int(11) NOT NULL AUTO_INCREMENT,
  name varchar(255) DEFAULT NULL,
  password varchar(255) DEFAULT NULL,
	isadministrator boolean ,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE userdetail (
  id int(11) NOT NULL AUTO_INCREMENT,
	uid int(11) DEFAULT NULL,
  name varchar(255) DEFAULT NULL,
  birthday varchar(255) DEFAULT NULL,
	hobby varchar(255) DEFAULT NULL ,
	sex varchar(255) DEFAULT NULL , 
  PRIMARY KEY (id),
	CONSTRAINT fk_userdetail_user FOREIGN KEY (uid) REFERENCES user (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE like_ (
  id int(11) NOT NULL AUTO_INCREMENT,
  uid int(11) DEFAULT NULL,
  like_uid int(11) DEFAULT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE notice (
  id int(11) NOT NULL AUTO_INCREMENT,
  uid int(11) DEFAULT NULL,
  context_ text DEFAULT NULL,
  PRIMARY KEY (id),
  CONSTRAINT fk_notice_user FOREIGN KEY (uid) REFERENCES user (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE category (
  id int(11) NOT NULL AUTO_INCREMENT,
  name varchar(255) DEFAULT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE article (
  id int(11) NOT NULL AUTO_INCREMENT,
	uid int(11) DEFAULT NULL,
	category_id int(11) DEFAULT NULL,
  title varchar(255) DEFAULT NULL,
	keyword varchar(255) DEFAULT NULL,
	viewcount int(11) DEFAULT NULL,
	context_ text DEFAULT NULL,
	createdate datetime DEFAULT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE picture (
  id int(11) NOT NULL AUTO_INCREMENT,
	type_ varchar(255) DEFAULT NULL,
	uid int(11) DEFAULT NULL,
  article_id int(11) DEFAULT NULL,
  PRIMARY KEY (id),
	CONSTRAINT fk_picture_user FOREIGN KEY (uid) REFERENCES user (id),
	CONSTRAINT fk_picture_article FOREIGN KEY (article_id) REFERENCES article (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE review (
  id int(11) NOT NULL AUTO_INCREMENT,
	uid int(11) DEFAULT NULL,
  article_id int(11) DEFAULT NULL,
	context_ text DEFAULT NULL,
	createdate datetime DEFAULT NULL,
  PRIMARY KEY (id),
	CONSTRAINT fk_review_user FOREIGN KEY (uid) REFERENCES user (id),
	CONSTRAINT fk_review_article FOREIGN KEY (article_id) REFERENCES article (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE reply (
  id int(11) NOT NULL AUTO_INCREMENT,
	review_id int(11) DEFAULT NULL,
  uid int(11) DEFAULT NULL,
	context_ text DEFAULT NULL,
	createdate datetime DEFAULT NULL,
  PRIMARY KEY (id),
	CONSTRAINT fk_reply_user FOREIGN KEY (uid) REFERENCES user (id),
	CONSTRAINT fk_reply_review FOREIGN KEY (review_id) REFERENCES review (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


表结构:

                    


二、后台开发

  1.     

没有更多推荐了,返回首页