/********************************************************************/
/* Filename : FT_CREATETABLE_FITS.SQL                               */
/* Author   : Nicolas Morisset                                      */
/* Date     : 22-JUL-1997                                           */
/* Purpose  :                                                       */
/* Drop and  create the FITS table used to store information about  */
/* the FITS files built from the CD-Roms data.                      */
/*                                                                  */
/* Description :                                                    */
/*                                                                  */
/*                     Table description                            */
/* SUMER_FITS :                                                     */
/*     filename   -> FITS file name                                 */
/*     date_obs   -> Start observation date                         */
/*     date_end   -> End observation date                           */
/*     study_id   -> Study id                                       */
/*     udp_slot   -> Udp slot                                       */
/*     prog_type  -> Program type, UDP or POP                       */
/*     slit       -> Slit number                                    */
/*     detector   -> Detector type                                  */
/*     wavemax    -> Wavelength max                                 */
/*     wavemin    -> Wavelength min                                 */
/*     ins_x      -> Solar X, Extrat from INS_X(Primary FITS Header)*/
/*     ins_y      -> Solar Y, Extrat from INS_Y(Primary FITS Header)*/
/*     id_dir     -> Ident used for the R_DIRNAME table             */
/*                                                                  */
/* R_DIRNAME :                                                      */
/*     dir_id     -> Primary Key                                    */
/*     dir_name   -> Directory name                                 */
/*                                                                  */
/********************************************************************/


/* Create log file */
/*-----------------*/
SPOOL createtable_fits.log

/* Drop table */
/*------------*/
DROP TABLE SUMER_FITS;


/* Create tables */
/*---------------*/
CREATE TABLE SUMER_FITS 
  (
       CONSTRAINT pk_filename PRIMARY KEY (filename)                           ,
       filename varchar(30)    CONSTRAINT filename NOT NULL                    ,
       date_obs   number(15,3) CONSTRAINT date_obs NOT NULL                    ,
       date_end   number(15,3)                                                 ,
       study_id   number(5)    CONSTRAINT study_id NOT NULL                    ,  
       udp_slot   number(2)                                                    ,
       prog_typ   number(1)                                                    ,
       slit       number(1)                                                    ,
       detector   varchar(3)                                                   ,
       wavemax    number(9,3)                                                  ,
       wavemin    number(9,3)                                                  ,
       ins_x      number(8,2)                                                  ,
       ins_y      number(8,2)                                                  ,
       CONSTRAINT fk_dir_id FOREIGN KEY (dir_id) REFERENCES R_DIRNAME(dir_id)  ,
       dir_id     number(3)  CONSTRAINT dir_id   NOT NULL
  );


/* Structure of R_DIRNAME table */
/*------------------------------*/
/*               Table not created by default                   */
/* CREATE TABLE R_DIRNAME                                       */          
/*  (                                                           */
/*   CONSTRAINT pk_dir_id PRIMARY KEY (dir_id),                 */
/*   dir_id    number(3)  CONSTRAINT iddirname  NOT NULL ,      */
/*   dir_name  varchar(20)                                      */
/*  );                                                          */




