Templates/Travel, property & events

Event ticketing database schema

Events at venues with ticket types, orders, issued tickets and door check-ins.

6 tables, 6 relationships

Opens as a new diagram you can change. Free.

Tables

venues

  • iduuid not null
  • nametext not null
  • addresstext not null
  • capacityinteger not null
  • created_attimestamptz not null

events

  • iduuid not null
  • venue_id> venuesuuid not null
  • titletext not null
  • starts_attimestamptz not null
  • on_sale_attimestamptz
  • created_attimestamptz not null

ticket_types

  • iduuid not null
  • event_id> eventsuuid not null
  • nametext not null
  • pricenumeric(8,2) not null
  • quantityinteger not null
  • created_attimestamptz not null

ticket_orders

  • iduuid not null
  • event_id> eventsuuid not null
  • buyer_emailtext not null
  • totalnumeric(10,2) not null
  • created_attimestamptz not null

tickets

  • iduuid not null
  • order_id> ticket_ordersuuid not null
  • ticket_type_id> ticket_typesuuid not null
  • codetext not null
  • created_attimestamptz not null

ticket_check_ins

  • iduuid not null
  • ticket_id> ticketsuuid not null
  • scanned_attimestamptz not null
  • created_attimestamptz not null

As PostgreSQL

The same diagram exports to MySQL, MariaDB, SQLite, SQL Server and Oracle, and to Prisma, Drizzle, SQLAlchemy and Convex models.

CREATE TABLE "events" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "venue_id" UUID NOT NULL,
  "title" TEXT NOT NULL,
  "starts_at" TIMESTAMPTZ NOT NULL,
  "on_sale_at" TIMESTAMPTZ,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "ticket_check_ins" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "ticket_id" UUID NOT NULL UNIQUE,
  "scanned_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "ticket_orders" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "event_id" UUID NOT NULL,
  "buyer_email" TEXT NOT NULL,
  "total" NUMERIC(10,2) NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "ticket_types" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "event_id" UUID NOT NULL,
  "name" TEXT NOT NULL,
  "price" NUMERIC(8,2) NOT NULL,
  "quantity" INTEGER NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "tickets" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "order_id" UUID NOT NULL,
  "ticket_type_id" UUID NOT NULL,
  "code" TEXT NOT NULL UNIQUE,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "venues" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "name" TEXT NOT NULL,
  "address" TEXT NOT NULL,
  "capacity" INTEGER NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

ALTER TABLE "events" ADD CONSTRAINT "fk_events_venue_id" FOREIGN KEY ("venue_id") REFERENCES "venues" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE "ticket_types" ADD CONSTRAINT "fk_ticket_types_event_id" FOREIGN KEY ("event_id") REFERENCES "events" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "ticket_orders" ADD CONSTRAINT "fk_ticket_orders_event_id" FOREIGN KEY ("event_id") REFERENCES "events" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE "tickets" ADD CONSTRAINT "fk_tickets_order_id" FOREIGN KEY ("order_id") REFERENCES "ticket_orders" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "tickets" ADD CONSTRAINT "fk_tickets_ticket_type_id" FOREIGN KEY ("ticket_type_id") REFERENCES "ticket_types" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE "ticket_check_ins" ADD CONSTRAINT "fk_ticket_check_ins_ticket_id" FOREIGN KEY ("ticket_id") REFERENCES "tickets" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

More Travel, property & events templates

Start with one diagram, free

One diagram with two branches, no card needed. Upgrade when your team needs more.