使用数据库设计工具,以下sql语句全部可以自动生成:
/*==============================================================*/
/* DBMS name: MySQL 5.0 */
/* Created on: 2017/5/27 0:57:18 */
/*==============================================================*/
drop table if exists Teacher;
drop table if exists course;
drop table if exists teach;
/*==============================================================*/
/* Table: Teacher */
/*==============================================================*/
create table Teacher
(
tid int not null,
teacherName varchar(20) not null,
sex char(1) not null default 'm',
birthday date,
major varchar(30),
primary key (tid)
);
alter table Teacher comment '教师实体对象,存放教师信息';
/*==============================================================*/
/* Table: course */
/*==============================================================*/
create table course
(
cid int not null,
cname varchar(20) not null,
chour int,
credit numeric(2,0),
primary key (cid)
);
alter table course comment '课程信息';
/*==============================================================*/
/* Table: teach */
/*==============================================================*/
create table teach
(
tid int not null,
cid int not null,
starttime datetime,
primary key (tid, cid)
);
alter table teach add constraint FK_teach foreign key (tid)
references Teacher (tid) on delete restrict on update restrict;
alter table teach add constraint FK_teach2 foreign key (cid)
references course (cid) on delete restrict on update restrict;
只要建立实体,添加实体间属性,实体间关系表也可以自动生成。如下图:
PowerDsigner的具体使用方法大家可以百度一个PDF文件或者视频学习。
PowerDesigner下载攻略:
先百度
找破解方案
按照破解文档操作即可使用。
亲测最简便上手方案。
关于数据库的设计等问题在我之前的博客中都有分享哦。