SSS MySQL数据库建库脚本


/*==============================================================*/
/* DBMS name:      MySQL 5.0                                    */
/* Created on:     2006-10-29 11:37:05 上午                       */
/*==============================================================*/

use sss;

drop table if exists FS_In_Project;

drop table if exists Fiber;

drop table if exists FluxStandard;

drop table if exists GS_In_Project;

drop table if exists GuideStar;

drop table if exists OBJ_In_Project;

drop table if exists Object;

drop table if exists Project;

drop table if exists SK_In_Project;

drop table if exists SkyLight;

/*==============================================================*/
/* Table: FS_In_Project                                         */
/*==============================================================*/
create table FS_In_Project
(
   FS_ID                numeric(10,0) not null,
   PROJECT_ID           numeric(10,0) not null,
   FIBER_ID             numeric(4,0) not null,
   primary key (FS_ID, PROJECT_ID)
);

/*==============================================================*/
/* Table: Fiber                                                 */
/*==============================================================*/
create table Fiber
(
   FIBER_ID             numeric(4,0) not null,
   FIBER_X              numeric(8,5),
   FIBER_Y              numeric(8,5),
   FIBER_R              numeric(8,5),
   FIBER_STATUS         numeric(2,0),
   primary key (FIBER_ID)
);

/*==============================================================*/
/* Table: FluxStandard                                          */
/*==============================================================*/
create table FluxStandard
(
   FS_ID                numeric(10,0) not null,
   FS_RA                numeric(8,5),
   FS_DE                numeric(8,5),
   FS_MAG               numeric(4,2),
   primary key (FS_ID)
);

/*==============================================================*/
/* Table: GS_In_Project                                         */
/*==============================================================*/
create table GS_In_Project
(
   GS_ID                numeric(10,0) not null,
   PROJECT_ID           numeric(10,0) not null,
   primary key (GS_ID, PROJECT_ID)
);

/*==============================================================*/
/* Table: GuideStar                                             */
/*==============================================================*/
create table GuideStar
(
   GS_ID                numeric(10,0) not null,
   GS_RA                numeric(8,5),
   GS_DE                numeric(8,5),
   GS_MAG               numeric(4,2),
   primary key (GS_ID)
);

/*==============================================================*/
/* Table: OBJ_In_Project                                        */
/*==============================================================*/
create table OBJ_In_Project
(
   OBJ_ID               numeric(10,0) not null,
   PROJECT_ID           numeric(10,0) not null,
   FIBER_ID             numeric(4,0) not null,
   primary key (OBJ_ID, PROJECT_ID)
);

/*==============================================================*/
/* Table: Object                                                */
/*==============================================================*/
create table Object
(
   OBJ_ID               numeric(10,0) not null,
   OBJ_RA               numeric(8,5),
   OBJ_DE               numeric(8,5),
   OBJ_MAG              numeric(4,2),
   OBJ_SOURCE           text,
   OBJ_PRI              numeric(2,0),
   OBJ_STATUS           numeric(2,0),
   primary key (OBJ_ID)
);

/*==============================================================*/
/* Table: Project                                               */
/*==============================================================*/
create table Project
(
   PROJECT_ID           numeric(10,0) not null,
   PROJECT_CRA          numeric(8,5),
   PROJECT_CDE          numeric(8,5),
   PROJECT_BEGINTIME    datetime,
   PROJECT_REMARK       text,
   primary key (PROJECT_ID)
);

/*==============================================================*/
/* Table: SK_In_Project                                         */
/*==============================================================*/
create table SK_In_Project
(
   SK_ID                numeric(10,0) not null,
   PROJECT_ID           numeric(10,0) not null,
   FIBER_ID             numeric(4,0) not null,
   primary key (SK_ID, PROJECT_ID)
);

/*==============================================================*/
/* Table: SkyLight                                              */
/*==============================================================*/
create table SkyLight
(
   SK_ID                numeric(10,0) not null,
   SK_RA                numeric(8,5),
   SK_DE                numeric(8,5),
   primary key (SK_ID)
);

alter table FS_In_Project add constraint FK_FS_In_Project foreign key (FS_ID)
      references FluxStandard (FS_ID) on delete restrict on update restrict;

alter table FS_In_Project add constraint FK_FS_In_Project2 foreign key (PROJECT_ID)
      references Project (PROJECT_ID) on delete restrict on update restrict;

alter table FS_In_Project add constraint FK_FS_In_Project3 foreign key (FIBER_ID)
      references Fiber (FIBER_ID) on delete restrict on update restrict;

alter table GS_In_Project add constraint FK_GS_In_Project foreign key (GS_ID)
      references GuideStar (GS_ID) on delete restrict on update restrict;

alter table GS_In_Project add constraint FK_GS_In_Project2 foreign key (PROJECT_ID)
      references Project (PROJECT_ID) on delete restrict on update restrict;

alter table OBJ_In_Project add constraint FK_OBJ_In_Project foreign key (OBJ_ID)
      references Object (OBJ_ID) on delete restrict on update restrict;

alter table OBJ_In_Project add constraint FK_OBJ_In_Project2 foreign key (PROJECT_ID)
      references Project (PROJECT_ID) on delete restrict on update restrict;

alter table OBJ_In_Project add constraint FK_OBJ_In_Project3 foreign key (FIBER_ID)
      references Fiber (FIBER_ID) on delete restrict on update restrict;

alter table SK_In_Project add constraint FK_SK_In_Project foreign key (SK_ID)
      references SkyLight (SK_ID) on delete restrict on update restrict;

alter table SK_In_Project add constraint FK_SK_In_Project2 foreign key (PROJECT_ID)
      references Project (PROJECT_ID) on delete restrict on update restrict;

alter table SK_In_Project add constraint FK_SK_In_Project3 foreign key (FIBER_ID)
      references Fiber (FIBER_ID) on delete restrict on update restrict;

 

你可能感兴趣的:(mysql,数据库,object,table,null,delete)