Templates/Travel, property & events

Hotel bookings database schema

Hotels with room types and rooms, guest reservations and payments.

6 tables, 5 relationships

Opens as a new diagram you can change. Free.

Tables

hotels

  • iduuid not null
  • nametext not null
  • citytext not null
  • starsinteger
  • created_attimestamptz not null

room_types

  • iduuid not null
  • hotel_id> hotelsuuid not null
  • nametext not null
  • capacityinteger not null
  • nightly_ratenumeric(8,2) not null
  • created_attimestamptz not null

rooms

  • iduuid not null
  • room_type_id> room_typesuuid not null
  • numbertext not null
  • created_attimestamptz not null

guests

  • iduuid not null
  • full_nametext not null
  • emailtext not null
  • phonetext
  • created_attimestamptz not null

reservations

  • iduuid not null
  • guest_id> guestsuuid not null
  • room_id> roomsuuid not null
  • check_indate not null
  • check_outdate not null
  • statustext not null
  • created_attimestamptz not null

reservation_payments

  • iduuid not null
  • reservation_id> reservationsuuid not null
  • amountnumeric(10,2) not null
  • paid_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 "guests" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "full_name" TEXT NOT NULL,
  "email" TEXT NOT NULL UNIQUE,
  "phone" TEXT,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "hotels" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "name" TEXT NOT NULL,
  "city" TEXT NOT NULL,
  "stars" INTEGER,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "reservation_payments" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "reservation_id" UUID NOT NULL,
  "amount" NUMERIC(10,2) NOT NULL,
  "paid_at" TIMESTAMPTZ NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "reservations" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "guest_id" UUID NOT NULL,
  "room_id" UUID NOT NULL,
  "check_in" DATE NOT NULL,
  "check_out" DATE NOT NULL,
  "status" TEXT DEFAULT 'confirmed' NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "room_types" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "hotel_id" UUID NOT NULL,
  "name" TEXT NOT NULL,
  "capacity" INTEGER NOT NULL,
  "nightly_rate" NUMERIC(8,2) NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "rooms" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "room_type_id" UUID NOT NULL,
  "number" TEXT NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

ALTER TABLE "room_types" ADD CONSTRAINT "fk_room_types_hotel_id" FOREIGN KEY ("hotel_id") REFERENCES "hotels" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "rooms" ADD CONSTRAINT "fk_rooms_room_type_id" FOREIGN KEY ("room_type_id") REFERENCES "room_types" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "reservations" ADD CONSTRAINT "fk_reservations_guest_id" FOREIGN KEY ("guest_id") REFERENCES "guests" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE "reservations" ADD CONSTRAINT "fk_reservations_room_id" FOREIGN KEY ("room_id") REFERENCES "rooms" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

ALTER TABLE "reservation_payments" ADD CONSTRAINT "fk_reservation_payments_reservation_id" FOREIGN KEY ("reservation_id") REFERENCES "reservations" ("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.