【正文】
if exists (select 1 from sysobjects where id = object_id(39。) drop table 上課goif exists (select 1 from sysobjects where id = object_id(39。) drop table 學生goif exists (select 1 from sysobjects where id = object_id(39。) drop table 教學樓goif exists (select 1 from sysobjects where id = object_id(39。) drop table 教室goif exists (select 1 from sysobjects where id = object_id(39。) drop table 教室借用goif exists (select 1 from sysobjects where id = object_id(39。) drop table 教師goif exists (select 1 from sysobjects where id = object_id(39。) drop table 課程goif exists (select 1 from sysobjects where id = object_id(39。) drop table 院系go/*==============================================================*//* Table: Association_3 *//*==============================================================*/create table Association_3 ( 課程號 char(10) not null, 教室編號 char(10) not null, constraint PK_ASSOCIATION_3 primary key (課程號, 教室編號))go/*==============================================================*//* Index: Association_3_FK *//*==============================================================*/create index Association_3_FK on Association_3 (課程號 ASC)go/*==============================================================*//* Index: Association_4_FK *//*==============================================================*/create index Association_4_FK on Association_3 (教室編號 ASC)go/*==============================================================*//* Table: 上課 *//*==============================================================*/create table 上課 ( 教師_教師編號 char(20) not null, 課程_課程號 char(10) not null, 教室_教室編號 char(10) not null, 教室編號 char(10) not null, 上課時間 datetime not null, 上課時間段 datetime not null, 教師編號 char(20) null, 課程號 char(10) null, constraint PK_上課 primary key (教師_教師編號, 課程_課程號, 教室_教室編號))go/*==============================================================*//* Index: 上課_FK *//*==============================================================*/create index 上課_FK on 上課 (教師_教師編號 ASC)go/*==============================================================*//* Index: 上課2_FK *//*==============================================================*/create index 上課2_FK on 上課 (課程_課程號 ASC)go/*==============================================================*//* Index: 上課3_FK *//*==============================================================*/create index 上課3_FK on 上課 (教室_教室編號 ASC)go/*==============================================================*//* Table: 學生 *//*==============================================================*/create table 學生 ( 學號 char(20) not null, 院系_院系號 char(10) null, 院系_院系號2 char(10) null, 姓名 char(10) null, 身份證號 char(20) null, 院系號 char(10) null, constraint PK_學生 primary key nonclustered (學號))go/*==============================================================*//* Index: Relation