最近在学习新闻发布系统,本想在网上找相关代码的,但没找到合适的,所以自己就写了一下,想到肯定有些小伙伴会用到,所以阿伟把代码放在这里供大家使用。新闻发布系统主要分为两大模块:用户管理和新闻管理
首先我们来看用户管理模块数据库创建代码:
创建用户表(user):
create table user(
id int(11) not null primary key auto_increment,
username varchar(20) not null,
password varchar(18) not null,
sex varchar(1) not null comment "取值0:男,1:女",
profession varchar(1) comment "取值0:学生,1:老师,2:工人",
favourite varchar(255) comment "取值0:电脑网络,1:影视娱乐,2:棋牌娱乐",
note varchar(255),
type varchar(1) comment "取值0:普通用户,1:管理员,默认为0"
);
创建新闻表(news):
create table news(id int(11) not null primary key auto_increment comment "自动增长",
title varchar(50) not null,
content text,
userid int(11) not null comment "引用用户表主键",
pubtime datetime not null,foreign key(userid) references user(id));