Example schema · PostgreSQL · 16 tables · 19 relationships

Pagila ER diagram — Sakila for PostgreSQL

The PostgreSQL port of the DVD-rental classic: films, actors, inventory, rentals and payments, rendered from the official schema dump.

SQL input — CREATE TABLE · DDL · dumppostgres
postgresSample: · · · · ·
Diagram16 tables · 19 foreign keys
Pagila ER diagram — 16 tables, 19 relationshipsON DELETE RESTRICTON DELETE RESTRICTON DELETE RESTRICTON DELETE RESTRICTON DELETE RESTRICTON DELETE RESTRICTON DELETE RESTRICTON DELETE RESTRICTON DELETE CASCADEON DELETE RESTRICTON DELETE RESTRICTON DELETE RESTRICTON DELETE RESTRICTON DELETE RESTRICTON DELETE RESTRICTON DELETE RESTRICTON DELETE RESTRICTON DELETE RESTRICTpublic.customerTABLEcustomer_idNNintstore_idFKNNintfirst_nameNNtextlast_nameNNtextemailtextaddress_idFKNNintactiveboolNNbooleancreate_dateNNdate+ 3 more columnspublic.actorTABLEactor_idNNintfirst_nameNNtextlast_nameNNtextlast_upd…NNtimestam…public.categoryTABLEcategory_idNNintnameNNtextlast_updateNNtimestamptzpublic.filmTABLEfilm_idNNinteger DEFAULT nextval(titleNNtext NOT NULLdescriptiontextrelease_yearpubliclanguage_idFKNNinteger NOT NULLoriginal_language_idFKintegerrental_durationNNsmallint DEFAULT 3 NOT NULLrental_rateNNnumeric(4,2) DEFAULT 4+ 7 more columnspublic.film_actorTABLEactor_idFKNNintfilm_idFKNNintlast_updateNNtimestamptzpublic.film_categoryTABLEfilm_idFKNNintcategory_idFKNNintlast_updateNNtimestamptzpublic.film_embeddingTABLEfilm_idFKNNintembeddingNNpublic.vector(20)last_updateNNtimestamptzpublic.addressTABLEaddress_idNNintaddressNNtextaddress2textdistrictNNtextcity_idFKNNintpostal_codetextphoneNNtextlast_upda…NNtimestam…public.cityTABLEcity_idNNintcityNNtextcountry_idFKNNintlast_upd…NNtimestam…public.countryTABLEcountry_idNNintcountryNNtextlast_upda…NNtimestam…public.inventoryTABLEinventory_idNNintfilm_idFKNNintstore_idFKNNintlast_updateNNtimestamptzpublic.languageTABLElanguage_idNNintnameNNtextlast_updateNNtimestamptzpublic.paymentTABLEpayment_idPKNNintcustomer_idNNintstaff_idNNintrental_idNNintamountNNdecimal(5, 2)payment_d…PKNNtimesta…uuidNNuuidpublic.rentalTABLErental_idNNintrental_d…NNtimestam…inventory_idFKNNintcustomer_idFKNNintreturn_datetimestamptzstaff_idFKNNintlast_upd…NNtimestam…uuidNNuuidpublic.staffTABLEstaff_idNNintfirst_nameNNtextlast_nameNNtextaddress_idFKNNintemailtextstore_idFKNNintactiveNNbooleanusernameNNtext+ 3 more columnspublic.storeTABLEstore_idNNintmanager_staff_…NNi…address_idFKNNintlast_upd…NNtimestam…
About the schema

What you're looking at

Pagila is the PostgreSQL adaptation of the Sakila DVD-rental schema: films are stocked as inventory per store, customers rent them, payments record the money. The core 16 tables here carry the whole story — the film–actor and film–category junctions, the rental→inventory→store chain, and staff tied to stores through addresses. PostgreSQL specifics are on display too: sequences feeding serial keys, ON UPDATE CASCADE rules, and CHECK-style boolean defaults.

This is the 16-table core. The full 71-table schema adds monthly payment partitions (payment_p2022_01 and friends) — paste the full dump into the converter to see them all.

Nothing above is hand-drawn — the diagram is generated from the official schema file, the same SQL you would paste into the SQL to ER diagram converter.

Working in PostgreSQL? The PostgreSQL to ER diagram converter takes any PostgreSQL DDL — pg_dump output, hand-written DDL, or a single CREATE TABLE.

Credits

Where the schema comes from

  • Source: devrimgunduz/pagila
  • License: PostgreSQL Licence
  • The schema belongs to its original authors; the diagram above was generated by erd.yizuolab.com.
FAQ

Questions, answered

What is Pagila?

Pagila is the PostgreSQL adaptation of Sakila, the DVD-rental sample database. It keeps Sakila's domain — films, actors, stores, customers, rentals, payments — while speaking real PostgreSQL: sequences, ON UPDATE CASCADE rules, and partitioned tables.

Why does the diagram show 16 tables when the schema has 71?

The full dump splits payments into dozens of monthly partitions (payment_p2022_01 through payment_p2026_07), which renders as dozens of near-identical child tables. This page prefills the 16-table core so the first frame is readable. Paste the full schema into the converter to see everything — Pro renders up to 500 tables per diagram.

Is this the Sakila schema? Why not use Sakila itself?

It's the same domain, ported to PostgreSQL. Sakila's original is MySQL and licensed GPL, which isn't redistributable here; Pagila carries the permissive PostgreSQL Licence, so it can be shown in full.

What does ON UPDATE CASCADE mean on these lines?

Pagila's reference tables cascade updates as well as deletes — change a country's key and every city row follows. The relationship labels in the diagram carry the on-delete rule; a Mermaid export preserves them as text.

More examples

Other real schemas