CREATE SEQUENCE public.trades_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; ALTER TABLE public.trades_id_seq OWNER TO jstrong; -- CREATE SEQUENCE public.exchangess_id_seq -- INCREMENT 1 -- MINVALUE 1 -- MAXVALUE 255 -- START 1 -- CACHE 1; -- ALTER TABLE public.exchangess_id_seq -- OWNER TO jstrong; -- -- CREATE SEQUENCE public.currencies_id_seq -- INCREMENT 1 -- MINVALUE 1 -- MAXVALUE 255 -- START 1 -- CACHE 1; -- ALTER TABLE public.currencies_id_seq -- OWNER TO jstrong; CREATE TABLE public.exchanges ( id smallint NOT NULL, symbol character varying(4) NOT NULL, CONSTRAINT exchanges_pkey PRIMARY KEY (id) ) WITH ( OIDS=FALSE ); CREATE TABLE public.currencies ( id smallint NOT NULL, symbol character varying(6) NOT NULL, CONSTRAINT currencies_pkey PRIMARY KEY (id) ) WITH ( OIDS=FALSE ); CREATE TABLE public.trades ( id integer NOT NULL DEFAULT nextval('trades_id_seq'::regclass), "time" timestamp with time zone NOT NULL, exch smallint NOT NULL, base smallint NOT NULL, quote smallint NOT NULL, amount double precision NOT NULL, price double precision NOT NULL, side smallint NULL, -- side has no fk ... bid=1, ask=2 server_time timestamp with time zone NULL, CONSTRAINT trades_pkey PRIMARY KEY (id), CONSTRAINT exch_fk FOREIGN KEY (exch) REFERENCES public.exchanges (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED, CONSTRAINT base_fk FOREIGN KEY (base) REFERENCES public.currencies (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED, CONSTRAINT quote_fk FOREIGN KEY (quote) REFERENCES public.currencies (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED ) WITH ( OIDS=FALSE ); ALTER TABLE public.trades OWNER TO jstrong; CREATE INDEX trades_time_abcdefg ON public.trades USING btree ("time"); CREATE INDEX trades_base_f6b2eeda ON public.trades USING btree (base); CREATE INDEX trades_quote_0d5895fc ON public.trades USING btree (quote); CREATE INDEX trades_exchange_5d5c6971 ON public.trades USING btree (exch); -- CREATE INDEX trades_side_23985593 -- ON public.trades -- USING btree -- (side); -- fill in exchanges/currencies insert into public.exchanges (id, symbol) values(1, 'plnx'); insert into public.exchanges (id, symbol) values(2, 'krkn'); insert into public.exchanges (id, symbol) values(3, 'gdax'); insert into public.exchanges (id, symbol) values(5, 'bits'); insert into public.exchanges (id, symbol) values(6, 'bmex'); insert into public.exchanges (id, symbol) values(7, 'btfx'); insert into public.exchanges (id, symbol) values(8, 'bnce'); insert into public.exchanges (id, symbol) values(9, 'okex'); insert into public.currencies (id, symbol) values(1, 'btc'); insert into public.currencies (id, symbol) values(2, 'eth'); insert into public.currencies (id, symbol) values(3, 'xmr'); insert into public.currencies (id, symbol) values(5, 'ltc'); insert into public.currencies (id, symbol) values(15, 'etc'); insert into public.currencies (id, symbol) values(4, 'usdt'); insert into public.currencies (id, symbol) values(100, 'usd');