Skip to content

Instantly share code, notes, and snippets.

@palmerj
Last active November 14, 2022 16:57
Show Gist options
  • Save palmerj/00cc867a0cb5c937c17f2539088cb502 to your computer and use it in GitHub Desktop.
Save palmerj/00cc867a0cb5c937c17f2539088cb502 to your computer and use it in GitHub Desktop.
Parcel <-> Title test QGIS relations
CREATE TABLE parcels (
id integer NOT NULL,
ldt_loc_id integer,
img_id integer,
fen_id integer,
toc_code character varying,
alt_id integer,
area double precision,
nonsurvey_def character varying,
appellation_date timestamp with time zone,
parcel_intent character varying,
status character varying,
total_area double precision,
calculated_area double precision,
audit_id integer,
se_row_id integer,
shape geometry(MultiSurface,4167)
);
CREATE INDEX parcels_shape_geom_idx ON parcels USING gist (shape);
ALTER TABLE ONLY parcels
ADD CONSTRAINT parcels_pkey PRIMARY KEY (id);
CREATE TABLE title (
audit_id integer NOT NULL,
title_no character varying,
ldt_loc_id integer,
register_type character varying,
ste_id integer,
issue_date timestamp with time zone,
guarantee_status character varying,
status character varying,
type character varying,
provisional character varying,
sur_wrk_id integer,
ttl_title_no_srs character varying,
ttl_title_no_head_srs character varying,
maori_land character varying
);
ALTER TABLE ONLY title
ADD CONSTRAINT title_pkey PRIMARY KEY (audit_id);
CREATE UNIQUE INDEX idx_ttl_title_no ON title USING btree (title_no);
CREATE TABLE title_parcel_association (
id integer NOT NULL,
ttl_title_no character varying,
par_id integer,
source character varying
);
ALTER TABLE ONLY title_parcel_association
ADD CONSTRAINT title_parcel_association_pkey PRIMARY KEY (id);
ALTER TABLE ONLY title_parcel_association
ADD CONSTRAINT fkey_parcel FOREIGN KEY (par_id) REFERENCES parcels(id) NOT VALID;
ALTER TABLE ONLY title_parcel_association
ADD CONSTRAINT fkey_title FOREIGN KEY (ttl_title_no) REFERENCES title(title_no) NOT VALID;
CREATE INDEX idx_tpa_par_id ON title_parcel_association USING btree (par_id);
CREATE INDEX idx_tpa_ttl_title_no ON title_parcel_association USING btree (ttl_title_no);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment