📄 crebas.sql
字号:
/*==============================================================*/
/* Database name: data base design */
/* DBMS name: Microsoft SQL Server 2000 */
/* Created on: 2005-6-28 :15:15 */
/*==============================================================*/
alter table 参与
drop constraint FK_参与_参与_教学管理人员
go
alter table 参与
drop constraint FK_参与_参与2_委员会
go
alter table 单位
drop constraint FK_单位_任职于1_学生工作人员
go
alter table 管理
drop constraint FK_管理_管理_教学管理人员
go
alter table 管理
drop constraint FK_管理_管理2_班级
go
alter table 任职于
drop constraint FK_任职于_任职于_教学管理人员
go
alter table 任职于
drop constraint FK_任职于_任职于2_单位
go
alter table 学生
drop constraint FK_学生_属于_班级
go
if exists (select 1
from sysindexes
where id = object_id('参与')
and name = '参与2_FK'
and indid > 0
and indid < 255)
drop index 参与.参与2_FK
go
if exists (select 1
from sysindexes
where id = object_id('参与')
and name = '参与_FK'
and indid > 0
and indid < 255)
drop index 参与.参与_FK
go
if exists (select 1
from sysindexes
where id = object_id('单位')
and name = '任职于1_FK'
and indid > 0
and indid < 255)
drop index 单位.任职于1_FK
go
if exists (select 1
from sysindexes
where id = object_id('管理')
and name = '管理2_FK'
and indid > 0
and indid < 255)
drop index 管理.管理2_FK
go
if exists (select 1
from sysindexes
where id = object_id('管理')
and name = '管理_FK'
and indid > 0
and indid < 255)
drop index 管理.管理_FK
go
if exists (select 1
from sysindexes
where id = object_id('任职于')
and name = '任职于2_FK'
and indid > 0
and indid < 255)
drop index 任职于.任职于2_FK
go
if exists (select 1
from sysindexes
where id = object_id('任职于')
and name = '任职于_FK'
and indid > 0
and indid < 255)
drop index 任职于.任职于_FK
go
if exists (select 1
from sysindexes
where id = object_id('学生')
and name = '属于_FK'
and indid > 0
and indid < 255)
drop index 学生.属于_FK
go
if exists (select 1
from sysobjects
where id = object_id('班级')
and type = 'U')
drop table 班级
go
if exists (select 1
from sysobjects
where id = object_id('参与')
and type = 'U')
drop table 参与
go
if exists (select 1
from sysobjects
where id = object_id('单位')
and type = 'U')
drop table 单位
go
if exists (select 1
from sysobjects
where id = object_id('管理')
and type = 'U')
drop table 管理
go
if exists (select 1
from sysobjects
where id = object_id('教学管理人员')
and type = 'U')
drop table 教学管理人员
go
if exists (select 1
from sysobjects
where id = object_id('任职于')
and type = 'U')
drop table 任职于
go
if exists (select 1
from sysobjects
where id = object_id('委员会')
and type = 'U')
drop table 委员会
go
if exists (select 1
from sysobjects
where id = object_id('学生')
and type = 'U')
drop table 学生
go
if exists (select 1
from sysobjects
where id = object_id('学生工作人员')
and type = 'U')
drop table 学生工作人员
go
/*==============================================================*/
/* Table: 班级 */
/*==============================================================*/
create table 班级 (
class_no int not null,
admittedDate datetime not null,
constraint PK_班级 primary key (class_no, admittedDate)
)
go
/*==============================================================*/
/* Table: 参与 */
/*==============================================================*/
create table 参与 (
ID int not null,
name4 char(20) not null,
constraint PK_参与 primary key (ID, name4)
)
go
/*==============================================================*/
/* Index: 参与_FK */
/*==============================================================*/
create index 参与_FK on 参与 (
ID
)
go
/*==============================================================*/
/* Index: 参与2_FK */
/*==============================================================*/
create index 参与2_FK on 参与 (
name4
)
go
/*==============================================================*/
/* Table: 单位 */
/*==============================================================*/
create table 单位 (
name char(20) not null,
ID2 int null,
Room int null,
leader2 char(10) null,
constraint PK_单位 primary key (name)
)
go
/*==============================================================*/
/* Index: 任职于1_FK */
/*==============================================================*/
create index 任职于1_FK on 单位 (
ID2
)
go
/*==============================================================*/
/* Table: 管理 */
/*==============================================================*/
create table 管理 (
ID int not null,
class_no int not null,
admittedDate datetime not null,
constraint PK_管理 primary key (ID, class_no, admittedDate)
)
go
/*==============================================================*/
/* Index: 管理_FK */
/*==============================================================*/
create index 管理_FK on 管理 (
ID
)
go
/*==============================================================*/
/* Index: 管理2_FK */
/*==============================================================*/
create index 管理2_FK on 管理 (
class_no,
admittedDate
)
go
/*==============================================================*/
/* Table: 教学管理人员 */
/*==============================================================*/
create table 教学管理人员 (
name2 char(20) null,
sex char(2) null,
degree char(10) null,
AcdemicPost char(10) null,
resume char(300) null,
Age2 int null,
ID int not null,
constraint PK_教学管理人员 primary key (ID)
)
go
/*==============================================================*/
/* Table: 任职于 */
/*==============================================================*/
create table 任职于 (
ID int not null,
name char(20) not null,
constraint PK_任职于 primary key (ID, name)
)
go
/*==============================================================*/
/* Index: 任职于_FK */
/*==============================================================*/
create index 任职于_FK on 任职于 (
ID
)
go
/*==============================================================*/
/* Index: 任职于2_FK */
/*==============================================================*/
create index 任职于2_FK on 任职于 (
name
)
go
/*==============================================================*/
/* Table: 委员会 */
/*==============================================================*/
create table 委员会 (
name4 char(20) not null,
leader char(10) null,
constraint PK_委员会 primary key (name4)
)
go
/*==============================================================*/
/* Table: 学生 */
/*==============================================================*/
create table 学生 (
name3 char(20) null,
sex2 char(2) null,
isPoor bit null,
Age3 int null,
ID3 int not null,
class_no int null,
admittedDate datetime null,
constraint PK_学生 primary key (ID3)
)
go
/*==============================================================*/
/* Index: 属于_FK */
/*==============================================================*/
create index 属于_FK on 学生 (
class_no,
admittedDate
)
go
/*==============================================================*/
/* Table: 学生工作人员 */
/*==============================================================*/
create table 学生工作人员 (
name5 char(20) null,
sex3 char(2) null,
Age int null,
ID2 int not null,
constraint PK_学生工作人员 primary key (ID2)
)
go
alter table 参与
add constraint FK_参与_参与_教学管理人员 foreign key (ID)
references 教学管理人员 (ID)
go
alter table 参与
add constraint FK_参与_参与2_委员会 foreign key (name4)
references 委员会 (name4)
go
alter table 单位
add constraint FK_单位_任职于1_学生工作人员 foreign key (ID2)
references 学生工作人员 (ID2)
go
alter table 管理
add constraint FK_管理_管理_教学管理人员 foreign key (ID)
references 教学管理人员 (ID)
go
alter table 管理
add constraint FK_管理_管理2_班级 foreign key (class_no, admittedDate)
references 班级 (class_no, admittedDate)
go
alter table 任职于
add constraint FK_任职于_任职于_教学管理人员 foreign key (ID)
references 教学管理人员 (ID)
go
alter table 任职于
add constraint FK_任职于_任职于2_单位 foreign key (name)
references 单位 (name)
go
alter table 学生
add constraint FK_学生_属于_班级 foreign key (class_no, admittedDate)
references 班级 (class_no, admittedDate)
go
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -