argos/dmp-db-scema/DataManagementPlanDB.sql

471 lines
13 KiB
SQL

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
drop table if exists "DMP" cascade;
drop table if exists "DMPOrganisation" cascade;
drop table if exists "DMPProfile" cascade;
drop table if exists "DMPResearcher" cascade;
drop table if exists "Dataset" cascade;
drop table if exists "DatasetProfile" cascade;
drop table if exists "DatasetProfileRuleset" cascade;
drop table if exists "DatasetProfileViewstyle" cascade;
drop table if exists "Organisation" cascade;
drop table if exists "Project" cascade;
drop table if exists "Researcher" cascade;
drop table if exists "Service" cascade;
drop table if exists "DataRepository" cascade;
drop table if exists "Registry" cascade;
drop table if exists "DatasetService" cascade;
drop table if exists "DatasetRegistry" cascade;
drop table if exists "DatasetDataRepository" cascade;
drop table if exists "UserInfo" cascade;
-- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
-- CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
CREATE TABLE "DMP" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Previous" uuid,
"Label" character varying(250) NOT NULL,
"Version" integer NOT NULL,
"Project" uuid NOT NULL,
"ProfileData" xml,
"Profile" uuid
);
ALTER TABLE "DMP" OWNER TO dmptool;
COMMENT ON COLUMN "DMP"."ProfileData" IS 'More data about the DMP as defined by the profile';
CREATE TABLE "DMPOrganisation" (
"DMP" uuid NOT NULL,
"Organisation" uuid NOT NULL,
"Role" integer,
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL
);
ALTER TABLE "DMPOrganisation" OWNER TO dmptool;
COMMENT ON TABLE "DMPOrganisation" IS 'Linking of DMPs to Organisations';
COMMENT ON COLUMN "DMPOrganisation"."Role" IS 'Enumerator of roles';
CREATE TABLE "DMPProfile" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250) NOT NULL,
"Definition" xml
);
ALTER TABLE "DMPProfile" OWNER TO dmptool;
CREATE TABLE "DMPResearcher" (
"DMP" uuid NOT NULL,
"Researcher" uuid NOT NULL,
"Role" integer,
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL
);
ALTER TABLE "DMPResearcher" OWNER TO dmptool;
COMMENT ON TABLE "DMPResearcher" IS 'Linking of DMPs to researchers';
COMMENT ON COLUMN "DMPResearcher"."Role" IS 'Enumerator of roles';
CREATE TABLE "Dataset" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250) NOT NULL,
"DMP" uuid NOT NULL,
"Uri" character varying(250),
"Properties" xml,
"Profile" uuid
);
ALTER TABLE "Dataset" OWNER TO dmptool;
COMMENT ON COLUMN "Dataset"."Uri" IS 'URI of item';
COMMENT ON COLUMN "Dataset"."Properties" IS 'More data about the dataset such as Uri, data types etc as defined by the profile';
CREATE TABLE "DatasetProfile" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250) NOT NULL,
"Ruleset" uuid,
"Viewstyle" uuid,
"Definition" xml NOT NULL
);
ALTER TABLE "DatasetProfile" OWNER TO dmptool;
COMMENT ON TABLE "DatasetProfile" IS 'Profiles for dmp datasets';
CREATE TABLE "DatasetProfileRuleset" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250) NOT NULL,
"Definition" xml NOT NULL
);
ALTER TABLE "DatasetProfileRuleset" OWNER TO dmptool;
COMMENT ON TABLE "DatasetProfileRuleset" IS 'Sets of Rules for dmp dataset profiles';
CREATE TABLE "DatasetProfileViewstyle" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250) NOT NULL,
"Definition" xml NOT NULL
);
ALTER TABLE "DatasetProfileViewstyle" OWNER TO dmptool;
COMMENT ON TABLE "DatasetProfileViewstyle" IS 'Style sets for dmp dataset profiles';
CREATE TABLE "Organisation" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250) NOT NULL,
"Abbreviation" character varying(50),
"Reference" xml,
"Uri" character varying(250),
"Definition" xml
);
ALTER TABLE "Organisation" OWNER TO dmptool;
COMMENT ON TABLE "Organisation" IS 'Table of organizations utilized in the project';
COMMENT ON COLUMN "Organisation"."ID" IS 'Unique identifier and primary key of item';
COMMENT ON COLUMN "Organisation"."Label" IS 'A human readable long label of the item';
COMMENT ON COLUMN "Organisation"."Abbreviation" IS 'A human readable abbreviation of the item';
COMMENT ON COLUMN "Organisation"."Reference" IS 'Reference to the URI of the item along with information to allow how the item reached the system (e.g. via an external vocabulary)';
COMMENT ON COLUMN "Organisation"."Uri" IS 'URI of item';
COMMENT ON COLUMN "Organisation"."Definition" IS 'More data about the Organisation such as web site, type etc';
CREATE TABLE "Project" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250) NOT NULL,
"Abbreviation" character varying(50),
"Reference" xml,
"Uri" character varying(250),
"Definition" xml
);
ALTER TABLE "Project" OWNER TO dmptool;
COMMENT ON TABLE "Project" IS 'Table of project managed in the system';
COMMENT ON COLUMN "Project"."ID" IS 'Unique identifier and primary key of item';
COMMENT ON COLUMN "Project"."Label" IS 'A human readable long label of the item';
COMMENT ON COLUMN "Project"."Abbreviation" IS 'A human readable abbreviation of the item';
COMMENT ON COLUMN "Project"."Reference" IS 'Additional reference data for the item along with information to allow how the item reached the system (e.g. via an external vocabulary)';
COMMENT ON COLUMN "Project"."Uri" IS 'URI of item';
COMMENT ON COLUMN "Project"."Definition" IS 'More data about the project such as web site, start/stop, etc';
CREATE TABLE "Researcher" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250) NOT NULL,
"Uri" character varying(250),
"PrimaryEmail" character varying(250),
"Definition" xml,
"Reference" xml
);
ALTER TABLE "Researcher" OWNER TO dmptool;
COMMENT ON TABLE "Researcher" IS 'Table of Researcher managed in the system';
COMMENT ON COLUMN "Researcher"."ID" IS 'Unique identifier and primary key of item';
COMMENT ON COLUMN "Researcher"."Label" IS 'Full name of the researcher (as presented by the system, and composed automatically by data or provided by the reference service)';
COMMENT ON COLUMN "Researcher"."Uri" IS 'URI of item';
COMMENT ON COLUMN "Researcher"."Definition" IS 'More data about the researcher such as: email addresses, affiliations etc';
COMMENT ON COLUMN "Researcher"."Reference" IS 'Additional reference data for the item along with information to allow how the item reached the system (e.g. via an external vocabulary)';
ALTER TABLE ONLY "DMPProfile"
ADD CONSTRAINT "DMPPRofile_pkey" PRIMARY KEY ("ID");
ALTER TABLE ONLY "DMP"
ADD CONSTRAINT "DMP_pkey" PRIMARY KEY ("ID");
ALTER TABLE ONLY "DatasetProfile"
ADD CONSTRAINT "DatasetProfile_pkey" PRIMARY KEY ("ID");
ALTER TABLE ONLY "DatasetProfileRuleset"
ADD CONSTRAINT "DatasetProfileRuleset_pkey" PRIMARY KEY ("ID");
ALTER TABLE ONLY "DatasetProfileViewstyle"
ADD CONSTRAINT "DatasetProfileViewstyle_pkey" PRIMARY KEY ("ID");
ALTER TABLE ONLY "Dataset"
ADD CONSTRAINT "Dataset_pkey" PRIMARY KEY ("ID");
ALTER TABLE ONLY "Organisation"
ADD CONSTRAINT "Organisation_pkey" PRIMARY KEY ("ID");
ALTER TABLE ONLY "DMPOrganisation"
ADD CONSTRAINT "PKey_DMPOrganisation" PRIMARY KEY ("ID");
ALTER TABLE ONLY "DMPResearcher"
ADD CONSTRAINT "PKey_DMPResearcher" PRIMARY KEY ("ID");
ALTER TABLE ONLY "Project"
ADD CONSTRAINT "Project_pkey" PRIMARY KEY ("ID");
ALTER TABLE ONLY "Researcher"
ADD CONSTRAINT "Researcher_pkey" PRIMARY KEY ("ID");
CREATE INDEX "fki_DMPDMPProfileReference" ON "DMP" USING btree ("Profile");
CREATE INDEX "fki_DatasetDatasetProfileReference" ON "Dataset" USING btree ("Profile");
ALTER TABLE ONLY "DMP"
ADD CONSTRAINT "DMPDMPProfileReference" FOREIGN KEY ("Profile") REFERENCES "DMPProfile"("ID");
ALTER TABLE ONLY "DMPOrganisation"
ADD CONSTRAINT "DMPOrganisationDMPReference" FOREIGN KEY ("Organisation") REFERENCES "Organisation"("ID");
ALTER TABLE ONLY "DMPOrganisation"
ADD CONSTRAINT "DMPOrganisationOrganisationReference" FOREIGN KEY ("DMP") REFERENCES "DMP"("ID");
ALTER TABLE ONLY "DMP"
ADD CONSTRAINT "DMPProjectReference" FOREIGN KEY ("Project") REFERENCES "Project"("ID");
ALTER TABLE ONLY "DMPResearcher"
ADD CONSTRAINT "DMPResearcherDMPReference" FOREIGN KEY ("Researcher") REFERENCES "Researcher"("ID");
ALTER TABLE ONLY "DMPResearcher"
ADD CONSTRAINT "DMPResearcherResearcherReference" FOREIGN KEY ("DMP") REFERENCES "DMP"("ID");
ALTER TABLE ONLY "Dataset"
ADD CONSTRAINT "DatasetDatasetProfileReference" FOREIGN KEY ("Profile") REFERENCES "DatasetProfile"("ID");
ALTER TABLE ONLY "Dataset"
ADD CONSTRAINT "DatasetDMPReference" FOREIGN KEY ("DMP") REFERENCES "DMP"("ID");
ALTER TABLE ONLY "DatasetProfile"
ADD CONSTRAINT "DatasetProfileDatasetProfileRulesetReference" FOREIGN KEY ("Ruleset") REFERENCES "DatasetProfileRuleset"("ID");
ALTER TABLE ONLY "DatasetProfile"
ADD CONSTRAINT "DatasetProfileDatasetProfileViewstyleReference" FOREIGN KEY ("Viewstyle") REFERENCES "DatasetProfileViewstyle"("ID");
CREATE TABLE "Service" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250),
"Abbreviation" character varying(50),
"Reference" xml,
"Uri" character varying(250),
"Definition" xml
);
ALTER TABLE "Service" OWNER TO dmptool;
ALTER TABLE ONLY "Service"
ADD CONSTRAINT "PKey_Service" PRIMARY KEY ("ID");
CREATE TABLE "DataRepository" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250),
"Abbreviation" character varying(50),
"Reference" xml,
"Uri" character varying(250),
"Definition" xml
);
ALTER TABLE "DataRepository" OWNER TO dmptool;
ALTER TABLE ONLY "DataRepository"
ADD CONSTRAINT "PKey_DataRepository" PRIMARY KEY ("ID");
CREATE TABLE "Registry" (
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL,
"Label" character varying(250),
"Abbreviation" character varying(50),
"Reference" xml,
"Uri" character varying(250),
"Definition" xml
);
ALTER TABLE "Registry" OWNER TO dmptool;
ALTER TABLE ONLY "Registry"
ADD CONSTRAINT "PKey_Registry" PRIMARY KEY ("ID");
CREATE TABLE "DatasetService" (
"Dataset" uuid NOT NULL,
"Service" uuid NOT NULL,
"Role" integer,
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL
);
ALTER TABLE "DatasetService" OWNER TO dmptool;
COMMENT ON TABLE "DatasetService" IS 'Linking Dataset to Service';
CREATE TABLE "DatasetRegistry" (
"Dataset" uuid NOT NULL,
"Registry" uuid NOT NULL,
"Role" integer,
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL
);
ALTER TABLE "DatasetRegistry" OWNER TO dmptool;
COMMENT ON TABLE "DatasetRegistry" IS 'Linking Dataset to Registry';
CREATE TABLE "DatasetDataRepository" (
"Dataset" uuid NOT NULL,
"DataRepository" uuid NOT NULL,
"Role" integer,
"ID" uuid DEFAULT uuid_generate_v4() NOT NULL
);
ALTER TABLE "DatasetDataRepository" OWNER TO dmptool;
COMMENT ON TABLE "DatasetDataRepository" IS 'Linking Dataset to DataRepository';
ALTER TABLE ONLY "DatasetDataRepository"
ADD CONSTRAINT "DatasetDataRepositoryDatasetReference" FOREIGN KEY ("Dataset") REFERENCES "Dataset"("ID");
ALTER TABLE ONLY "DatasetDataRepository"
ADD CONSTRAINT "DatasetDataRepositoryDataRepositoryReference" FOREIGN KEY ("DataRepository") REFERENCES "DataRepository"("ID");
ALTER TABLE ONLY "DatasetRegistry"
ADD CONSTRAINT "DatasetRegistryDatasetReference" FOREIGN KEY ("Dataset") REFERENCES "Dataset"("ID");
ALTER TABLE ONLY "DatasetRegistry"
ADD CONSTRAINT "DatasetRegistryRegistryReference" FOREIGN KEY ("Registry") REFERENCES "Registry"("ID");
ALTER TABLE ONLY "DatasetService"
ADD CONSTRAINT "DatasetServiceDatasetReference" FOREIGN KEY ("Dataset") REFERENCES "Dataset"("ID");
ALTER TABLE ONLY "DatasetService"
ADD CONSTRAINT "DatasetServiceServiceReference" FOREIGN KEY ("Service") REFERENCES "Service"("ID");
CREATE TABLE "UserInfo" (
"autoid" uuid DEFAULT uuid_generate_v4() NOT NULL,
"id" character varying(500),
"email" character varying(250),
"emailIsVerified" boolean,
"name" character varying(250),
"pictureUrl" character varying(500),
"locale" character varying(50),
"familyName" character varying(250),
"givenName" character varying(250),
"additionalinfo" xml,
PRIMARY KEY (id, email)
);
REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;