diff --git "a/40 \346\227\266\345\255\246\345\256\211/\345\233\276\344\271\246\351\246\206\344\275\234\344\270\232.md" "b/40 \346\227\266\345\255\246\345\256\211/\345\233\276\344\271\246\351\246\206\344\275\234\344\270\232.md" new file mode 100644 index 0000000000000000000000000000000000000000..fa474d055e38bce82a0f38da798505199bc31ef3 --- /dev/null +++ "b/40 \346\227\266\345\255\246\345\256\211/\345\233\276\344\271\246\351\246\206\344\275\234\344\270\232.md" @@ -0,0 +1,294 @@ +~~~~mysql +~~~mysql + +~~~ + +/*==============================================================*/ +/* Index: Admin_PK */ +/*==============================================================*/ +create unique index Admin_PK on Admin ( +AdminID ASC +); + +/*==============================================================*/ +/* Index: 拥有_FK */ +/*==============================================================*/ +create index 拥有_FK on Admin ( +r_id ASC +); + +/*==============================================================*/ +/* Table: BookInfo */ +/*==============================================================*/ +create table BookInfo +( + BB—_id char(20) not null, + CC_id integer not null, + AdminID char(5) not null, + CataID char(5) not null, + BB_name char(20) not null, + B_Author char(5) not null, + Press char(20) not null, + Pubdate date not null, + Price numeric(5,1) not null, + B_RRID char(5) not null, + EnterTime timestamp not null, + BB_AdminID char(20) not null, + constraint PK_BOOKINFO primary key (BB—_id) +); + +/*==============================================================*/ +/* Index: BookInfo_PK */ +/*==============================================================*/ +create unique index BookInfo_PK on BookInfo ( +BB—_id ASC +); + +/*==============================================================*/ +/* Index: 包含_FK */ +/*==============================================================*/ +create index 包含_FK on BookInfo ( +CC_id ASC +); + +/*==============================================================*/ +/* Index: 管理1_FK */ +/*==============================================================*/ +create index 管理1_FK on BookInfo ( +AdminID ASC +); + +/*==============================================================*/ +/* Table: BorrowInfo */ +/*==============================================================*/ +create table BorrowInfo +( + b_id char(20) not null, + AdminID char(5) not null, + C_ID integer not null, + BB—_id char(20) not null, + re_id char(20) not null, + reader_id char(20) not null, + BookID char(20) not null, + Btime timestamp not null, + Deadline timestamp not null, + Rtime timestamp null, + State integer not null, + BAdminID char(20) not null, + constraint PK_BORROWINFO primary key (b_id) +); + +/*==============================================================*/ +/* Index: BorrowInfo_PK */ +/*==============================================================*/ +create unique index BorrowInfo_PK on BorrowInfo ( +b_id ASC +); + +/*==============================================================*/ +/* Index: 管理_FK */ +/*==============================================================*/ +create index 管理_FK on BorrowInfo ( +AdminID ASC +); + +/*==============================================================*/ +/* Index: jiaofei_FK */ +/*==============================================================*/ +create index jiaofei_FK on BorrowInfo ( +C_ID ASC +); + +/*==============================================================*/ +/* Index: 借阅1_FK */ +/*==============================================================*/ +create index 借阅1_FK on BorrowInfo ( +BB—_id ASC +); + +/*==============================================================*/ +/* Index: 借阅_FK */ +/*==============================================================*/ +create index 借阅_FK on BorrowInfo ( +re_id ASC +); + +/*==============================================================*/ +/* Table: Catagory */ +/*==============================================================*/ +create table Catagory +( + CC_id integer not null default (S_Catagory.nextval), + CC_name char(20) not null, + constraint PK_CATAGORY primary key (CC_id) +); + +/*==============================================================*/ +/* Index: Catagory_PK */ +/*==============================================================*/ +create unique index Catagory_PK on Catagory ( +CC_id ASC +); + +/*==============================================================*/ +/* Table: Charge */ +/*==============================================================*/ +create table Charge +( + C_ID integer not null, + AdminID char(5) not null, + b_id char(20) null, + C_BID integer not null, + Amount numeric(5,1) not null, + ExecTime timestamp not null, + C_AdminID char(20) not null, + constraint PK_CHARGE primary key (C_ID) +); + +/*==============================================================*/ +/* Index: Charge_PK */ +/*==============================================================*/ +create unique index Charge_PK on Charge ( +C_ID ASC +); + +/*==============================================================*/ +/* Index: 收费_FK */ +/*==============================================================*/ +create index 收费_FK on Charge ( +AdminID ASC +); + +/*==============================================================*/ +/* Index: jiaofei2_FK */ +/*==============================================================*/ +create index jiaofei2_FK on Charge ( +b_id ASC +); + +/*==============================================================*/ +/* Table: Privilege */ +/*==============================================================*/ +create table Privilege +( + Level integer not null, + MaxBookNum integer not null, + MaxDays integer not null, + constraint PK_PRIVILEGE primary key (Level) +); + +/*==============================================================*/ +/* Index: Privilege_PK */ +/*==============================================================*/ +create unique index Privilege_PK on Privilege ( +Level ASC +); + +/*==============================================================*/ +/* Table: ReaderInfo */ +/*==============================================================*/ +create table ReaderInfo +( + re_id char(20) not null, + Level integer not null, + re_name char(5) not null, + dept char(30) null, + re_pwd char(30) not null, + Regtime timestamp not null, + re_Le integer not null, + constraint PK_READERINFO primary key (re_id) +); + +/*==============================================================*/ +/* Index: ReaderInfo_PK */ +/*==============================================================*/ +create unique index ReaderInfo_PK on ReaderInfo ( +re_id ASC +); + +/*==============================================================*/ +/* Index: 限制_FK */ +/*==============================================================*/ +create index 限制_FK on ReaderInfo ( +Level ASC +); + +/*==============================================================*/ +/* Table: ReadingRoom */ +/*==============================================================*/ +create table ReadingRoom +( + r_id char(5) not null, + r_name char(30) not null, + r_address char(30) not null, + constraint PK_READINGROOM primary key (r_id) +); + +/*==============================================================*/ +/* Index: ReadingRoom_PK */ +/*==============================================================*/ +create unique index ReadingRoom_PK on ReadingRoom ( +r_id ASC +); + +alter table Admin + add constraint FK_ADMIN_拥有_READINGR foreign key (r_id) + references ReadingRoom (r_id) + on update restrict + on delete restrict; + +alter table BookInfo + add constraint FK_BOOKINFO_包含_CATAGORY foreign key (CC_id) + references Catagory (CC_id) + on update restrict + on delete restrict; + +alter table BookInfo + add constraint FK_BOOKINFO_管理1_ADMIN foreign key (AdminID) + references Admin (AdminID) + on update restrict + on delete restrict; + +alter table BorrowInfo + add constraint FK_BORROWIN_JIAOFEI_CHARGE foreign key (C_ID) + references Charge (C_ID) + on update restrict + on delete restrict; + +alter table BorrowInfo + add constraint FK_BORROWIN_借阅_READERIN foreign key (re_id) + references ReaderInfo (re_id) + on update restrict + on delete restrict; + +alter table BorrowInfo + add constraint FK_BORROWIN_借阅1_BOOKINFO foreign key (BB—_id) + references BookInfo (BB—_id) + on update restrict + on delete restrict; + +alter table BorrowInfo + add constraint FK_BORROWIN_管理_ADMIN foreign key (AdminID) + references Admin (AdminID) + on update restrict + on delete restrict; + +alter table Charge + add constraint FK_CHARGE_JIAOFEI2_BORROWIN foreign key (b_id) + references BorrowInfo (b_id) + on update restrict + on delete restrict; + +alter table Charge + add constraint FK_CHARGE_收费_ADMIN foreign key (AdminID) + references Admin (AdminID) + on update restrict + on delete restrict; + +alter table ReaderInfo + add constraint FK_READERIN_限制_PRIVILEG foreign key (Level) + references Privilege (Level) + on update restrict + on delete restrict;) + +~~~~ \ No newline at end of file