Skip to content

Instantly share code, notes, and snippets.

@quiver
Last active July 11, 2017 21:49
Show Gist options
  • Save quiver/11079225 to your computer and use it in GitHub Desktop.
Save quiver/11079225 to your computer and use it in GitHub Desktop.
CREATE EXTENSION cstore_fdw;
CREATE SERVER cstore_server FOREIGN DATA WRAPPER cstore_fdw;
create foreign table users(
userid integer not null,
username char(8),
firstname varchar(30),
lastname varchar(30),
city varchar(30),
state char(2),
email varchar(100),
phone char(14),
likesports boolean,
liketheatre boolean,
likeconcerts boolean,
likejazz boolean,
likeclassical boolean,
likeopera boolean,
likerock boolean,
likevegas boolean,
likebroadway boolean,
likemusicals boolean)
SERVER cstore_server
OPTIONS(filename '/var/lib/postgresql/9.3/main/cstore/users.cstore',
compression 'pglz');
create foreign table venue(
venueid smallint not null,
venuename varchar(100),
venuecity varchar(30),
venuestate char(2),
venueseats integer)
SERVER cstore_server
OPTIONS(filename '/var/lib/postgresql/9.3/main/cstore/venue.cstore',
compression 'pglz');
create foreign table category(
catid smallint not null,
catgroup varchar(10),
catname varchar(10),
catdesc varchar(50))
SERVER cstore_server
OPTIONS(filename '/var/lib/postgresql/9.3/main/cstore/category.cstore',
compression 'pglz');
create foreign table date(
dateid smallint not null,
caldate date not null,
day character(3) not null,
week smallint not null,
month character(5) not null,
qtr character(5) not null,
year smallint not null,
holiday boolean default('N'))
SERVER cstore_server
OPTIONS(filename '/var/lib/postgresql/9.3/main/cstore/date.cstore',
compression 'pglz');
create foreign table event(
eventid integer not null,
venueid smallint not null,
catid smallint not null,
dateid smallint not null ,
eventname varchar(200),
starttime timestamp)
SERVER cstore_server
OPTIONS(filename '/var/lib/postgresql/9.3/main/cstore/event.cstore',
compression 'pglz');
create foreign table listing(
listid integer not null,
sellerid integer not null,
eventid integer not null,
dateid smallint not null ,
numtickets smallint not null,
priceperticket decimal(8,2),
totalprice decimal(8,2),
listtime timestamp)
SERVER cstore_server
OPTIONS(filename '/var/lib/postgresql/9.3/main/cstore/listing.cstore',
compression 'pglz');
create foreign table sales(
salesid integer not null,
listid integer not null,
sellerid integer not null,
buyerid integer not null,
eventid integer not null,
dateid smallint not null ,
qtysold smallint not null,
pricepaid decimal(8,2),
commission decimal(8,2),
saletime timestamp)
SERVER cstore_server
OPTIONS(filename '/var/lib/postgresql/9.3/main/cstore/sales.cstore',
compression 'pglz');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment