-- ABS-58862 / ABS-91688

--------- ADDRESSTAXAREAID --------------

CREATE TABLE ADDRESSTAXAREAID 
(
ADDRESS_ID NUMBER NOT NULL,
TAXAREAID VARCHAR2(9) NOT NULL,
MANUALLYSETSYSTEMUSER_ID NUMBER NULL,
MANUALLYSETTIMESTAMP DATE NULL,
SYSTEMUSER_ID NUMBER NOT NULL,
TIMESTAMP DATE NOT NULL
);
                                      
COMMENT ON COLUMN ADDRESSTAXAREAID.MANUALLYSETSYSTEMUSER_ID
IS 'System user who manually set the tax areas';

COMMENT ON COLUMN ADDRESSTAXAREAID.MANUALLYSETTIMESTAMP
IS 'Date/time of manual setting';

ALTER TABLE ADDRESSTAXAREAID ADD CONSTRAINT XPKADDRESSTAXAREAID PRIMARY KEY (ADDRESS_ID);

ALTER TABLE ADDRESSTAXAREAID
    ADD CONSTRAINT FK_ADDRESSTAXAREAID_ADDRESS FOREIGN KEY (ADDRESS_ID)
    REFERENCES ADDRESS (ADDRESS_ID) ON DELETE CASCADE;