Advertisement
vojtarek

db structure

Oct 10th, 2011
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 34.15 KB | None | 0 0
  1. --
  2. -- PostgreSQL database dump
  3. --
  4.  
  5. SET client_encoding = 'UTF8';
  6. SET standard_conforming_strings = off;
  7. SET check_function_bodies = FALSE;
  8. SET client_min_messages = warning;
  9. SET escape_string_warning = off;
  10.  
  11. --
  12. -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: meco
  13. --
  14.  
  15. CREATE PROCEDURAL LANGUAGE plpgsql;
  16.  
  17.  
  18. ALTER PROCEDURAL LANGUAGE plpgsql OWNER TO meco;
  19.  
  20. SET search_path = public, pg_catalog;
  21.  
  22. --
  23. -- Name: create_stats(); Type: FUNCTION; Schema: public; Owner: meco
  24. --
  25.  
  26. CREATE FUNCTION create_stats() RETURNS void
  27.     AS $$DECLARE
  28.   mrow RECORD;
  29. BEGIN
  30.   -- count documents
  31.   PERFORM insert_log('Total Documents', NULL,
  32.     (SELECT COUNT(*) FROM documents));
  33.   FOR mrow IN SELECT LANGUAGE, COUNT(*) FROM DOCUMENTS GROUP BY LANGUAGE LOOP
  34.      PERFORM insert_log('Total Documents By Lang', mrow.LANGUAGE, mrow.COUNT);
  35.   END LOOP;
  36.  
  37.   -- analyzed
  38.   PERFORM insert_log('Analyzed Documents', NULL,
  39.     (SELECT COUNT(*) FROM documents WHERE _analyzed=TRUE));
  40.  
  41.   -- medisys temporarly
  42.   PERFORM insert_log('Medisys crawling', 'to download',
  43.     (SELECT COUNT(*) FROM documents d WHERE
  44.      source_id IN (1, 1677, 1676) -- from medisys
  45.     AND id < 27240254 -- problematic sources
  46.     AND guid !~ '.*_'
  47.     AND NOT EXISTS ( -- and downloaded
  48.       SELECT 1 FROM documents dd
  49.       WHERE dd.guid=(d.guid || '_') AND dd.id > 27240254)));
  50.   PERFORM insert_log('Medisys crawling', 'downloaded',
  51.     (SELECT COUNT(*) FROM documents d WHERE
  52.      source_id IN (1, 1677, 1676) -- from medisys
  53.      AND id >= 27240254
  54.     AND guid ~ '.*_'));
  55.   PERFORM insert_log('Medisys crawling', 'can not be downloaded (404)',
  56.     (SELECT COUNT(*) FROM documents d WHERE
  57.      source_id IN (1, 1677, 1676) -- from medisys
  58.     AND id < 27240254 -- problematic sources
  59.     AND guid ~ '.*_'));
  60.  
  61.   -- stanford
  62.   FOR mrow IN SELECT LANGUAGE, COUNT(*) FROM DOCUMENTS WHERE _stanford=TRUE GROUP BY LANGUAGE LOOP
  63.      PERFORM insert_log('Stanford parser', mrow.LANGUAGE, mrow.COUNT);
  64.   END LOOP;
  65.  
  66.  
  67.   PERFORM insert_log('Affected organism', NULL,
  68.      (SELECT COUNT(*) FROM documents WHERE _affected=TRUE));
  69.  
  70.  
  71.   PERFORM insert_log('OpenCalais', NULL,
  72.      (SELECT COUNT(*) FROM documents WHERE _calaised = TRUE AND LANGUAGE!='de'));
  73.  
  74.   PERFORM insert_log('Alchemized', NULL,
  75.      (SELECT COUNT(*) FROM documents WHERE _calaised = TRUE AND LANGUAGE='de'));
  76.  
  77.  
  78.  
  79.   -- sections
  80.   FOR mrow IN SELECT COUNT(*), LOWER(SECTION) AS SECTION FROM documents, sources
  81.     WHERE sources.id=documents.source_id GROUP BY LOWER(SECTION) LOOP
  82.      PERFORM insert_log('Total Documents by Sections', mrow.SECTION, mrow.COUNT);
  83.   END LOOP;
  84. END
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94. $$
  95.     LANGUAGE plpgsql;
  96.  
  97.  
  98. ALTER FUNCTION public.create_stats() OWNER TO meco;
  99.  
  100. --
  101. -- Name: create_tsvector(character varying, character varying, text); Type: FUNCTION; Schema: public; Owner: meco
  102. --
  103.  
  104. CREATE FUNCTION create_tsvector(LANGUAGE CHARACTER VARYING, title CHARACTER VARYING, text text) RETURNS tsvector
  105.     AS $_$select * FROM to_tsvector(langtolong($1), COALESCE($2, '')||COALESCE($3, '')) LIMIT 1;$_$
  106.     LANGUAGE SQL;
  107.  
  108.  
  109. ALTER FUNCTION public.create_tsvector(LANGUAGE CHARACTER VARYING, title CHARACTER VARYING, text text) OWNER TO meco;
  110.  
  111. --
  112. -- Name: FUNCTION create_tsvector(language character varying, title character varying, text text); Type: COMMENT; Schema: public; Owner: meco
  113. --
  114.  
  115. COMMENT ON FUNCTION create_tsvector(LANGUAGE CHARACTER VARYING, title CHARACTER VARYING, text text) IS 'Example usage:
  116. select * from create_tsvector(''en'', ''I\\''m in Prague'', ''Hello from prague!'')';
  117.  
  118.  
  119. --
  120. -- Name: insert_entity(character varying, integer, character varying, character varying); Type: FUNCTION; Schema: public; Owner: meco
  121. --
  122.  
  123. CREATE FUNCTION insert_entity(par_name CHARACTER VARYING, par_enttype_id INTEGER, par_reference CHARACTER VARYING, par_coordinates CHARACTER VARYING) RETURNS INTEGER
  124.     AS $$DECLARE
  125.   already_id INTEGER;
  126. BEGIN
  127.   -- already in db?
  128.   IF par_coordinates IS NULL THEN
  129.     SELECT id INTO already_id FROM entities WHERE name=par_name AND coordinates IS NULL;
  130.   ELSE
  131.     SELECT id INTO already_id FROM entities WHERE name=par_name AND coordinates=par_coordinates;
  132.   END IF;
  133.  
  134.   IF already_id IS NULL THEN
  135.     -- have to insert it
  136.     INSERT INTO entities (name, enttype_id, reference, normalized_entity, coordinates)
  137.            VALUES (par_name, par_enttype_id, par_reference, LOWER(btrim(par_name, E' #\n\r\t')),
  138.                    par_coordinates)
  139.            RETURNING id INTO already_id;
  140.   END IF;
  141.  
  142.   RETURN already_id;
  143. END$$
  144.     LANGUAGE plpgsql;
  145.  
  146.  
  147. ALTER FUNCTION public.insert_entity(par_name CHARACTER VARYING, par_enttype_id INTEGER, par_reference CHARACTER VARYING, par_coordinates CHARACTER VARYING) OWNER TO meco;
  148.  
  149. --
  150. -- Name: insert_log(character varying, character varying, bigint); Type: FUNCTION; Schema: public; Owner: meco
  151. --
  152.  
  153. CREATE FUNCTION insert_log(type_ CHARACTER VARYING, param_ CHARACTER VARYING, value_ BIGINT) RETURNS void
  154.     AS $_$BEGIN
  155.     INSERT INTO logs (TIMESTAMP, TYPE, param, VALUE) VALUES (CURRENT_TIMESTAMP, $1, $2, $3);
  156. END;$_$
  157.     LANGUAGE plpgsql;
  158.  
  159.  
  160. ALTER FUNCTION public.insert_log(type_ CHARACTER VARYING, param_ CHARACTER VARYING, value_ BIGINT) OWNER TO meco;
  161.  
  162. --
  163. -- Name: inserting_document_f(); Type: FUNCTION; Schema: public; Owner: meco
  164. --
  165.  
  166. CREATE FUNCTION inserting_document_f() RETURNS TRIGGER
  167.     AS $$BEGIN
  168.     IF NEW.TIMESTAMP IS NULL THEN
  169.         NEW.TIMESTAMP := CURRENT_TIMESTAMP;
  170.     END IF;
  171.     NEW.fts := to_tsvector(langtolong(NEW.LANGUAGE), SUBSTRING(COALESCE(NEW.title, '')||COALESCE(NEW.text, ''), 1, 500000));
  172.     RETURN NEW;
  173. END;$$
  174.     LANGUAGE plpgsql;
  175.  
  176.  
  177. ALTER FUNCTION public.inserting_document_f() OWNER TO meco;
  178.  
  179. --
  180. -- Name: inserting_sources_f(); Type: FUNCTION; Schema: public; Owner: meco
  181. --
  182.  
  183. CREATE FUNCTION inserting_sources_f() RETURNS TRIGGER
  184.     AS $$BEGIN
  185. IF NEW.normalized_section IS NULL THEN
  186.     NEW.normalized_section := LOWER( NEW.SECTION );
  187. END IF;
  188. RETURN NEW;
  189. END;$$
  190.     LANGUAGE plpgsql;
  191.  
  192.  
  193. ALTER FUNCTION public.inserting_sources_f() OWNER TO meco;
  194.  
  195. --
  196. -- Name: inserting_terms_f(character varying); Type: FUNCTION; Schema: public; Owner: meco
  197. --
  198.  
  199. CREATE FUNCTION inserting_terms_f(_term CHARACTER VARYING) RETURNS INTEGER
  200.     AS $$DECLARE
  201.   already_id INTEGER;
  202. BEGIN
  203.   -- already in db?
  204.   SELECT id INTO already_id FROM terms WHERE term=_term;
  205.  
  206.   IF already_id IS NULL THEN
  207.     -- have to insert it
  208.     INSERT INTO terms (term)
  209.            VALUES (_term)
  210.            RETURNING id INTO already_id;
  211.   END IF;
  212.  
  213.   RETURN already_id;
  214. END$$
  215.     LANGUAGE plpgsql;
  216.  
  217.  
  218. ALTER FUNCTION public.inserting_terms_f(_term CHARACTER VARYING) OWNER TO meco;
  219.  
  220. --
  221. -- Name: langtolong(character varying); Type: FUNCTION; Schema: public; Owner: meco
  222. --
  223.  
  224. CREATE FUNCTION langtolong(CHARACTER VARYING) RETURNS regconfig
  225.     AS $_$SELECT LANGUAGE FROM langs WHERE lang=$1 LIMIT 1;$_$
  226.     LANGUAGE SQL IMMUTABLE;
  227.  
  228.  
  229. ALTER FUNCTION public.langtolong(CHARACTER VARYING) OWNER TO meco;
  230.  
  231. SET default_tablespace = '';
  232.  
  233. SET default_with_oids = FALSE;
  234.  
  235. --
  236. -- Name: authors; Type: TABLE; Schema: public; Owner: meco; Tablespace:
  237. --
  238.  
  239. CREATE TABLE authors (
  240.     id INTEGER NOT NULL,
  241.     guid CHARACTER VARYING(64) NOT NULL,
  242.     name CHARACTER VARYING(511),
  243.     location CHARACTER VARYING(511),
  244.     description CHARACTER VARYING(511),
  245.     occupation CHARACTER VARYING(511),
  246.     gps CHARACTER VARYING(32),
  247.     gps_process BOOLEAN DEFAULT FALSE
  248. );
  249.  
  250.  
  251. ALTER TABLE public.authors OWNER TO meco;
  252.  
  253. --
  254. -- Name: documents; Type: TABLE; Schema: public; Owner: meco; Tablespace:
  255. --
  256.  
  257. CREATE TABLE documents (
  258.     id INTEGER NOT NULL,
  259.     LANGUAGE CHARACTER VARYING(2),
  260.     source_id INTEGER,
  261.     author_id INTEGER,
  262.     "timestamp" TIMESTAMP WITHOUT TIME zone,
  263.     guid CHARACTER VARYING(511),
  264.     link CHARACTER VARYING(2047),
  265.     title CHARACTER VARYING(2047),
  266.     text text,
  267.     georss_lat CHARACTER VARYING(31),
  268.     georss_lon CHARACTER VARYING(31),
  269.     html_description text,
  270.     html_keywords text,
  271.     pubdate DATE,
  272.     pubtime TIME WITHOUT TIME zone,
  273.     sentences text,
  274.     termvector text,
  275.     _calaised BOOLEAN DEFAULT FALSE,
  276.     _analyzed BOOLEAN DEFAULT FALSE,
  277.     _relevance INTEGER DEFAULT (-1),
  278.     _stanford BOOLEAN,
  279.     fts tsvector,
  280.     _affected BOOLEAN DEFAULT FALSE,
  281.     georss_name CHARACTER VARYING(255)
  282. );
  283.  
  284.  
  285. ALTER TABLE public.documents OWNER TO meco;
  286.  
  287. --
  288. -- Name: COLUMN documents._calaised; Type: COMMENT; Schema: public; Owner: meco
  289. --
  290.  
  291. COMMENT ON COLUMN documents._calaised IS 'True if document was analyzed by OpenCalais.';
  292.  
  293.  
  294. --
  295. -- Name: COLUMN documents._analyzed; Type: COMMENT; Schema: public; Owner: meco
  296. --
  297.  
  298. COMMENT ON COLUMN documents._analyzed IS 'true if was analyzed by analyzer';
  299.  
  300.  
  301. --
  302. -- Name: COLUMN documents._relevance; Type: COMMENT; Schema: public; Owner: meco
  303. --
  304.  
  305. COMMENT ON COLUMN documents._relevance IS 'the implicit value is -1';
  306.  
  307.  
  308. --
  309. -- Name: COLUMN documents.fts; Type: COMMENT; Schema: public; Owner: meco
  310. --
  311.  
  312. COMMENT ON COLUMN documents.fts IS 'full text search';
  313.  
  314.  
  315. --
  316. -- Name: sources; Type: TABLE; Schema: public; Owner: meco; Tablespace:
  317. --
  318.  
  319. CREATE TABLE sources (
  320.     id INTEGER NOT NULL,
  321.     link CHARACTER VARYING(2047),
  322.     LANGUAGE CHARACTER VARYING(2),
  323.     etag CHARACTER VARYING(63),
  324.     modified CHARACTER VARYING(63),
  325.     SECTION CHARACTER VARYING(200),
  326.     _stahovak BOOLEAN DEFAULT FALSE,
  327.     _follow BOOLEAN DEFAULT FALSE,
  328.     normalized_section CHARACTER VARYING(200)
  329. );
  330.  
  331.  
  332. ALTER TABLE public.sources OWNER TO meco;
  333.  
  334. --
  335. -- Name: COLUMN sources._stahovak; Type: COMMENT; Schema: public; Owner: meco
  336. --
  337.  
  338. COMMENT ON COLUMN sources._stahovak IS 'True if should be downloaded by stahovak';
  339.  
  340.  
  341. --
  342. -- Name: COLUMN sources._follow; Type: COMMENT; Schema: public; Owner: meco
  343. --
  344.  
  345. COMMENT ON COLUMN sources._follow IS 'True if needed follow links of rss.';
  346.  
  347.  
  348. --
  349. -- Name: sources_twitter; Type: VIEW; Schema: public; Owner: meco
  350. --
  351.  
  352. CREATE VIEW sources_twitter AS
  353.     SELECT sources.id, sources.link, sources.LANGUAGE, sources.etag, sources.modified, sources.SECTION, sources._stahovak, sources._follow FROM sources WHERE ((sources.SECTION)::text = ANY ((ARRAY['TWITTER'::CHARACTER VARYING, 'Twitter'::CHARACTER VARYING, 'twitter'::CHARACTER VARYING])::text[]));
  354.  
  355.  
  356. ALTER TABLE public.sources_twitter OWNER TO meco;
  357.  
  358. --
  359. -- Name: VIEW sources_twitter; Type: COMMENT; Schema: public; Owner: meco
  360. --
  361.  
  362. COMMENT ON VIEW sources_twitter IS 'Vybere všechny sources, které náleží twitteru.';
  363.  
  364.  
  365. --
  366. -- Name: Problems; Type: VIEW; Schema: public; Owner: meco
  367. --
  368.  
  369. CREATE VIEW "Problems" AS
  370.     (SELECT COUNT(1) AS COUNT, 'Autori bez dokumentu' AS popis FROM authors WHERE (NOT (EXISTS (SELECT 1 FROM documents WHERE (documents.author_id = authors.id)))) UNION SELECT COUNT(1) AS COUNT, 'Tweety delsi 140 znaku' AS popis FROM documents WHERE ((documents.source_id IN (SELECT sources_twitter.id FROM sources_twitter)) AND (LENGTH(documents.text) > 140))) UNION SELECT COUNT(1) AS COUNT, 'Dokumenty s exotickymi jazyky' AS popis FROM documents WHERE (langtolong(documents.LANGUAGE) IS NULL);
  371.  
  372.  
  373. ALTER TABLE public."Problems" OWNER TO meco;
  374.  
  375. --
  376. -- Name: VIEW "Problems"; Type: COMMENT; Schema: public; Owner: meco
  377. --
  378.  
  379. COMMENT ON VIEW "Problems" IS 'Detekce problému. Velmi pomalé!';
  380.  
  381.  
  382. --
  383. -- Name: StanfordProgress; Type: VIEW; Schema: public; Owner: meco
  384. --
  385.  
  386. CREATE VIEW "StanfordProgress" AS
  387.     SELECT documents.LANGUAGE, 'Stanford successfully', COUNT(*) AS COUNT FROM documents WHERE ((documents._stanford = TRUE) AND (documents.sentences IS NOT NULL)) GROUP BY documents.LANGUAGE UNION SELECT documents.LANGUAGE, 'Analyzed by Stanford', COUNT(*) AS COUNT FROM documents WHERE (documents._stanford = TRUE) GROUP BY documents.LANGUAGE;
  388.  
  389.  
  390. ALTER TABLE public."StanfordProgress" OWNER TO meco;
  391.  
  392. --
  393. -- Name: VIEW "StanfordProgress"; Type: COMMENT; Schema: public; Owner: meco
  394. --
  395.  
  396. COMMENT ON VIEW "StanfordProgress" IS 'Progress of stanford parser.';
  397.  
  398.  
  399. --
  400. -- Name: authors_id_seq; Type: SEQUENCE; Schema: public; Owner: meco
  401. --
  402.  
  403. CREATE SEQUENCE authors_id_seq
  404.     INCREMENT BY 1
  405.     NO MAXVALUE
  406.     NO MINVALUE
  407.     CACHE 1;
  408.  
  409.  
  410. ALTER TABLE public.authors_id_seq OWNER TO meco;
  411.  
  412. --
  413. -- Name: authors_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: meco
  414. --
  415.  
  416. ALTER SEQUENCE authors_id_seq OWNED BY authors.id;
  417.  
  418.  
  419. --
  420. -- Name: entities; Type: TABLE; Schema: public; Owner: meco; Tablespace:
  421. --
  422.  
  423. CREATE TABLE entities (
  424.     id INTEGER NOT NULL,
  425.     name CHARACTER VARYING(255),
  426.     enttype_id INTEGER,
  427.     reference CHARACTER VARYING(255),
  428.     normalized_entity CHARACTER VARYING(255),
  429.     coordinates CHARACTER VARYING(24)
  430. );
  431.  
  432.  
  433. ALTER TABLE public.entities OWNER TO meco;
  434.  
  435. --
  436. -- Name: COLUMN entities.coordinates; Type: COMMENT; Schema: public; Owner: meco
  437. --
  438.  
  439. COMMENT ON COLUMN entities.coordinates IS 'in form latitude - longitude';
  440.  
  441.  
  442. --
  443. -- Name: enttypes; Type: TABLE; Schema: public; Owner: meco; Tablespace:
  444. --
  445.  
  446. CREATE TABLE enttypes (
  447.     id INTEGER NOT NULL,
  448.     TYPE CHARACTER VARYING(255),
  449.     reference CHARACTER VARYING(255),
  450.     parent CHARACTER VARYING(255)
  451. );
  452.  
  453.  
  454. ALTER TABLE public.enttypes OWNER TO meco;
  455.  
  456. --
  457. -- Name: instances; Type: TABLE; Schema: public; Owner: meco; Tablespace:
  458. --
  459.  
  460. CREATE TABLE instances (
  461.     id INTEGER NOT NULL,
  462.     entity_id INTEGER,
  463.     item_id INTEGER,
  464.     exact CHARACTER VARYING(255),
  465.     offset_ INTEGER,
  466.     LENGTH INTEGER,
  467.     sid INTEGER,
  468.     begintoken INTEGER,
  469.     endtoken INTEGER
  470. );
  471.  
  472.  
  473. ALTER TABLE public.instances OWNER TO meco;
  474.  
  475. --
  476. -- Name: de_twitter_location; Type: VIEW; Schema: public; Owner: meco
  477. --
  478.  
  479. CREATE VIEW de_twitter_location AS
  480.     SELECT DISTINCT d.id, d.text, e.name AS entity, et.TYPE AS entity_type FROM (((documents d JOIN instances i ON ((i.item_id = d.id))) JOIN entities e ON ((i.entity_id = e.id))) JOIN enttypes et ON ((e.enttype_id = et.id))) WHERE (((((d.LANGUAGE)::text = 'de'::text) AND (d._calaised = TRUE)) AND (d.source_id IN (SELECT sources_twitter.id FROM sources_twitter))) AND (et.id = ANY (ARRAY[7, 10, 11, 14, 17, 18, 49]))) ORDER BY d.id, d.text, e.name, et.TYPE;
  481.  
  482.  
  483. ALTER TABLE public.de_twitter_location OWNER TO meco;
  484.  
  485. --
  486. -- Name: VIEW de_twitter_location; Type: COMMENT; Schema: public; Owner: meco
  487. --
  488.  
  489. COMMENT ON VIEW de_twitter_location IS 'vyber všechny německé tweety a k nim entity s takovým typem, že se jedná nějakým způsobem o lokaci';
  490.  
  491.  
  492. --
  493. -- Name: de_twitter_location_with_MedicalCondition; Type: VIEW; Schema: public; Owner: meco
  494. --
  495.  
  496. CREATE VIEW "de_twitter_location_with_MedicalCondition" AS
  497.     SELECT DISTINCT d.id, d.text AS tweet, e.name AS entity, et.TYPE AS entity_type FROM (((documents d JOIN instances i ON ((i.item_id = d.id))) JOIN entities e ON ((i.entity_id = e.id))) JOIN enttypes et ON ((e.enttype_id = et.id))) WHERE ((((((d.LANGUAGE)::text = 'de'::text) AND (d._calaised = TRUE)) AND (d.source_id IN (SELECT sources_twitter.id FROM sources_twitter))) AND (et.id = ANY (ARRAY[7, 10, 11, 14, 17, 18, 49]))) AND (EXISTS (SELECT dd.id, dd.LANGUAGE, dd.source_id, dd.author_id, dd."timestamp", dd.guid, dd.link, dd.title, dd.text, dd.georss_lat, dd.georss_lon, dd.html_description, dd.html_keywords, dd.pubdate, dd.pubtime, dd.sentences, dd.termvector, dd._calaised, dd._analyzed, dd._relevance, dd._stanford, ii.id, ii.entity_id, ii.item_id, ii.exact, ii.offset_, ii.LENGTH, ii.sid, ii.begintoken, ii.endtoken, ee.id, ee.name, ee.enttype_id, ee.reference, ee.normalized_entity, eet.id, eet.TYPE, eet.reference FROM (((documents dd JOIN instances ii ON ((ii.item_id = dd.id))) JOIN entities ee ON ((ii.entity_id = ee.id))) JOIN enttypes eet ON ((ee.enttype_id = eet.id))) WHERE ((dd.id = d.id) AND (eet.id = 13))))) ORDER BY d.id, d.text, e.name, et.TYPE;
  498.  
  499.  
  500. ALTER TABLE public."de_twitter_location_with_MedicalCondition" OWNER TO meco;
  501.  
  502. --
  503. -- Name: VIEW "de_twitter_location_with_MedicalCondition"; Type: COMMENT; Schema: public; Owner: meco
  504. --
  505.  
  506. COMMENT ON VIEW "de_twitter_location_with_MedicalCondition" IS 'Vyber všechny německé tweety s nějakou tou entitou typu různých Location. Další podmínka je výskyt entity typu 13 MedicalCondition, což znamená, že tweet je "relevantnější".';
  507.  
  508.  
  509. --
  510. -- Name: de_twitter_no_location; Type: VIEW; Schema: public; Owner: meco
  511. --
  512.  
  513. CREATE VIEW de_twitter_no_location AS
  514.     SELECT d.id, d.text FROM documents d WHERE (((NOT (d.id IN (SELECT de_twitter_location.id FROM de_twitter_location))) AND ((d.LANGUAGE)::text = 'de'::text)) AND (d.source_id IN (SELECT sources_twitter.id FROM sources_twitter))) ORDER BY d.id;
  515.  
  516.  
  517. ALTER TABLE public.de_twitter_no_location OWNER TO meco;
  518.  
  519. --
  520. -- Name: VIEW de_twitter_no_location; Type: COMMENT; Schema: public; Owner: meco
  521. --
  522.  
  523. COMMENT ON VIEW de_twitter_no_location IS 'Zeptá se de_twitter_location na twíty s lokací a vybere všechny ostatní (tj. twíty německé bez lokace)';
  524.  
  525.  
  526. --
  527. -- Name: diseases; Type: TABLE; Schema: public; Owner: meco; Tablespace:
  528. --
  529.  
  530. CREATE TABLE diseases (
  531.     id INTEGER NOT NULL,
  532.     disease_id INTEGER,
  533.     disease CHARACTER VARYING(255),
  534.     LANGUAGE CHARACTER VARYING(2),
  535.     _new BOOLEAN DEFAULT TRUE
  536. );
  537.  
  538.  
  539. ALTER TABLE public.diseases OWNER TO meco;
  540.  
  541. --
  542. -- Name: diseases_id_seq; Type: SEQUENCE; Schema: public; Owner: meco
  543. --
  544.  
  545. CREATE SEQUENCE diseases_id_seq
  546.     INCREMENT BY 1
  547.     NO MAXVALUE
  548.     NO MINVALUE
  549.     CACHE 1;
  550.  
  551.  
  552. ALTER TABLE public.diseases_id_seq OWNER TO meco;
  553.  
  554. --
  555. -- Name: diseases_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: meco
  556. --
  557.  
  558. ALTER SEQUENCE diseases_id_seq OWNED BY diseases.id;
  559.  
  560.  
  561. --
  562. -- Name: documents_id_seq; Type: SEQUENCE; Schema: public; Owner: meco
  563. --
  564.  
  565. CREATE SEQUENCE documents_id_seq
  566.     INCREMENT BY 1
  567.     NO MAXVALUE
  568.     NO MINVALUE
  569.     CACHE 1;
  570.  
  571.  
  572. ALTER TABLE public.documents_id_seq OWNER TO meco;
  573.  
  574. --
  575. -- Name: documents_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: meco
  576. --
  577.  
  578. ALTER SEQUENCE documents_id_seq OWNED BY documents.id;
  579.  
  580.  
  581. --
  582. -- Name: downloadurl; Type: TABLE; Schema: public; Owner: meco; Tablespace:
  583. --
  584.  
  585. CREATE TABLE downloadurl (
  586.     entity_id INTEGER NOT NULL,
  587.     document_id INTEGER
  588. );
  589.  
  590.  
  591. ALTER TABLE public.downloadurl OWNER TO meco;
  592.  
  593. --
  594. -- Name: TABLE downloadurl; Type: COMMENT; Schema: public; Owner: meco
  595. --
  596.  
  597. COMMENT ON TABLE downloadurl IS 'Download url entities';
  598.  
  599.  
  600. --
  601. -- Name: downloadurl_document_id_seq; Type: SEQUENCE; Schema: public; Owner: meco
  602. --
  603.  
  604. CREATE SEQUENCE downloadurl_document_id_seq
  605.     INCREMENT BY 1
  606.     NO MAXVALUE
  607.     NO MINVALUE
  608.     CACHE 1;
  609.  
  610.  
  611. ALTER TABLE public.downloadurl_document_id_seq OWNER TO meco;
  612.  
  613. --
  614. -- Name: downloadurl_document_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: meco
  615. --
  616.  
  617. ALTER SEQUENCE downloadurl_document_id_seq OWNED BY downloadurl.document_id;
  618.  
  619.  
  620. --
  621. -- Name: downloadurl_entity_id_seq; Type: SEQUENCE; Schema: public; Owner: meco
  622. --
  623.  
  624. CREATE SEQUENCE downloadurl_entity_id_seq
  625.     START WITH 1
  626.     INCREMENT BY 1
  627.     NO MAXVALUE
  628.     NO MINVALUE
  629.     CACHE 1;
  630.  
  631.  
  632. ALTER TABLE public.downloadurl_entity_id_seq OWNER TO meco;
  633.  
  634. --
  635. -- Name: downloadurl_entity_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: meco
  636. --
  637.  
  638. ALTER SEQUENCE downloadurl_entity_id_seq OWNED BY downloadurl.entity_id;
  639.  
  640.  
  641. --
  642. -- Name: entities_id_seq; Type: SEQUENCE; Schema: public; Owner: meco
  643. --
  644.  
  645. CREATE SEQUENCE entities_id_seq
  646.     INCREMENT BY 1
  647.     NO MAXVALUE
  648.     NO MINVALUE
  649.     CACHE 1;
  650.  
  651.  
  652. ALTER TABLE public.entities_id_seq OWNER TO meco;
  653.  
  654. --
  655. -- Name: entities_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: meco
  656. --
  657.  
  658. ALTER SEQUENCE entities_id_seq OWNED BY entities.id;
  659.  
  660.  
  661. --
  662. -- Name: enttypes_id_seq; Type: SEQUENCE; Schema: public; Owner: meco
  663. --
  664.  
  665. CREATE SEQUENCE enttypes_id_seq
  666.     INCREMENT BY 1
  667.     NO MAXVALUE
  668.     NO MINVALUE
  669.     CACHE 1;
  670.  
  671.  
  672. ALTER TABLE public.enttypes_id_seq OWNER TO meco;
  673.  
  674. --
  675. -- Name: enttypes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: meco
  676. --
  677.  
  678. ALTER SEQUENCE enttypes_id_seq OWNED BY enttypes.id;
  679.  
  680.  
  681. --
  682. -- Name: instances_id_seq; Type: SEQUENCE; Schema: public; Owner: meco
  683. --
  684.  
  685. CREATE SEQUENCE instances_id_seq
  686.     INCREMENT BY 1
  687.     NO MAXVALUE
  688.     NO MINVALUE
  689.     CACHE 1;
  690.  
  691.  
  692. ALTER TABLE public.instances_id_seq OWNER TO meco;
  693.  
  694. --
  695. -- Name: instances_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: meco
  696. --
  697.  
  698. ALTER SEQUENCE instances_id_seq OWNED BY instances.id;
  699.  
  700.  
  701. --
  702. -- Name: langs; Type: TABLE; Schema: public; Owner: meco; Tablespace:
  703. --
  704.  
  705. CREATE TABLE langs (
  706.     lang CHARACTER VARYING(12) NOT NULL,
  707.     LANGUAGE regconfig
  708. );
  709.  
  710.  
  711. ALTER TABLE public.langs OWNER TO meco;
  712.  
  713. --
  714. -- Name: TABLE langs; Type: COMMENT; Schema: public; Owner: meco
  715. --
  716.  
  717. COMMENT ON TABLE langs IS 'Stahovane jazyky. Ktere zde nejsou, budou zahozeny. K jazykove zkratce je nutno pripojit i spravny "regconfig" -- plny nazev pro FULL TEXT SEARCH.';
  718.  
  719.  
  720. --
  721. -- Name: logs; Type: TABLE; Schema: public; Owner: meco; Tablespace:
  722. --
  723.  
  724. CREATE TABLE logs (
  725.     "timestamp" TIMESTAMP WITHOUT TIME zone NOT NULL,
  726.     TYPE CHARACTER VARYING(64) NOT NULL,
  727.     VALUE BIGINT NOT NULL,
  728.     param CHARACTER VARYING(64)
  729. );
  730.  
  731.  
  732. ALTER TABLE public.logs OWNER TO meco;
  733.  
  734. --
  735. -- Name: logs_value_seq; Type: SEQUENCE; Schema: public; Owner: meco
  736. --
  737.  
  738. CREATE SEQUENCE logs_value_seq
  739.     START WITH 1
  740.     INCREMENT BY 1
  741.     NO MAXVALUE
  742.     NO MINVALUE
  743.     CACHE 1;
  744.  
  745.  
  746. ALTER TABLE public.logs_value_seq OWNER TO meco;
  747.  
  748. --
  749. -- Name: logs_value_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: meco
  750. --
  751.  
  752. ALTER SEQUENCE logs_value_seq OWNED BY logs.VALUE;
  753.  
  754.  
  755. --
  756. -- Name: prefered_sources; Type: VIEW; Schema: public; Owner: meco
  757. --
  758.  
  759. CREATE VIEW prefered_sources AS
  760.     SELECT sources.id, sources.link, sources.LANGUAGE, sources.etag, sources.modified, sources.SECTION, sources._stahovak, sources._follow, sources.normalized_section FROM sources WHERE ((((sources.SECTION)::text = 'Medisys'::text) OR ((sources.SECTION)::text = 'medworm'::text)) OR (sources.id = 8793));
  761.  
  762.  
  763. ALTER TABLE public.prefered_sources OWNER TO meco;
  764.  
  765. --
  766. -- Name: pubtypes_sources; Type: TABLE; Schema: public; Owner: meco; Tablespace:
  767. --
  768.  
  769. CREATE TABLE pubtypes_sources (
  770.     source_id INTEGER,
  771.     pubtype CHARACTER VARYING(32)
  772. );
  773.  
  774.  
  775. ALTER TABLE public.pubtypes_sources OWNER TO meco;
  776.  
  777. --
  778. -- Name: sources_id_seq; Type: SEQUENCE; Schema: public; Owner: meco
  779. --
  780.  
  781. CREATE SEQUENCE sources_id_seq
  782.     INCREMENT BY 1
  783.     NO MAXVALUE
  784.     NO MINVALUE
  785.     CACHE 1;
  786.  
  787.  
  788. ALTER TABLE public.sources_id_seq OWNER TO meco;
  789.  
  790. --
  791. -- Name: sources_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: meco
  792. --
  793.  
  794. ALTER SEQUENCE sources_id_seq OWNED BY sources.id;
  795.  
  796.  
  797. --
  798. -- Name: stat_count_doc_alchemized; Type: VIEW; Schema: public; Owner: meco
  799. --
  800.  
  801. CREATE VIEW stat_count_doc_alchemized AS
  802.     SELECT COUNT(*) AS COUNT FROM documents WHERE (((documents.LANGUAGE)::text = 'de'::text) AND (documents._calaised = TRUE));
  803.  
  804.  
  805. ALTER TABLE public.stat_count_doc_alchemized OWNER TO meco;
  806.  
  807. --
  808. -- Name: VIEW stat_count_doc_alchemized; Type: COMMENT; Schema: public; Owner: meco
  809. --
  810.  
  811. COMMENT ON VIEW stat_count_doc_alchemized IS 'Počet dokumentů anotovaných AlchemyAPI.';
  812.  
  813.  
  814. --
  815. -- Name: stat_count_doc_analyzed; Type: VIEW; Schema: public; Owner: meco
  816. --
  817.  
  818. CREATE VIEW stat_count_doc_analyzed AS
  819.     SELECT COUNT(*) AS COUNT FROM documents WHERE (documents._analyzed = TRUE);
  820.  
  821.  
  822. ALTER TABLE public.stat_count_doc_analyzed OWNER TO meco;
  823.  
  824. --
  825. -- Name: VIEW stat_count_doc_analyzed; Type: COMMENT; Schema: public; Owner: meco
  826. --
  827.  
  828. COMMENT ON VIEW stat_count_doc_analyzed IS 'Počet analyzovaných dokumentů.';
  829.  
  830.  
  831. --
  832. -- Name: stat_count_doc_per_source; Type: VIEW; Schema: public; Owner: meco
  833. --
  834.  
  835. CREATE VIEW stat_count_doc_per_source AS
  836.     SELECT COUNT(1) AS pocet, sources.SECTION FROM documents, sources WHERE (documents.source_id = sources.id) GROUP BY sources.SECTION ORDER BY COUNT(1);
  837.  
  838.  
  839. ALTER TABLE public.stat_count_doc_per_source OWNER TO meco;
  840.  
  841. --
  842. -- Name: VIEW stat_count_doc_per_source; Type: COMMENT; Schema: public; Owner: meco
  843. --
  844.  
  845. COMMENT ON VIEW stat_count_doc_per_source IS 'pocet dokumentů z každého fóra';
  846.  
  847.  
  848. --
  849. -- Name: stat_count_doc_stanford; Type: VIEW; Schema: public; Owner: meco
  850. --
  851.  
  852. CREATE VIEW stat_count_doc_stanford AS
  853.     SELECT COUNT(*) AS COUNT FROM documents WHERE (documents._stanford = TRUE);
  854.  
  855.  
  856. ALTER TABLE public.stat_count_doc_stanford OWNER TO meco;
  857.  
  858. --
  859. -- Name: symptoms; Type: TABLE; Schema: public; Owner: meco; Tablespace:
  860. --
  861.  
  862. CREATE TABLE symptoms (
  863.     id INTEGER NOT NULL,
  864.     symptom CHARACTER VARYING(255),
  865.     LANGUAGE CHARACTER VARYING(2),
  866.     _new BOOLEAN DEFAULT TRUE
  867. );
  868.  
  869.  
  870. ALTER TABLE public.symptoms OWNER TO meco;
  871.  
  872. --
  873. -- Name: symptoms_id_seq; Type: SEQUENCE; Schema: public; Owner: meco
  874. --
  875.  
  876. CREATE SEQUENCE symptoms_id_seq
  877.     INCREMENT BY 1
  878.     NO MAXVALUE
  879.     NO MINVALUE
  880.     CACHE 1;
  881.  
  882.  
  883. ALTER TABLE public.symptoms_id_seq OWNER TO meco;
  884.  
  885. --
  886. -- Name: symptoms_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: meco
  887. --
  888.  
  889. ALTER SEQUENCE symptoms_id_seq OWNED BY symptoms.id;
  890.  
  891.  
  892. --
  893. -- Name: terms; Type: TABLE; Schema: public; Owner: meco; Tablespace:
  894. --
  895.  
  896. CREATE TABLE terms (
  897.     term CHARACTER VARYING(255) NOT NULL,
  898.     id INTEGER NOT NULL
  899. );
  900.  
  901.  
  902. ALTER TABLE public.terms OWNER TO meco;
  903.  
  904. --
  905. -- Name: term_form_seq; Type: SEQUENCE; Schema: public; Owner: meco
  906. --
  907.  
  908. CREATE SEQUENCE term_form_seq
  909.     START WITH 1
  910.     INCREMENT BY 1
  911.     NO MAXVALUE
  912.     NO MINVALUE
  913.     CACHE 1;
  914.  
  915.  
  916. ALTER TABLE public.term_form_seq OWNER TO meco;
  917.  
  918. --
  919. -- Name: term_form_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: meco
  920. --
  921.  
  922. ALTER SEQUENCE term_form_seq OWNED BY terms.term;
  923.  
  924.  
  925. --
  926. -- Name: term_number_seq; Type: SEQUENCE; Schema: public; Owner: meco
  927. --
  928.  
  929. CREATE SEQUENCE term_number_seq
  930.     INCREMENT BY 1
  931.     NO MAXVALUE
  932.     NO MINVALUE
  933.     CACHE 1;
  934.  
  935.  
  936. ALTER TABLE public.term_number_seq OWNER TO meco;
  937.  
  938. --
  939. -- Name: term_number_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: meco
  940. --
  941.  
  942. ALTER SEQUENCE term_number_seq OWNED BY terms.id;
  943.  
  944.  
  945. --
  946. -- Name: id; Type: DEFAULT; Schema: public; Owner: meco
  947. --
  948.  
  949. ALTER TABLE authors ALTER COLUMN id SET DEFAULT NEXTVAL('authors_id_seq'::regclass);
  950.  
  951.  
  952. --
  953. -- Name: id; Type: DEFAULT; Schema: public; Owner: meco
  954. --
  955.  
  956. ALTER TABLE diseases ALTER COLUMN id SET DEFAULT NEXTVAL('diseases_id_seq'::regclass);
  957.  
  958.  
  959. --
  960. -- Name: id; Type: DEFAULT; Schema: public; Owner: meco
  961. --
  962.  
  963. ALTER TABLE documents ALTER COLUMN id SET DEFAULT NEXTVAL('documents_id_seq'::regclass);
  964.  
  965.  
  966. --
  967. -- Name: entity_id; Type: DEFAULT; Schema: public; Owner: meco
  968. --
  969.  
  970. ALTER TABLE downloadurl ALTER COLUMN entity_id SET DEFAULT NEXTVAL('downloadurl_entity_id_seq'::regclass);
  971.  
  972.  
  973. --
  974. -- Name: document_id; Type: DEFAULT; Schema: public; Owner: meco
  975. --
  976.  
  977. ALTER TABLE downloadurl ALTER COLUMN document_id SET DEFAULT NEXTVAL('downloadurl_document_id_seq'::regclass);
  978.  
  979.  
  980. --
  981. -- Name: id; Type: DEFAULT; Schema: public; Owner: meco
  982. --
  983.  
  984. ALTER TABLE entities ALTER COLUMN id SET DEFAULT NEXTVAL('entities_id_seq'::regclass);
  985.  
  986.  
  987. --
  988. -- Name: id; Type: DEFAULT; Schema: public; Owner: meco
  989. --
  990.  
  991. ALTER TABLE enttypes ALTER COLUMN id SET DEFAULT NEXTVAL('enttypes_id_seq'::regclass);
  992.  
  993.  
  994. --
  995. -- Name: id; Type: DEFAULT; Schema: public; Owner: meco
  996. --
  997.  
  998. ALTER TABLE instances ALTER COLUMN id SET DEFAULT NEXTVAL('instances_id_seq'::regclass);
  999.  
  1000.  
  1001. --
  1002. -- Name: id; Type: DEFAULT; Schema: public; Owner: meco
  1003. --
  1004.  
  1005. ALTER TABLE sources ALTER COLUMN id SET DEFAULT NEXTVAL('sources_id_seq'::regclass);
  1006.  
  1007.  
  1008. --
  1009. -- Name: id; Type: DEFAULT; Schema: public; Owner: meco
  1010. --
  1011.  
  1012. ALTER TABLE symptoms ALTER COLUMN id SET DEFAULT NEXTVAL('symptoms_id_seq'::regclass);
  1013.  
  1014.  
  1015. --
  1016. -- Name: id; Type: DEFAULT; Schema: public; Owner: meco
  1017. --
  1018.  
  1019. ALTER TABLE terms ALTER COLUMN id SET DEFAULT NEXTVAL('term_number_seq'::regclass);
  1020.  
  1021.  
  1022. --
  1023. -- Name: authors_guid_key; Type: CONSTRAINT; Schema: public; Owner: meco; Tablespace:
  1024. --
  1025.  
  1026. ALTER TABLE ONLY authors
  1027.     ADD CONSTRAINT authors_guid_key UNIQUE (guid);
  1028.  
  1029.  
  1030. --
  1031. -- Name: authors_pkey; Type: CONSTRAINT; Schema: public; Owner: meco; Tablespace:
  1032. --
  1033.  
  1034. ALTER TABLE ONLY authors
  1035.     ADD CONSTRAINT authors_pkey PRIMARY KEY (id);
  1036.  
  1037.  
  1038. --
  1039. -- Name: diseases_disease_key; Type: CONSTRAINT; Schema: public; Owner: meco; Tablespace:
  1040. --
  1041.  
  1042. ALTER TABLE ONLY diseases
  1043.     ADD CONSTRAINT diseases_disease_key UNIQUE (disease);
  1044.  
  1045.  
  1046. --
  1047. -- Name: diseases_pkey; Type: CONSTRAINT; Schema: public; Owner: meco; Tablespace:
  1048. --
  1049.  
  1050. ALTER TABLE ONLY diseases
  1051.     ADD CONSTRAINT diseases_pkey PRIMARY KEY (id);
  1052.  
  1053.  
  1054. --
  1055. -- Name: documents_guid_key; Type: CONSTRAINT; Schema: public; Owner: meco; Tablespace:
  1056. --
  1057.  
  1058. ALTER TABLE ONLY documents
  1059.     ADD CONSTRAINT documents_guid_key UNIQUE (guid);
  1060.  
  1061.  
  1062. --
  1063. -- Name: documents_pkey; Type: CONSTRAINT; Schema: public; Owner: meco; Tablespace:
  1064. --
  1065.  
  1066. ALTER TABLE ONLY documents
  1067.     ADD CONSTRAINT documents_pkey PRIMARY KEY (id);
  1068.  
  1069.  
  1070. --
  1071. -- Name: entities_pkey; Type: CONSTRAINT; Schema: public; Owner: meco; Tablespace:
  1072. --
  1073.  
  1074. ALTER TABLE ONLY entities
  1075.     ADD CONSTRAINT entities_pkey PRIMARY KEY (id);
  1076.  
  1077.  
  1078. --
  1079. -- Name: enttypes_pkey; Type: CONSTRAINT; Schema: public; Owner: meco; Tablespace:
  1080. --
  1081.  
  1082. ALTER TABLE ONLY enttypes
  1083.     ADD CONSTRAINT enttypes_pkey PRIMARY KEY (id);
  1084.  
  1085.  
  1086. --
  1087. -- Name: enttypes_type_key; Type: CONSTRAINT; Schema: public; Owner: meco; Tablespace:
  1088. --
  1089.  
  1090. ALTER TABLE ONLY enttypes
  1091.     ADD CONSTRAINT enttypes_type_key UNIQUE (TYPE);
  1092.  
  1093.  
  1094. --
  1095. -- Name: instances_pkey; Type: CONSTRAINT; Schema: public; Owner: meco; Tablespace:
  1096. --
  1097.  
  1098. ALTER TABLE ONLY instances
  1099.     ADD CONSTRAINT instances_pkey PRIMARY KEY (id);
  1100.  
  1101.  
  1102. --
  1103. -- Name: langs_pkey; Type: CONSTRAINT; Schema: public; Owner: meco; Tablespace:
  1104. --
  1105.  
  1106. ALTER TABLE ONLY langs
  1107.     ADD CONSTRAINT langs_pkey PRIMARY KEY (lang);
  1108.  
  1109.  
  1110. --
  1111. -- Name: name_coords_uniq; Type: CONSTRAINT; Schema: public; Owner: meco; Tablespace:
  1112. --
  1113.  
  1114. ALTER TABLE ONLY entities
  1115.     ADD CONSTRAINT name_coords_uniq UNIQUE (name, coordinates);
  1116.  
  1117.  
  1118. --
  1119. -- Name: sources_link_key; Type: CONSTRAINT; Schema: public; Owner: meco; Tablespace:
  1120. --
  1121.  
  1122. ALTER TABLE ONLY sources
  1123.     ADD CONSTRAINT sources_link_key UNIQUE (link);
  1124.  
  1125.  
  1126. --
  1127. -- Name: sources_pkey; Type: CONSTRAINT; Schema: public; Owner: meco; Tablespace:
  1128. --
  1129.  
  1130. ALTER TABLE ONLY sources
  1131.     ADD CONSTRAINT sources_pkey PRIMARY KEY (id);
  1132.  
  1133.  
  1134. --
  1135. -- Name: symptoms_pkey; Type: CONSTRAINT; Schema: public; Owner: meco; Tablespace:
  1136. --
  1137.  
  1138. ALTER TABLE ONLY symptoms
  1139.     ADD CONSTRAINT symptoms_pkey PRIMARY KEY (id);
  1140.  
  1141.  
  1142. --
  1143. -- Name: terms_pkey; Type: CONSTRAINT; Schema: public; Owner: meco; Tablespace:
  1144. --
  1145.  
  1146. ALTER TABLE ONLY terms
  1147.     ADD CONSTRAINT terms_pkey PRIMARY KEY (id);
  1148.  
  1149.  
  1150. --
  1151. -- Name: terms_term_key; Type: CONSTRAINT; Schema: public; Owner: meco; Tablespace:
  1152. --
  1153.  
  1154. ALTER TABLE ONLY terms
  1155.     ADD CONSTRAINT terms_term_key UNIQUE (term);
  1156.  
  1157.  
  1158. --
  1159. -- Name: uniq_symptom; Type: CONSTRAINT; Schema: public; Owner: meco; Tablespace:
  1160. --
  1161.  
  1162. ALTER TABLE ONLY symptoms
  1163.     ADD CONSTRAINT uniq_symptom UNIQUE (symptom);
  1164.  
  1165.  
  1166. --
  1167. -- Name: author_id_index; Type: INDEX; Schema: public; Owner: meco; Tablespace:
  1168. --
  1169.  
  1170. CREATE INDEX author_id_index ON documents USING btree (author_id);
  1171.  
  1172.  
  1173. --
  1174. -- Name: documents_analyzed; Type: INDEX; Schema: public; Owner: meco; Tablespace:
  1175. --
  1176.  
  1177. CREATE INDEX documents_analyzed ON documents USING btree (_stanford, _calaised, _analyzed);
  1178.  
  1179.  
  1180. --
  1181. -- Name: documents_fts_index; Type: INDEX; Schema: public; Owner: meco; Tablespace:
  1182. --
  1183.  
  1184. CREATE INDEX documents_fts_index ON documents USING gin (fts);
  1185.  
  1186.  
  1187. --
  1188. -- Name: documents_language; Type: INDEX; Schema: public; Owner: meco; Tablespace:
  1189. --
  1190.  
  1191. CREATE INDEX documents_language ON documents USING btree (LANGUAGE);
  1192.  
  1193.  
  1194. --
  1195. -- Name: documents_pubdate; Type: INDEX; Schema: public; Owner: meco; Tablespace:
  1196. --
  1197.  
  1198. CREATE INDEX documents_pubdate ON documents USING btree (pubdate, pubtime);
  1199.  
  1200.  
  1201. --
  1202. -- Name: documents_relevance; Type: INDEX; Schema: public; Owner: meco; Tablespace:
  1203. --
  1204.  
  1205. CREATE INDEX documents_relevance ON documents USING btree (_relevance);
  1206.  
  1207.  
  1208. --
  1209. -- Name: entities_enttype_id; Type: INDEX; Schema: public; Owner: meco; Tablespace:
  1210. --
  1211.  
  1212. CREATE INDEX entities_enttype_id ON entities USING btree (enttype_id);
  1213.  
  1214.  
  1215. --
  1216. -- Name: entities_normalized_entity; Type: INDEX; Schema: public; Owner: meco; Tablespace:
  1217. --
  1218.  
  1219. CREATE INDEX entities_normalized_entity ON entities USING hash (normalized_entity);
  1220.  
  1221.  
  1222. --
  1223. -- Name: entity_index; Type: INDEX; Schema: public; Owner: meco; Tablespace:
  1224. --
  1225.  
  1226. CREATE UNIQUE INDEX entity_index ON downloadurl USING btree (entity_id);
  1227.  
  1228.  
  1229. --
  1230. -- Name: instances_entity_id; Type: INDEX; Schema: public; Owner: meco; Tablespace:
  1231. --
  1232.  
  1233. CREATE INDEX instances_entity_id ON instances USING btree (entity_id);
  1234.  
  1235.  
  1236. --
  1237. -- Name: instances_item_id; Type: INDEX; Schema: public; Owner: meco; Tablespace:
  1238. --
  1239.  
  1240. CREATE INDEX instances_item_id ON instances USING btree (item_id);
  1241.  
  1242.  
  1243. --
  1244. -- Name: inserting_document_trigger; Type: TRIGGER; Schema: public; Owner: meco
  1245. --
  1246.  
  1247. CREATE TRIGGER inserting_document_trigger
  1248.     BEFORE INSERT ON documents
  1249.     FOR EACH ROW
  1250.     EXECUTE PROCEDURE inserting_document_f();
  1251.  
  1252.  
  1253. --
  1254. -- Name: inserting_trigger; Type: TRIGGER; Schema: public; Owner: meco
  1255. --
  1256.  
  1257. CREATE TRIGGER inserting_trigger
  1258.     BEFORE INSERT ON sources
  1259.     FOR EACH ROW
  1260.     EXECUTE PROCEDURE inserting_sources_f();
  1261.  
  1262.  
  1263. --
  1264. -- Name: authors_fk; Type: FK CONSTRAINT; Schema: public; Owner: meco
  1265. --
  1266.  
  1267. ALTER TABLE ONLY documents
  1268.     ADD CONSTRAINT authors_fk FOREIGN KEY (author_id) REFERENCES authors(id) ON UPDATE SET NULL ON DELETE SET NULL;
  1269.  
  1270.  
  1271. --
  1272. -- Name: doc_fk; Type: FK CONSTRAINT; Schema: public; Owner: meco
  1273. --
  1274.  
  1275. ALTER TABLE ONLY downloadurl
  1276.     ADD CONSTRAINT doc_fk FOREIGN KEY (document_id) REFERENCES documents(id) ON UPDATE CASCADE ON DELETE CASCADE;
  1277.  
  1278.  
  1279. --
  1280. -- Name: entity_fk; Type: FK CONSTRAINT; Schema: public; Owner: meco
  1281. --
  1282.  
  1283. ALTER TABLE ONLY downloadurl
  1284.     ADD CONSTRAINT entity_fk FOREIGN KEY (entity_id) REFERENCES entities(id) ON UPDATE CASCADE ON DELETE CASCADE;
  1285.  
  1286.  
  1287. --
  1288. -- Name: fk_entities_enttypes; Type: FK CONSTRAINT; Schema: public; Owner: meco
  1289. --
  1290.  
  1291. ALTER TABLE ONLY entities
  1292.     ADD CONSTRAINT fk_entities_enttypes FOREIGN KEY (enttype_id) REFERENCES enttypes(id);
  1293.  
  1294.  
  1295. --
  1296. -- Name: fk_instances_documents; Type: FK CONSTRAINT; Schema: public; Owner: meco
  1297. --
  1298.  
  1299. ALTER TABLE ONLY instances
  1300.     ADD CONSTRAINT fk_instances_documents FOREIGN KEY (item_id) REFERENCES documents(id) ON UPDATE CASCADE ON DELETE CASCADE;
  1301.  
  1302.  
  1303. --
  1304. -- Name: fk_instances_entities; Type: FK CONSTRAINT; Schema: public; Owner: meco
  1305. --
  1306.  
  1307. ALTER TABLE ONLY instances
  1308.     ADD CONSTRAINT fk_instances_entities FOREIGN KEY (entity_id) REFERENCES entities(id) ON UPDATE CASCADE ON DELETE CASCADE;
  1309.  
  1310.  
  1311. --
  1312. -- Name: fk_pubtypes_sources_sources; Type: FK CONSTRAINT; Schema: public; Owner: meco
  1313. --
  1314.  
  1315. ALTER TABLE ONLY pubtypes_sources
  1316.     ADD CONSTRAINT fk_pubtypes_sources_sources FOREIGN KEY (source_id) REFERENCES sources(id);
  1317.  
  1318.  
  1319. --
  1320. -- Name: source_fk; Type: FK CONSTRAINT; Schema: public; Owner: meco
  1321. --
  1322.  
  1323. ALTER TABLE ONLY documents
  1324.     ADD CONSTRAINT source_fk FOREIGN KEY (source_id) REFERENCES sources(id) ON UPDATE CASCADE ON DELETE SET NULL;
  1325.  
  1326.  
  1327. --
  1328. -- Name: public; Type: ACL; Schema: -; Owner: ischmidt
  1329. --
  1330.  
  1331. REVOKE ALL ON SCHEMA public FROM PUBLIC;
  1332. REVOKE ALL ON SCHEMA public FROM ischmidt;
  1333. GRANT ALL ON SCHEMA public TO ischmidt;
  1334. GRANT ALL ON SCHEMA public TO PUBLIC;
  1335.  
  1336.  
  1337. --
  1338. -- Name: inserting_document_f(); Type: ACL; Schema: public; Owner: meco
  1339. --
  1340.  
  1341. REVOKE ALL ON FUNCTION inserting_document_f() FROM PUBLIC;
  1342. REVOKE ALL ON FUNCTION inserting_document_f() FROM meco;
  1343. GRANT ALL ON FUNCTION inserting_document_f() TO meco;
  1344. GRANT ALL ON FUNCTION inserting_document_f() TO PUBLIC;
  1345.  
  1346.  
  1347. --
  1348. -- PostgreSQL database dump complete
  1349. --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement