source: TI01-discovery-Ingest/trunk/v4.3.0/ingestAutomation-upgrade/database/original_document.sql @ 7185

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI01-discovery-Ingest/trunk/v4.3.0/ingestAutomation-upgrade/database/original_document.sql@7185
Revision 7185, 3.0 KB checked in by sdonegan, 10 years ago (diff)

Adding files from v4.2.0 tag to form basis for v4.3.0 version

Line 
1/*
2 * Table storing the original document with its format and the TSVector format - for text searches
3 *
4 * C Byrom Apr 08
5 *
6 */
7DROP TABLE original_document CASCADE;
8CREATE TABLE original_document (
9        original_document_id SERIAL primary key,
10                original_document_filename varchar(255),
11                discovery_id    varchar(255) unique not null,
12                original_format text,
13                original_format_name text,
14                original_format_version text,
15                datacentre_name text,
16                dataset_name text,
17                dataset_abstract text,
18                dataset_metadata_update_date timestamp, -- update/revision of actual metadata content by DC
19                dataset_metadata_creation_date timestamp, -- creation date of actual metadata content by DC
20                dataset_metadata_publication_date timestamp, -- publication date of actual metadata content by DC
21                dataset_start_date_nom timestamp, -- simplest method to allow ordering by date when no date info present in temporal table!!
22                dataset_end_date_nom timestamp, -- ditto for end data ordering
23                document_ts_vector      tsvector, -- note original_document taken out
24                authors text, --original text version so can return original info
25                authors_ts_vector       tsvector,
26                parameters text, --original text version so can return original info
27                parameters_ts_vector    tsvector,
28                resource_type text, --original text version so can return original info
29                resource_type_ts_vector   tsvector,
30                topic_category text, --original text version so can return original info
31                topic_category_ts_vector  tsvector,
32                lineage text, --original text version so can return original info
33                lineage_ts_vector tsvector,
34                limitations_public_access text, --original text version so can return original info
35                limitations_public_access_ts_vector   tsvector,
36                data_formats text, -- original text version for data formats
37                data_formats_tsvector tsvector,
38                data_originator text, -- for returning actual value of data originator
39                data_originator_tsvector tsvector,      -- to allow searching of data originator as a targeted search
40                scope_ts_vector tsvector,
41                create_date     timestamp, -- creation date of upload of record in the Discovery DB
42                update_date timestamp, -- subsequent date of update to the record in the Discovery DB
43                harvest_count int,      -- this is a counter to store the number of times a doc is repeatedly harvested, even though it hasn't changed
44                resultset_count int,    -- this is a counter to store the number of times a doc has been included in a resultset
45                access_count int,       -- this is a counter to store the number of times a link within the document has been used
46                scn                     int
47);
48
49-- create the mirror table for this table - to store audit histories
50DROP TABLE original_document_history CASCADE;
51SELECT * INTO original_document_history FROM original_document; 
52
53-- add a trigger to ensure the history table is populated by records when these change
54CREATE TRIGGER add_to_history_table
55   BEFORE UPDATE ON original_document
56                FOR EACH ROW EXECUTE PROCEDURE add_document_to_history();
57
58-- Create index on searchable column to speed up searches
59CREATE INDEX textsearch_idx ON original_document USING gin(document_ts_vector);
Note: See TracBrowser for help on using the repository browser.