SQL

CREATE TABLE minute_data (
  ticker_id INTEGER NOT NULL REFERENCES tickers,
  timestamp INTEGER NOT NULL,
  bid_ask_open_price REAL NOT NULL,
  bid_ask_high_price REAL NOT NULL,
  bid_ask_low_price REAL NOT NULL,
  bid_ask_close_price REAL NOT NULL,
  trade_open_price REAL,
  trade_high_price REAL,
  trade_low_price REAL,
  trade_close_price REAL,
  volume REAL NOT NULL CHECK(volume>=0 AND volume<=1.7976931348623157e308),
  trade_count INTEGER NOT NULL CHECK(trade_count>=0),
  average_price REAL CHECK(average_price>0 AND average_price<=1.7976931348623157e308),
  CHECK((trade_open_price IS NULL)=(trade_high_price IS NULL) AND (trade_open_price IS NULL)=(trade_low_price IS NULL) AND (trade_open_price IS NULL)=(trade_close_price IS NULL) AND (trade_open_price IS NULL)=(average_price IS NULL)),
  CHECK(trade_open_price IS NOT NULL OR (volume=0 AND trade_count=0)),
  CHECK(bid_ask_low_price>0 AND bid_ask_high_price<=1.7976931348623157e308 AND bid_ask_open_price BETWEEN bid_ask_low_price AND bid_ask_high_price AND bid_ask_close_price BETWEEN bid_ask_low_price AND bid_ask_high_price),
  CHECK(bid_ask_open_price<=bid_ask_close_price),
  CHECK(trade_low_price>0 AND trade_high_price<=1.7976931348623157e308 AND trade_open_price BETWEEN trade_low_price AND trade_high_price AND trade_close_price BETWEEN trade_low_price AND trade_high_price),
  PRIMARY KEY(ticker_id,timestamp)
)

+ Add column

Columns

Column Data type Allow null Primary key Actions
ticker_id INTEGER ✓ Rename | Drop
timestamp INTEGER ✓ Rename | Drop
bid_ask_open_price REAL Rename | Drop
bid_ask_high_price REAL Rename | Drop
bid_ask_low_price REAL Rename | Drop
bid_ask_close_price REAL Rename | Drop
trade_open_price REAL ✓ Rename | Drop
trade_high_price REAL ✓ Rename | Drop
trade_low_price REAL ✓ Rename | Drop
trade_close_price REAL ✓ Rename | Drop
volume REAL Rename | Drop
trade_count INTEGER Rename | Drop
average_price REAL ✓ Rename | Drop

Foreign Keys

Column Destination
ticker_id tickers.None

+ Add index

Indexes

Name Columns Unique SQL Drop?

Triggers

Name SQL Drop?
vix_minutes_are_index_prices SQL
CREATE TRIGGER vix_minutes_are_index_prices BEFORE INSERT ON minute_data
 WHEN (SELECT symbol FROM tickers WHERE id=NEW.ticker_id)='VIX' BEGIN SELECT RAISE(ABORT,'VIX prices go to index_minute_data'); END
Drop