转php面试题有我的答案(九A)

来源:互联网 发布:重庆时时彩计划软件 编辑:程序博客网 时间:2024/05/21 13:30

sorry, 本人未能理解每种图书,是指图书类别,还是一个图书,具体的有多本。

 

/*==============================================================*/
/* DBMS name:      MySQL 4.0                                    */
/* Created on:     2007-10-25 20:43:34                          */
/*==============================================================*/


drop table if exists book;

drop table if exists bookDetail;

drop table if exists lend;

drop table if exists user;

/*==============================================================*/
/* Table: book   ,包括图书的一些具体信息                                               */
/*==============================================================*/
create table book
(
   b_id                           
int unsigned                   not null AUTO_INCREMENT,
   b_name                         
varchar(100)                   not null,
   b_author                       
varchar(30)                    not null,
   b_desc                         
text,
   b_price                        
dec(10,2)                      not null,
   b_isbn                         
varchar(30)                    not null,
   
primary key (b_id)
)
type 
= InnoDB;

/*==============================================================*/
/* Table: bookDetail              ,包括唯一编号,图书编号,入库日期,入库人                       */
/*==============================================================*/
create table bookDetail
(
   bd_id                          
int unsigned                   not null AUTO_INCREMENT,
   b_id                           
int unsigned,
   db_inTime                      
datetime                       not null,
   db_inUser                      
int                            not null,
   
primary key (bd_id)
)
type 
= InnoDB;

/*==============================================================*/
/* Index: "fk_Book_Detail_FK"                                            */
/*==============================================================*/
create index fk_Book_Detail_FK
(
   b_id
);

/*==============================================================*/
/* Table: lend   借阅信息,借出日期,借阅天数,实际归还的日期                */
/*==============================================================*/
create table lend
(
   u_id                           
int unsigned,
   bd_id                          
int unsigned,
   l_date                         date,
   l_backdate                     date,
   l_days                         
int unsigned
)
type 
= InnoDB;

/*==============================================================*/
/* Index: "fk_user_lend_FK"                                            */
/*==============================================================*/
create index fk_user_lend_FK
(
   u_id
);
/*==============================================================*/
/* Index: "fK_book_lend_FK"                                            */
/*==============================================================*/
create index fK_book_lend_FK
(
   bd_id
);

/*==============================================================*/
/* Table: user                        用户具体表                          */
/*==============================================================*/
create table user
(
   u_id                           
int unsigned                   not null AUTO_INCREMENT,
   u_name                         
varchar(30)                    not null,
   u_phone                        
varchar(30),
   u_address                      
varchar(200),
   u_booknum                      
int unsigned                   not null,
   
primary key (u_id)
)
type 
= InnoDB;

alter table bookDetail add constraint fk_BookType_Book foreign key (b_id)
      
references book (b_id) on delete restrict on update restrict;

alter table lend add constraint FK_fK_book_lend foreign key (bd_id)
      
references bookDetail (bd_id) on delete restrict on update restrict;

alter table lend add constraint FK_fk_user_lend foreign key (u_id)
      
references user (u_id) on delete restrict on update restrict;

原创粉丝点击