Changeset 507 for trunk


Ignore:
Timestamp:
Mar 25, 2007, 5:27:38 PM (13 years ago)
Author:
Nick Burch
Message:

Support storing GB or Irish eastings and northings, but always one matching set

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/npemap.org.uk/schema_postgres.sql

    r331 r507  
    2525    raw_postcode_outward character varying(30) NOT NULL,
    2626    raw_postcode_inward character varying(30),
    27     easting integer NOT NULL,
    28     northing integer NOT NULL,
     27
     28        -- Constraints ensure we get a matching pair
     29    easting integer,
     30    northing integer,
     31        ie_easting integer,
     32        ie_northing integer,
     33
    2934    ip inet,
    3035    created_at timestamp without time zone NOT NULL default NOW(),
     
    3540
    3641        CONSTRAINT pk_postcode PRIMARY KEY (id),
    37         CONSTRAINT fk_postcode_source FOREIGN KEY (source) REFERENCES sources (id)
     42        CONSTRAINT fk_postcode_source FOREIGN KEY (source) REFERENCES sources (id),
     43        CONSTRAINT c_postcode_easting CHECK (CASE WHEN easting IS NULL then 1 else 0 END + CASE WHEN ie_easting IS NULL then 1 else 0 END = 1),
     44        CONSTRAINT c_postcode_northing CHECK (CASE WHEN northing IS NULL then 1 else 0 END + CASE WHEN ie_northing IS NULL then 1 else 0 END = 1),
     45        CONSTRAINT c_postcode_same_en CHECK ( (easting IS NULL AND northing IS NULL) OR (easting IS NOT NULL AND northing IS NOT NULL) )
    3846);
    3947
Note: See TracChangeset for help on using the changeset viewer.