CGB

Tables (8)

Customer

  • customer_id — SERIAL — Primary key
  • phone — VARCHAR(20)

Employee

  • employee_id — SERIAL — Primary key
  • name — VARCHAR(100)
  • phone — VARCHAR(20)
  • screen_id — SERIAL — Foreign key → Screen.screen_id
  • theater_id — SERIAL — Foreign key → Screen.theater_id

Movie

  • movie_id — SERIAL — Primary key
  • title — VARCHAR(255)
  • start_date — DATE
  • end_date — DATE

Screen

  • screen_id — SERIAL — Primary key
  • theater_id — SERIAL — Foreign key → Theater.theater_id
  • name — VARCHAR(50)
  • employee_id — INT

ScreenPeriod

  • screen_period_id — SERIAL — Primary key
  • screen_id — SERIAL — Foreign key → Screen.screen_id
  • theater_id — SERIAL — Foreign key → Screen.theater_id
  • start_time — TIMESTAMP
  • end_time — TIMESTAMP
  • movie_id (movie_id2) — SERIAL — Foreign key → Movie.movie_id

Seat

  • seat_id — SERIAL — Primary key
  • screen_period_id — SERIAL — Foreign key → ScreenPeriod.screen_period_id
  • screen_id — SERIAL — Foreign key → ScreenPeriod.screen_id
  • theater_id — SERIAL — Foreign key → ScreenPeriod.theater_id
  • row — CHAR(1)
  • number — INT
  • location — VARCHAR(50)
  • type — VARCHAR(50)
  • price — DECIMAL(10,2)
  • UNIQUE(screen_id, — row,

Theater

  • theater_id — SERIAL — Primary key
  • name — VARCHAR(100)
  • location — TEXT

Ticket

  • ticket_id — SERIAL — Primary key
  • customer_id — SERIAL — Foreign key → Customer.customer_id
  • purchased_at — TIMESTAMP
  • movie_id — SERIAL — Foreign key → Movie.movie_id
  • seat_id — SERIAL — Foreign key → Seat.seat_id
  • screen_period_id — SERIAL — Foreign key → Seat.screen_period_id
  • screen_id — SERIAL — Foreign key → Seat.screen_id
  • theater_id — SERIAL — Foreign key → Seat.theater_id