Last active
August 29, 2015 14:11
-
-
Save GeorgeDewar/22ea744475a19b9871ff to your computer and use it in GitHub Desktop.
LINZ Landonline Schema
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drop table action_type cascade; | |
create table action_type ( | |
type varchar(4), | |
description varchar(200) not null, | |
system_action char(1) not null, | |
sob_name varchar(50), -- FK | |
existing_inst char(1) not null, | |
audit_id integer not null | |
); | |
COPY action_type from '/home/george/Downloads/memorial/landonline-action-type.csv' DELIMITER ',' CSV HEADER; | |
alter table action_type | |
add primary key (type), | |
add unique (audit_id) | |
; | |
drop table action cascade; | |
create table action ( | |
tin_id integer not null, | |
id integer not null, | |
sequence integer not null, | |
att_type varchar(4) not null, | |
system_action char(1) not null, | |
act_id_orig integer, | |
act_tin_id_orig integer, | |
ste_id integer, | |
mode varchar(4), | |
flags varchar(4), | |
source integer not null, | |
audit_id integer not null | |
); | |
COPY action from '/home/george/Downloads/memorial/landonline-action.csv' DELIMITER ',' CSV HEADER; | |
alter table action | |
add primary key (tin_id, id), | |
add foreign key (att_type) references action_type(type), | |
add foreign key (act_id_orig, act_tin_id_orig) references action (id, tin_id), | |
add unique (audit_id) | |
; | |
drop table title_action cascade; | |
create table title_action ( | |
ttl_title_no varchar(20),-- references title(title_no), | |
act_tin_id integer, | |
act_id integer, | |
audit_id integer not null | |
); | |
COPY title_action from '/home/george/Downloads/memorial/landonline-title-action.csv' DELIMITER ',' CSV HEADER; | |
alter table title_action | |
add primary key (ttl_title_no, act_tin_id, act_id), | |
add foreign key (act_id, act_tin_id) references action (id, tin_id), | |
add unique (audit_id) | |
); | |
drop table title_memorial cascade; | |
create table title_memorial ( | |
id integer, | |
ttl_title_no varchar(20) not null,-- references title(title_no), | |
mmt_code varchar(10) not null, | |
act_id_orig integer not null, | |
act_tin_id_orig integer not null, | |
act_id_crt integer not null, | |
act_tin_id_crt integer not null, | |
status varchar(4) not null, | |
user_changed char(1) not null, | |
text_type varchar(4) not null, | |
register_only_mem char(1), | |
prev_further_reg char(1), | |
curr_hist_flag varchar(4) not null, | |
"default" char(1) not null, | |
number_of_cols integer, | |
col_1_size integer, | |
col_2_size integer, | |
col_3_size integer, | |
col_4_size integer, | |
col_5_size integer, | |
col_6_size integer, | |
col_7_size integer, | |
act_id_ext integer, | |
act_tin_id_ext integer | |
); | |
COPY title_memorial from '/home/george/Downloads/memorial/landonline-title-memorial.csv' DELIMITER ',' CSV HEADER; | |
alter table title_memorial | |
add primary key (id), | |
add foreign key (act_id_orig, act_tin_id_orig) references action(id, tin_id), | |
add foreign key (act_id_crt, act_tin_id_crt) references action(id, tin_id), | |
add foreign key (act_id_ext, act_tin_id_ext) references action(id, tin_id) | |
; | |
drop table title_memorial_text cascade; | |
create table title_memorial_text ( | |
ttm_id integer, | |
sequence_no integer not null, | |
curr_hist_flag varchar(4) not null, | |
std_text varchar(18000), | |
col_1_text varchar(2048), | |
col_2_text varchar(2048), | |
col_3_text varchar(2048), | |
col_4_text varchar(2048), | |
col_5_text varchar(2048), | |
col_6_text varchar(2048), | |
col_7_text varchar(2048), | |
audit_id integer not null | |
); | |
COPY title_memorial_text from '/home/george/Downloads/memorial/landonline-title-memorial-text.csv' DELIMITER ',' CSV HEADER; | |
alter table title_memorial_text | |
add primary key (ttm_id, sequence_no), | |
add foreign key (ttm_id) references title_memorial(id), | |
add unique (audit_id) | |
; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment