首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

Nutz+ExtJS示范教程——数据库设计

2012-09-07 
Nutz+ExtJS示例教程——数据库设计?/**//*

Nutz+ExtJS示例教程——数据库设计

?

/*==============================================================*//* DBMS name: MySQL 5.0 *//* Created on: 2011-2-20 23:25:35 *//*==============================================================*/drop index titleIndex on t_blog;drop index modifyTimeIndex on t_blog;drop table if exists t_blog;drop index emailIndex on t_contact;drop index cellphoneIndex on t_contact;drop index userNameIndex on t_contact;drop table if exists t_contact;drop index userTypeIndex on t_contact_type;drop table if exists t_contact_type;drop table if exists t_user;/*==============================================================*//* Table: t_blog *//*==============================================================*/create table t_blog( id int not null auto_increment comment '唯一主键', userId int comment '用户id', title varchar(100) comment '标题', content varchar(1000) comment '内容', isPublic varchar(4) comment '是否公开(1.私有 2.公开)', createTime timestamp comment '创建时间', modifyTime timestamp comment '修改时间', primary key (id));alter table t_blog comment '博客表';/*==============================================================*//* Index: modifyTimeIndex *//*==============================================================*/create index modifyTimeIndex on t_blog( modifyTime);/*==============================================================*//* Index: titleIndex *//*==============================================================*/create index titleIndex on t_blog( title);/*==============================================================*//* Table: t_contact *//*==============================================================*/create table t_contact( id int not null auto_increment comment '唯一主键', userId int comment '用户id', contactTypeId int comment '联系人类别Id', contactName varchar(50) comment '联系人名', sex varchar(10) comment '性别', birthday date comment '生日', telephone varchar(20) comment '电话', mobilephone varchar(20) comment '手机', qq varchar(20) comment 'QQ号', msn varchar(20) comment 'MSN号', email varchar(50) comment '电子邮件', address varchar(50) comment '家庭住址', remark varchar(100) comment '备注', primary key (id));alter table t_contact comment '联系人表';/*==============================================================*//* Index: userNameIndex *//*==============================================================*/create index userNameIndex on t_contact( contactName);/*==============================================================*//* Index: cellphoneIndex *//*==============================================================*/create index cellphoneIndex on t_contact( mobilephone);/*==============================================================*//* Index: emailIndex *//*==============================================================*/create index emailIndex on t_contact( email);/*==============================================================*//* Table: t_contact_type *//*==============================================================*/create table t_contact_type( id int not null auto_increment comment '唯一主键', userId int comment '用户id', typeName varchar(20) comment '类别名称', primary key (id));alter table t_contact_type comment '联系人类别表';/*==============================================================*//* Index: userTypeIndex *//*==============================================================*/create unique index userTypeIndex on t_contact_type( typeName);/*==============================================================*//* Table: t_user *//*==============================================================*/create table t_user( id int not null auto_increment comment '唯一主键', userName varchar(30) comment '用户名', password varchar(20) comment '密码', userType varchar(10) comment '用户类型(1.管理员 2.普通用户)', primary key (id));alter table t_user comment '用户表';alter table t_blog add constraint FK_Reference_4 foreign key (userId) references t_user (id) on delete restrict on update restrict;alter table t_contact add constraint FK_Reference_1 foreign key (contactTypeId) references t_contact_type (id) on delete restrict on update restrict;alter table t_contact add constraint FK_Reference_2 foreign key (userId) references t_user (id) on delete restrict on update restrict;alter table t_contact_type add constraint FK_Reference_3 foreign key (userId) references t_user (id) on delete restrict on update restrict;?

?

以上操作,其中关于Powerdesigner的使用问题,可以参照另一篇Blog(http://pangwu86.iteye.com/blog/910647),这里不再重复。

?

下一集,将开始讲述后台代码的Dao这层的编写。

?

1 楼 tywo45 2011-08-03   博主加油!

热点排行