Stock

Tables (6)

accounts

  • id (Key) — BIGINT — Primary key — NOT NULL
  • account_number — VARCHAR(20) — NOT NULL
  • balance — DECIMAL(19, 4) — NOT NULL
  • created_at — DATETIME — NOT NULL
  • updated_at — DATETIME
  • user_id — BIGINT — Foreign key → users.id — NOT NULL

holdings

  • id — BIGINT — Primary key
  • quantity — INT — NOT NULL
  • average_buy_price — DECIMAL(19, 4) — NOT NULL
  • last_updated_at — DATETIME — NOT NULL
  • account_id — BIGINT — Foreign key → accounts.id — NOT NULL
  • stock_id — BIGINT — Foreign key → stocks.id

orders

  • id — BIGINT — Primary key
  • order_type — ENUM('BUY', 'SELL') — NOT NULL
  • order_price — DECIMAL(19, 4)
  • order_quantity — INT — NOT NULL
  • order_status — ENUM('PENDING', 'PARTIAL_FILLED', 'FILLED', 'CANCELED') — NOT NULL
  • ordered_at — DATETIME — NOT NULL
  • filled_quantity — INT
  • filled_price — DECIMAL(19, 4)
  • account_id — BIGINT — Foreign key → accounts.id — NOT NULL
  • stock_id — BIGINT — Foreign key → stocks.id

stocks

  • id — BIGINT — Primary key
  • symbol — VARCHAR(10) — NOT NULL
  • company_name — VARCHAR(100) — NOT NULL
  • current_price — DECIMAL(19, 4) — NOT NULL
  • daily_change — DECIMAL(19, 4)
  • daily_change_rate — DECIMAL(5, 2)
  • updated_at — DATETIME — NOT NULL

transactions

  • id — BIGINT — Primary key
  • transaction_type — ENUM('DEPOSIT', 'WITHDRAW', 'BUY_FILLED', 'SELL_FILLED', 'FEE') — NOT NULL
  • amount — DECIMAL(19, 4) — NOT NULL
  • transaction_time — DATETIME — NOT NULL
  • description — VARCHAR(255)
  • account_id — BIGINT — Foreign key → accounts.id — NOT NULL
  • order_id — BIGINT — Foreign key → orders.id

users

  • id — BIGINT — Primary key — NOT NULL
  • username — VARCHAR(50) — NOT NULL
  • password — VARCHAR(255) — NOT NULL
  • email — VARCHAR(100) — NOT NULL
  • created_at — DATETIME — NOT NULL
  • updated_at — DATETIME