Project

General

Profile

« Previous | Next » 

Revision 48302

Added by Tsampikos Livisianos almost 7 years ago

move changes from dnet4

View differences:

stats_db_schema.sql
260 260
   orid text
261 261
);
262 262

  
263
 CREATE TABLE shadow.person_oids (
264
    id text NOT NULL,
265
   orid text
266
);
263
-- CREATE TABLE shadow.person_oids (
264
--   id text NOT NULL,
265
--  orid text
266
-- );
267 267

  
268 268

  
269 269
 CREATE TABLE shadow.project_keywords (
......
397 397
--
398 398

  
399 399

  
400
CREATE TABLE shadow.person (
401
    id text NOT NULL,
402
    person_results text NOT NULL,
403
  firstname text,
404
  lastname text,
405
  fullname text ,
406
  nationality text ,
407
  email text,
408
  phone text,
409
  deletedbyinference TEXT,
410
  number text
411
);
400
-- CREATE TABLE shadow.person (
401
--     id text NOT NULL,
402
--     person_results text NOT NULL,
403
--   firstname text,
404
--   lastname text,
405
--   fullname text ,
406
--   nationality text ,
407
--   email text,
408
--   phone text,
409
--   deletedbyinference TEXT,
410
--   number text
411
-- );
412 412

  
413 413

  
414
CREATE TABLE shadow.person_results (
415
    id text NOT NULL,
416
    result text NOT NULL
417
);
414
-- CREATE TABLE shadow.person_results (
415
--     id text NOT NULL,
416
--    result text NOT NULL
417
-- );
418 418

  
419
CREATE TABLE shadow.project_persons (
420
  id text NOT NULL,
421
  person text NOT NULL
422
);
419
-- CREATE TABLE shadow.project_persons (
420
--  id text NOT NULL,
421
--  person text NOT NULL
422
-- );
423 423

  
424 424
CREATE TABLE shadow.result_pids (
425 425
  id text NOT NULL,
......
908 908

  
909 909
BEGIN
910 910

  
911
-- country nums
912
CREATE TABLE "shadow".numbers_country AS SELECT org.country AS country, count(distinct rd.datasource) AS datasources, count(distinct r.id) AS publications FROM "shadow".result r, "shadow".result_datasources rd, "shadow".datasource d, "shadow".datasource_organizations dor, "shadow".organization org WHERE r.id=rd.id AND rd.datasource=d.id AND d.id=dor.id AND dor.organization=org.id AND r.type='publication' AND r.bestlicense='Open Access' GROUP BY org.country;
913

  
914
-- country charts
915
CREATE TABLE "shadow".chart_country_year AS SELECT org.country AS country, r.year AS year, count(distinct r.id) AS publications FROM "shadow".result r, "shadow".result_datasources rd, "shadow".datasource d, "shadow".datasource_organizations dor, "shadow".organization org WHERE r.id=rd.id AND rd.datasource=d.id AND rd.datasource=dor.id AND dor.organization=org.id AND r.type='publication' AND r.bestlicense='Open Access' and r.year>='1990' AND r.year<=extract(YEAR from now()) group by org.country, r.year ORDER BY org.country, r.year;
916
CREATE TABLE "shadow".chart_country_datasources AS SELECT org.country AS country, d.name AS datasource, count(distinct r.id) AS publications FROM "shadow".result r, "shadow".result_datasources rd, "shadow".datasource d, "shadow".datasource_organizations dor, "shadow".organization org WHERE r.id=rd.id AND rd.datasource=d.id AND d.id=dor.id AND dor.organization=org.id AND r.type='publication' AND r.bestlicense='Open Access' GROUP BY org.country, d.name ORDER BY org.country, count(distinct r.id) DESC;
917
CREATE TABLE "shadow".chart_country_type AS SELECT org.country AS country, rc.type AS type, count(distinct r.id) AS publications FROM "shadow".result r, "shadow".result_datasources rd, "shadow".datasource d, "shadow".result_classifications rc, "shadow".datasource_organizations dor, "shadow".organization org WHERE r.id=rd.id AND r.id=rc.id AND rd.datasource=d.id AND rd.datasource=dor.id AND dor.organization=org.id AND r.type='publication' AND r.bestlicense='Open Access' GROUP BY org.country, rc.type;
918
CREATE TABLE "shadow".chart_country_fp7 AS SELECT org.country AS country, r.year AS year, count(distinct r.id) AS publications FROM "shadow".result r, "shadow".result_datasources rd, "shadow".datasource d, "shadow".datasource_organizations dor, "shadow".organization org, "shadow".project_results pr, "shadow".project p WHERE r.id=rd.id AND rd.datasource=d.id AND rd.datasource=dor.id AND dor.organization=org.id AND r.id=pr.result AND pr.id=p.id AND p.funding_lvl0='FP7' AND r.type='publication' AND r.year>='1990' AND r.year<=extract(YEAR from now()) GROUP BY org.country, r.year ORDER BY org.country, r.year;
919

  
911 920
-- datasource charts
912 921
CREATE TABLE "shadow".chart_datasource_type AS SELECT rd.datasource, rc.type, count(distinct rd.id) FROM "shadow".result_datasources rd, "shadow".result_classifications rc WHERE rd.id=rc.id GROUP BY rd.datasource, rc.type;
913 922
CREATE TABLE "shadow".chart_datasource_year AS SELECT rd.datasource, r.year, count(distinct rd.id) FROM "shadow".result r, "shadow".result_datasources rd WHERE rd.id=r.id GROUP By rd.datasource, r.year;
......
931 940

  
932 941
BEGIN
933 942

  
943
-- country nums
944
CREATE INDEX numbers_country_country ON "shadow".numbers_country USING btree(country);
945

  
946
-- country charts
947
CREATE INDEX chart_country_year_country ON "shadow".chart_country_year USING btree(country);
948
CREATE INDEX chart_country_datasources_country ON "shadow".chart_country_datasources USING btree(country);
949
CREATE INDEX chart_country_type_country ON "shadow".chart_country_type USING btree(country);
950
CREATE INDEX chart_country_fp7_country ON "shadow".chart_country_fp7 USING btree(country);
951

  
934 952
-- datasource
935 953
CREATE INDEX chart_datasource_type_datasource ON "shadow".chart_datasource_type USING btree(datasource);
936 954
CREATE INDEX chart_datasource_year_datasource ON "shadow".chart_datasource_year USING btree(datasource);

Also available in: Unified diff