Version 3 (modified by cedric, 13 years ago) (diff) |
---|
back to first page..
back to RHT
CREATE TABLE rht.model_mod ( mod_id serial NOT NULL, mod_name character varying(30) NOT NULL, mod_date date, mod_description text NOT NULL, mod_location character varying(25), -- Geographical area to which the model is applied, should be consistent with europe.wso mod_formula text, CONSTRAINT model_mod_pkey PRIMARY KEY (mod_id), CONSTRAINT model_mod_mod_name_key UNIQUE (mod_name) ); DROP TABLE IF EXISTS rht.resultmodel; CREATE TABLE rht.resultmodel ( res_id serial NOT NULL, res_id_drain integer, res_value double precision, res_mod_id integer, CONSTRAINT resultmodel_pkey PRIMARY KEY (res_id), CONSTRAINT c_fk_res_mod_id FOREIGN KEY (res_mod_id) REFERENCES rht.model_mod (mod_id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION ); drop view if exists (v_resultmodel); create view v_resultmodel as ( select sub1.*, sub2.res_value as mpa, sub3.res_value as mdmpa, sub4.res_value as largeur, sub5.res_value as surface from (select id_drain,dmer,dsource,res_value as md, the_geom from rht.rht_topology join rht.resultmodel on res_id_drain=id_drain where res_mod_id=1) as sub1 join (select id_drain, res_value from rht.rht_topology join rht.resultmodel on res_id_drain=id_drain where res_mod_id=2) as sub2 on sub1.id_drain=sub2.id_drain join (select id_drain, res_value from rht.rht_topology join rht.resultmodel on res_id_drain=id_drain where res_mod_id=3) as sub3 on sub1.id_drain=sub3.id_drain join (select id_drain, res_value from rht.rht_topology join rht.resultmodel on res_id_drain=id_drain where res_mod_id=4) as sub4 on sub1.id_drain=sub4.id_drain join (select id_drain, res_value from rht.rht_topology join rht.resultmodel on res_id_drain=id_drain where res_mod_id=5) as sub5 on sub1.id_drain=sub5.id_drain );