print "Using database observations"
use observations
go

if exists (select name from sysobjects where name = 'obs_aliases' and type = 'U')
		begin
		    print "Dropping existing obs_aliases table"
		    drop table obs_aliases
		end
go


print "Creating table obs_aliases"
Create table obs_aliases
(
	keyword		varchar(50) null,
	alias           varchar(50) null
)
go

print "Creating indices on obs_aliases table"
create unique clustered index key_alias
        on obs_aliases (keyword,alias)
go

print "Granting"
grant select on obs_aliases to public
grant all on obs_aliases to frameingest
go

INSERT obs_aliases VALUES ('HIERARCH ESO OBS TPLNO',    'HIERARCH ESO TPL SEQNO')
INSERT obs_aliases VALUES ('HIERARCH ESO DET ID',       'HIERARCH ESO DET NAME')
INSERT obs_aliases VALUES ('HIERARCH ESO DET ID',       'HIERARCH ESO INS ID')
INSERT obs_aliases VALUES ('HIERARCH ESO DET CHIP1 ID', 'HIERARCH ESO DET CHIP ID')
INSERT obs_aliases VALUES ('HIERARCH ESO DET CHIP1 ID', 'HIERARCH ESO DET NAME')
INSERT obs_aliases VALUES ('HIERARCH ESO DET EXP ID',   'HIERARCH ESO DET EXPO NO')
INSERT obs_aliases VALUES ('HIERARCH ESO DET EXP ID',   'HIERARCH ESO DET EXP NO')
INSERT obs_aliases VALUES ('HIERARCH ESO DPR CATG',     'HIERARCH ESO OBS CATG')
INSERT obs_aliases VALUES ('HIERARCH ESO DPR TYPE',     'HIERARCH ESO OBS TYPE')
INSERT obs_aliases VALUES ('HIERARCH ESO DPR TECH',     'HIERARCH ESO OBS TECH')
go