📄 图书_管理.sql
字号:
/*==============================================================*/
/* DBMS name: Microsoft SQL Server 2000 */
/* Created on: 2007-12-15 12:53:49 */
/*==============================================================*/
alter table 借阅信息
drop constraint FK_借阅信息_借阅信息管理_管理员
go
alter table 借阅信息
drop constraint FK_借阅信息_借阅图书登记2_图书
go
alter table 借阅信息
drop constraint FK_借阅信息_借阅者登记_用户
go
alter table 图书
drop constraint FK_图书_图书信息管理_管理员
go
alter table 用户
drop constraint 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 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
/*==============================================================*/
/* Table: 借阅信息 */
/*==============================================================*/
create table 借阅信息 (
图书编号 char(12) null,
用户编号 char(8) null,
管理员编号 char(8) null,
编号 char(8) not null,
借书日期 datetime null,
续借次数 char(1) null,
还书日期 datetime null,
constraint AK_编号_借阅信息 unique (编号)
)
go
/*==============================================================*/
/* Index: 借阅信息管理_FK */
/*==============================================================*/
create index 借阅信息管理_FK on 借阅信息 (
管理员编号 ASC
)
go
/*==============================================================*/
/* Table: 图书 */
/*==============================================================*/
create table 图书 (
管理员编号 char(8) null,
图书编号 char(12) not null,
图书名称 varchar(50) null,
出版社 varchar(50) null,
作者 varchar(20) null,
单价 float(5) null,
借阅状态 char(1) null,
constraint AK_图书编号_图书 unique (图书编号)
)
go
/*==============================================================*/
/* Index: 图书信息管理_FK */
/*==============================================================*/
create index 图书信息管理_FK on 图书 (
管理员编号 ASC
)
go
/*==============================================================*/
/* Table: 用户 */
/*==============================================================*/
create table 用户 (
管理员编号 char(8) null,
用户编号 char(8) not null,
用户姓名 char(8) null,
用户密码 char(6) null,
性别 char(2) null,
所在学院 char(20) null,
借阅本数 char(2) null,
constraint AK_用户编号_用户 unique (用户编号)
)
go
/*==============================================================*/
/* Index: 用户信息管理_FK */
/*==============================================================*/
create index 用户信息管理_FK on 用户 (
管理员编号 ASC
)
go
/*==============================================================*/
/* Table: 管理员 */
/*==============================================================*/
create table 管理员 (
管理员编号 char(8) not null,
管理员姓名 char(8) null,
管理员密码 char(6) null,
管理员权限 char(1) null,
constraint AK_管理员编号_管理员 unique (管理员编号)
)
go
alter table 借阅信息
add constraint FK_借阅信息_借阅信息管理_管理员 foreign key (管理员编号)
references 管理员 (管理员编号)
go
alter table 借阅信息
add constraint FK_借阅信息_借阅图书登记2_图书 foreign key (图书编号)
references 图书 (图书编号)
go
alter table 借阅信息
add constraint FK_借阅信息_借阅者登记_用户 foreign key (用户编号)
references 用户 (用户编号)
go
alter table 图书
add constraint FK_图书_图书信息管理_管理员 foreign key (管理员编号)
references 管理员 (管理员编号)
go
alter table 用户
add constraint FK_用户_用户信息管理_管理员 foreign key (管理员编号)
references 管理员 (管理员编号)
go
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -