Templates/Work & productivity

Document e-signature database schema

Documents sent to signers, signature fields, signatures and an audit trail.

5 tables, 6 relationships

Opens as a new diagram you can change. Free.

Tables

documents

  • iduuid not null
  • titletext not null
  • file_urltext not null
  • statustext not null
  • completed_attimestamptz
  • created_attimestamptz not null

signers

  • iduuid not null
  • document_id> documentsuuid not null
  • nametext not null
  • emailtext not null
  • signing_orderinteger not null
  • created_attimestamptz not null

signature_fields

  • iduuid not null
  • document_id> documentsuuid not null
  • signer_id> signersuuid not null
  • pageinteger not null
  • xnumeric not null
  • ynumeric not null
  • created_attimestamptz not null

signatures

  • iduuid not null
  • field_id> signature_fieldsuuid not null
  • image_urltext not null
  • signed_attimestamptz not null
  • ip_addressinet
  • created_attimestamptz not null

document_events

  • iduuid not null
  • document_id> documentsuuid not null
  • signer_id> signersuuid
  • actiontext 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 "document_events" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "document_id" UUID NOT NULL,
  "signer_id" UUID,
  "action" TEXT NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "documents" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "title" TEXT NOT NULL,
  "file_url" TEXT NOT NULL,
  "status" TEXT DEFAULT 'draft' NOT NULL,
  "completed_at" TIMESTAMPTZ,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "signature_fields" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "document_id" UUID NOT NULL,
  "signer_id" UUID NOT NULL,
  "page" INTEGER NOT NULL,
  "x" NUMERIC NOT NULL,
  "y" NUMERIC NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "signatures" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "field_id" UUID NOT NULL UNIQUE,
  "image_url" TEXT NOT NULL,
  "signed_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  "ip_address" INET,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

CREATE TABLE "signers" (
  "id" UUID DEFAULT gen_random_uuid() NOT NULL,
  "document_id" UUID NOT NULL,
  "name" TEXT NOT NULL,
  "email" TEXT NOT NULL,
  "signing_order" INTEGER DEFAULT 1 NOT NULL,
  "created_at" TIMESTAMPTZ DEFAULT now() NOT NULL,
  PRIMARY KEY ("id")
);

ALTER TABLE "signers" ADD CONSTRAINT "fk_signers_document_id" FOREIGN KEY ("document_id") REFERENCES "documents" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "signature_fields" ADD CONSTRAINT "fk_signature_fields_document_id" FOREIGN KEY ("document_id") REFERENCES "documents" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "signature_fields" ADD CONSTRAINT "fk_signature_fields_signer_id" FOREIGN KEY ("signer_id") REFERENCES "signers" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "signatures" ADD CONSTRAINT "fk_signatures_field_id" FOREIGN KEY ("field_id") REFERENCES "signature_fields" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "document_events" ADD CONSTRAINT "fk_document_events_document_id" FOREIGN KEY ("document_id") REFERENCES "documents" ("id") ON DELETE CASCADE ON UPDATE NO ACTION;

ALTER TABLE "document_events" ADD CONSTRAINT "fk_document_events_signer_id" FOREIGN KEY ("signer_id") REFERENCES "signers" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

More Work & productivity templates

Start with one diagram, free

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