DROP TABLE CUSTOMER;
DROP TABLE ONLINECUSTOMER;
DROP TABLE OPENJPA_SEQUENCE_TABLE;

-- CREATE DATABASE "JPA-INHERITANCEBD"
--   WITH OWNER = postgres
--        ENCODING = 'SQL_ASCII'
--        TABLESPACE = pg_default;

CREATE TABLE OPENJPA_SEQUENCE_TABLE (ID SMALLINT NOT NULL, SEQUENCE_VALUE BIGINT, PRIMARY KEY (ID));

CREATE TABLE CUSTOMER (
      CUST_ID INTEGER NOT NULL ,
      FIRST_NAME VARCHAR(50) NOT NULL,
      LAST_NAME  VARCHAR(50),
      STREET  VARCHAR(50),
      APPT  VARCHAR(20),
      CITY  VARCHAR(25),
      ZIP_CODE  VARCHAR(10) NOT NULL,
      CUST_TYPE VARCHAR(10) NOT NULL ,
      WEBSITE  VARCHAR(100),
      LAST_UPDATED_TIME TIMESTAMP
);


ALTER TABLE CUSTOMER ADD CONSTRAINT CUSTOMER_PK Primary Key (CUST_ID);

CREATE TABLE ONLINECUSTOMER (
      CUST_ID INTEGER NOT NULL ,
      FIRST_NAME VARCHAR(50),
      LAST_NAME  VARCHAR(50),
      STREET  VARCHAR(50),
      APPT  VARCHAR(20),
      CITY  VARCHAR(25),
      ZIP_CODE  VARCHAR(10),
      CUST_TYPE VARCHAR(10)  ,
      WEBSITE  VARCHAR(100),
      LAST_UPDATED_TIME TIMESTAMP

);

ALTER TABLE ONLINECUSTOMER ADD CONSTRAINT ONLINECUSTOMER_PK Primary Key (CUST_ID);



