CREATE TABLE CUSTOMERS
(
  USERID VARCHAR(50) NOT NULL,
  PRIMARY KEY (USERID)
);

CREATE TABLE PROFILES
(
  ID INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), 
  PREFERREDLANGUAGE VARCHAR(50),
  MYLISTPREFERENCE CHAR(10),
  FAVORITECATEGORY VARCHAR(50),
  BANNERPREFERENCE CHAR(10),
  FK_USERID VARCHAR(50),
  PRIMARY KEY (ID)
);

CREATE TABLE CREDITCARDS
(
  ID INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
  CARDTYPE VARCHAR(50),
  EXPIRYDATE VARCHAR(50),
  CARDNUMBER VARCHAR(50),
  FK_ACCOUNTID INTEGER,
  FK_ORDERID INTEGER,
  PRIMARY KEY (ID)
);

CREATE TABLE CONTACTINFOS
(
  ID INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
  FAMILYNAME VARCHAR(50),
  TELEPHONE VARCHAR(50),
  GIVENNAME VARCHAR(50),
  EMAIL VARCHAR(50),
  FK_ACCOUNTID INTEGER,
  FK_POID VARCHAR(50),
  PRIMARY KEY (ID)
);

CREATE TABLE ADDRESSES
(
  ID INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
  ZIPCODE VARCHAR(50),
  STATE VARCHAR(50),
  STREETNAME2 VARCHAR(50),
  STREETNAME1 VARCHAR(50),
  COUNTRY VARCHAR(50),
  CITY VARCHAR(50),
  FK_CONTACTINFOID INTEGER,
  PRIMARY KEY (ID)
);

CREATE TABLE ACCOUNTS
(
  ID INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
  STATUS VARCHAR(50),
  FK_USERID VARCHAR(50),
  PRIMARY KEY (ID)
);

CREATE TABLE USERS
(
  PASSWORD VARCHAR(50) NOT NULL,
  USERNAME VARCHAR(50) NOT NULL,
  PRIMARY KEY (PASSWORD, USERNAME)
);

CREATE TABLE COUNTERS
(
  COUNTER INTEGER,
  NAME VARCHAR(50) NOT NULL,
  PRIMARY KEY (NAME)
);

CREATE TABLE INVENTORY
(
  ITEMID VARCHAR(50) NOT NULL,
  QUANTITY INTEGER NOT NULL,
  PRIMARY KEY (ITEMID)
);

CREATE TABLE SUPPLIERORDERS
(
  POID VARCHAR(50) NOT NULL,
  PODATE BIGINT,
  POSTATUS VARCHAR(50),
  PRIMARY KEY (POID)
);

CREATE TABLE PURCHASEORDERS
(
  POID VARCHAR(50) NOT NULL,
  POUSERID VARCHAR(50),
  POEMAILID VARCHAR(50),
  PODATE BIGINT,
  POLOCALE VARCHAR(50),
  POVALUE VARCHAR(50),
  PRIMARY KEY (POID)
);

CREATE TABLE LINEITEMS
(
  ID INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
  CATEGORYID VARCHAR(50),
  PRODUCTID VARCHAR(50),
  ITEMID VARCHAR(50),
  LINENUMBER VARCHAR(50),
  QUANTITY INTEGER,
  UNITPRICE DECIMAL(10,2),
  QUANTITYSHIPPED INTEGER,
  FK_POID VARCHAR(50),
  PRIMARY KEY (ID)
);

CREATE TABLE MANAGERS
(
  STATUS VARCHAR(50),
  ORDERID VARCHAR(50) NOT NULL,
  PRIMARY KEY (ORDERID)  
);
