{"id":13877792,"url":"https://github.com/devrimgunduz/pagila","last_synced_at":"2025-07-16T13:32:48.694Z","repository":{"id":33224005,"uuid":"36867296","full_name":"devrimgunduz/pagila","owner":"devrimgunduz","description":"PostgreSQL Sample Database","archived":false,"fork":false,"pushed_at":"2024-01-22T14:15:57.000Z","size":41099,"stargazers_count":822,"open_issues_count":5,"forks_count":296,"subscribers_count":24,"default_branch":"master","last_synced_at":"2024-08-07T08:09:17.813Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PLpgSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devrimgunduz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-04T11:51:20.000Z","updated_at":"2024-08-06T16:03:13.000Z","dependencies_parsed_at":"2023-01-15T00:01:03.876Z","dependency_job_id":null,"html_url":"https://github.com/devrimgunduz/pagila","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devrimgunduz%2Fpagila","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devrimgunduz%2Fpagila/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devrimgunduz%2Fpagila/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devrimgunduz%2Fpagila/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devrimgunduz","download_url":"https://codeload.github.com/devrimgunduz/pagila/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226134226,"owners_count":17578778,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T08:01:24.275Z","updated_at":"2025-07-16T13:32:48.686Z","avatar_url":"https://github.com/devrimgunduz.png","language":"PLpgSQL","funding_links":[],"categories":["PLpgSQL","Compiled list","List"],"sub_categories":["plv8:"],"readme":"# Pagila\n\nPagila started as a port of the [Sakila](https://dev.mysql.com/doc/sakila/en/) example database available for MySQL, which was\noriginally developed by Mike Hillyer of the MySQL AB documentation team. It\nis intended to provide a standard schema that can be used for examples in\nbooks, tutorials, articles, samples, etc.\n\nPagila has been tested against PostgreSQL 12 and above.\n\nAll the tables, data, views, and functions have been ported; some of the\nchanges made were:\n\n- Changed char(1) true/false fields to true boolean fields\n- The last_update columns were set with triggers to update them\n- Added foreign keys\n- Removed 'DEFAULT 0' on foreign keys since it's pointless with real FK's\n- Used PostgreSQL built-in fulltext searching for fulltext index.\n  Removed the need for the film_text table.\n- The rewards_report function was ported to a simple SRF\n- Added JSONB data\n\nThe pagila database is made available under PostgreSQL license.\n\n## EXAMPLE QUERY\n\nFind late rentals:\n\n```sql\nSELECT\n\tCONCAT(customer.last_name, ', ', customer.first_name) AS customer,\n\taddress.phone,\n\tfilm.title\nFROM\n\trental\n\tINNER JOIN customer ON rental.customer_id = customer.customer_id\n\tINNER JOIN address ON customer.address_id = address.address_id\n\tINNER JOIN inventory ON rental.inventory_id = inventory.inventory_id\n\tINNER JOIN film ON inventory.film_id = film.film_id\nWHERE\n\trental.return_date IS NULL\n\tAND rental_date \u003c CURRENT_DATE\nORDER BY\n\ttitle\nLIMIT 5;\n```\n\n## FULLTEXT SEARCH\n\nFulltext functionality is built in PostgreSQL, so parts of the schema exist\nin the main schema file.\n\nExample usage:\n\nSELECT * FROM film WHERE fulltext @@ to_tsquery('fate\u0026india');\n\npgAdmin is included in the docker-compose.\n\nNavigate to the URL : http://localhost:5050/\nDefault Username: admin@admin.com\nDefault Password: root\n\n## PARTITIONED TABLES\n\nThe payment table is designed as a partitioned table with a 7 month timespan\nfor the date ranges.\n\n## INSTALL NOTE\n\nThe pagila-data.sql file and the pagila-insert-data.sql both contain the same\ndata, the former using COPY commands, the latter using INSERT commands, so you\nonly need to install one of them. Both formats are provided for those who have\ntrouble using one version or another, and for instructors who want to point out\nthe longer data loading time with the latter. You can load them via psql, pgAdmin, etc.\n\nSince JSONB data is quite large to store on Github, the backup is not a plain SQL\nfile. You can still use psql/pgAdmin, etc. to load `pagila-schema-jsonb.backup`, however\nplease use pg_restore to load jsonb data files:\n\n```\npg_restore /usr/share/pagila/pagila-data-yum-jsonb.backup -U postgres -d pagila\npg_restore /usr/share/pagila/pagila-data-apt-jsonb.backup -U postgres -d pagila\n```\n\n## VERSION HISTORY\n\nVersion 3.0.0\n\n- Add JSONB sample data (based on the packages at apt.postgresql.org and yum.postgresql.org)\n- Add docker compose support ( contributed by https://github.com/theothermattm ) https://github.com/devrimgunduz/pagila/pull/16\n- Add steps to create pagila database on docker by @dedeco in https://github.com/devrimgunduz/pagila/pull/13\n- Add missing user argument by @zOxta in https://github.com/devrimgunduz/pagila/pull/14\n- Update dates to 2022\n- Fix various issues reported in Github\n\nVersion 2.1.0\n\n- Replace varchar(n) with text (David Fetter)\n- Match foreign key and primary key data type in some tables (Ganeshan Venkataraman)\n- Change CREATE TABLE statement for customer table to use\n  DEFAULT nextval('customer_customer_id_seq'::regclass) for customer_id\n  field instead of SERIAL (Adrian Klaver).\n\nVersion 2.0\n\n- Update schema for newer PostgreSQL versions\n- Remove RULE for partitioning, add trigger support.\n- Update years in sample data.\n- Remove ARTICLES section from README, all links are dead.\n\nVersion 0.10.1\n\n- Add pagila-data-insert.sql file, added articles section\n\nVersion 0.10\n\n- Support for built-in fulltext. Add enum example\n\nVersion 0.9\n\n- Add table partitioning example\n\nVersion 0.8\n\n- First release of pagila\n\n## CREATE DATABASE ON [DOCKER](https://docs.docker.com/)\n\n1. On terminal pull the latest postgres image:\n\n```\n docker pull postgres\n```\n\n2. Run image:\n\n```\n docker run --name postgres -e POSTGRES_PASSWORD=secret -d postgres\n```\n\n3. Run postgres and create the database:\n\n```\ndocker exec -it postgres psql -U postgres\n```\n\n```\npsql (13.1 (Debian 13.1-1.pgdg100+1))\nType \"help\" for help.\n\npostgres=# CREATE DATABASE pagila;\npostgres-# CREATE DATABASE\npostgres=\\q\n```\n\n4. Create all schema objetcs (tables, etc) replace `\u003clocal-repo\u003e` by your local directory :\n\n```\ncat \u003clocal-repo\u003e/pagila-schema.sql | docker exec -i postgres psql -U postgres -d pagila\n```\n\n5. Insert all data:\n\n```\ncat \u003clocal-repo\u003e/pagila-data.sql | docker exec -i postgres psql -U postgres -d pagila\n```\n\n6. Done! Just use:\n\n```\ndocker exec -it postgres psql -U postgres\n```\n\n````\npostgres\npsql (13.1 (Debian 13.1-1.pgdg100+1))\nType \"help\" for help.\n\npostgres=# \\c pagila\nYou are now connected to database \"pagila\" as user \"postgres\".\npagila=# \\dt\n                    List of relations\n Schema |       Name       |       Type        |  Owner\n--------+------------------+-------------------+----------\n public | actor            | table             | postgres\n public | address          | table             | postgres\n public | category         | table             | postgres\n public | city             | table             | postgres\n public | country          | table             | postgres\n public | customer         | table             | postgres\n public | film             | table             | postgres\n public | film_actor       | table             | postgres\n public | film_category    | table             | postgres\n public | inventory        | table             | postgres\n public | language         | table             | postgres\n public | payment          | partitioned table | postgres\n public | payment_p2022_01 | table             | postgres\n public | payment_p2022_02 | table             | postgres\n public | payment_p2022_03 | table             | postgres\n public | payment_p2022_04 | table             | postgres\n public | payment_p2022_05 | table             | postgres\n public | payment_p2022_06 | table             | postgres\n public | payment_p2022_07 | table             | postgres\n public | rental           | table             | postgres\n public | staff            | table             | postgres\n public | store            | table             | postgres\n(21 rows)\n\npagila=#\n```\n````\n\n## CREATE DATABASE ON [DOCKER-COMPOSE](https://docs.docker.com/compose/)\n\n1. Run:\n\n```\ndocker-compose up\n```\n\n2. Done! Just use:\n\n```\ndocker exec -it pagila psql -U postgres\n```\n\n```\n\npostgres\npsql (13.1 (Debian 13.1-1.pgdg100+1))\nType \"help\" for help.\n\npostgres=# \\c pagila\nYou are now connected to database \"pagila\" as user \"postgres\".\npagila=# \\dt\n                    List of relations\n Schema |       Name       |       Type        |  Owner\n--------+------------------+-------------------+----------\n public | actor            | table             | postgres\n public | address          | table             | postgres\n public | category         | table             | postgres\n public | city             | table             | postgres\n public | country          | table             | postgres\n public | customer         | table             | postgres\n public | film             | table             | postgres\n public | film_actor       | table             | postgres\n public | film_category    | table             | postgres\n public | inventory        | table             | postgres\n public | language         | table             | postgres\n public | payment          | partitioned table | postgres\n public | payment_p2022_01 | table             | postgres\n public | payment_p2022_02 | table             | postgres\n public | payment_p2022_03 | table             | postgres\n public | payment_p2022_04 | table             | postgres\n public | payment_p2022_05 | table             | postgres\n public | payment_p2022_06 | table             | postgres\n public | payment_p2022_07 | table             | postgres\n public | rental           | table             | postgres\n public | staff            | table             | postgres\n public | store            | table             | postgres\n(21 rows)\n\npagila=#\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevrimgunduz%2Fpagila","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevrimgunduz%2Fpagila","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevrimgunduz%2Fpagila/lists"}