
--
-- Sampledb SQL database for AceQL usage tested with:
--  PostgreSQL 8.4.1+,

CREATE TABLE users
(               
  username              varchar(300)    not null,     
  encrypted_password    varchar(300)    not null,
        PRIMARY KEY (username)
);


CREATE TABLE banned_usernames
(               
  username              varchar(255)    not null,     
        PRIMARY KEY (username)
);


CREATE TABLE customer
(
    customer_id     integer     not null,
    customer_title  char(4)         null,
    fname           varchar(32)     null,
    lname           varchar(32) not null,
    addressline     varchar(64) not null,
    town            varchar(32) not null,
    zipcode         char(10)    not null,
    phone           varchar(32)     null,
        PRIMARY KEY(customer_id)
);

CREATE TABLE product_image
(
    product_id  integer     not null,
    name        varchar(64) not null,
    image       oid         null, 
        PRIMARY KEY(product_id)
);

--
-- orderlog table 
-- 

CREATE TABLE orderlog
(
    customer_id     integer     not null,
    item_id         integer     not null,
    description     varchar(64) not null,
    item_cost	    numeric     null,
    date_placed     date        not null,
    date_shipped    timestamp 	null, 
    jpeg_image      oid 	    null, 
    is_delivered    integer     null,
    quantity        integer     not null,    
         PRIMARY KEY(customer_id, item_id)
);

--
-- Example of a table with an auto-increment primary index
--

CREATE TABLE customer_auto
(
    customer_id     serial      not null,
    customer_title  char(4)     null,
    fname           varchar(32) null,
    lname           varchar(32) not null,
    addressline     varchar(64) null,
    town            varchar(32) null,
    zipcode         char(10)    not null,
    phone           varchar(32) null,
        PRIMARY KEY(customer_id)
);

--
-- documentation table
-- A CLOB example.

CREATE TABLE documentation
(
    item_id         integer     not null,
    item_doc        text        NOT NULL,         
         PRIMARY KEY(item_id)
);

--
-- Init the users table with a (username, encrypted_password)
--

insert into users values ('username', '5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8');

 