4. SQL Script

Excerpt from schema.sql

                
...

CREATE TABLE PERSON (
    ID INTEGER generated by default as identity (start with 1) not null,  
    FIRST_NAME varchar(50) not null,
    LAST_NAME varchar(50) not null,
    TYPE integer, 
	LAST_UPDATED TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
	LAST_UPDATE_USER VARCHAR(255) DEFAULT 'SYSTEM' NOT NULL,
	CREATED TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
	CREATE_USER VARCHAR(255) DEFAULT 'SYSTEM' NOT NULL,
    CONSTRAINT IDX_PERSON_ID PRIMARY KEY (ID),
    CONSTRAINT FK_PERSON_TYPE FOREIGN KEY (TYPE) REFERENCES PERSON_TYPE(ID)
);

...

CREATE TABLE ADDRESS (
    ID INTEGER generated by default as identity (start with 1) not null,
    PERSON_ID integer,  
    ADDRESS varchar(255),
    CITY varchar(50) not null,
    STATE varchar(50) null,
    ZIP_POSTAL varchar(30) not null,
    COUNTRY varchar(50) not null,
    LAST_UPDATED TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
    LAST_UPDATE_USER VARCHAR(255) DEFAULT 'SYSTEM' NOT NULL,
    CREATED TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
    CREATE_USER VARCHAR(255) DEFAULT 'SYSTEM' NOT NULL,
    CONSTRAINT IDX_ADDRESS_ID PRIMARY KEY (ID),
    CONSTRAINT FK_ADDRESS_PERSON_ID FOREIGN KEY (PERSON_ID) REFERENCES PERSON(ID) on delete cascade
);

...