Comprehensive guidelines for designing, implementing, optimizing, and documenting a database project. Ideal for final-year DBA students working with PostgreSQL or similar RDBMS.
The dvdrental database is a popular sample dataset for PostgreSQL, designed to mimic the business processes of a 2000s-era DVD rental store. It is essentially the “PostgreSQL version” of the Sakila database originally created for MySQL.
It consists of 15 tables that cover everything from inventory and film details to customer payments and store locations.
The database is structured into a few logical groups that handle different aspects of the business.
film: The central table containing titles, descriptions, release years, and rental rates.actor: Stores names of actors.film_actor: A bridge table for the many-to-many relationship between films and actors.category & film_category: Used to group movies (e.g., Action, Comedy, Horror).language: Stores the language of the film.inventory: Tracks individual physical copies of a movie. One film can have many inventory items across different stores.store: Contains store locations and connects to the manager (staff).staff: Information about the employees.customer: Stores user data, email, and whether they are active.rental: Records every time a customer takes a DVD. This table tracks rental_date and return_date.payment: Tracks the financial transactions tied to a rental.address, city, country: A normalized hierarchy for storing locations of both stores and customers.If you are practicing stored procedures or complex queries, this database is ideal because it provides:
film_actor) to simulate real-world data complexity.process_return example, the link between rental and payment is perfect for practicing ACID properties and transaction management.The database is usually provided as a .tar file. To get it into your local Postgres instance:
dvdrental.zip (standard on most tutorial sites).dvdrental.tar.CREATE DATABASE dvdrental;pg_restore -U postgres -d dvdrental C:\path\to\dvdrental.tar
(Note: Replace postgres with your username and provide the correct path to the file.)
\c dvdrental
\dt
You should see 15 tables, including actor, film, customer, and rental.
dvdrental database using the pgAdmin 4 GUIRestoring the dvdrental database using the pgAdmin 4 GUI is a straightforward process. Since the download is a .tar file, you will use the built-in Restore tool.
Follow these steps to get the database up and running:
Before you can restore the data, you need an empty “container” for it.
dvdrental.dvdrental database in the browser tree.A dialog box will appear. Fill in the following details:
dvdrental.tar, choose Custom or tar)..tar file.postgres (or your specific superuser).Click the Restore options tab at the top of the dialog. To ensure a clean import, toggle these to Yes:
dvdrental database and select Refresh.If pgAdmin says it cannot find the pg_restore utility, you need to tell it where your PostgreSQL “bin” folder is:
C:\Program Files\PostgreSQL\16\bin).