Dvdrental — [better]
Identify bottlenecks in queries by analyzing the query plan, such as distinguishing between Seq Scan (sequential scan) and Index Scan .
Explaining the in more detail. Let me know what you'd like to do next! Drop Procedure - PostgreSQL - GeeksforGeeks
-- Send daily late fee alerts (requires pg_cron extension) SELECT cron.schedule( 'late-fee-alerts', -- job name '0 9 * * *', -- every day at 9 AM $$ SELECT generate_late_return_alerts(); $$ );
This feature identifies overdue rentals, calculates late fees, and sends alerts to customers. dvdrental
Handles inventory management across different physical locations. 2. Setting Up the dvdrental Database
The database is more than just a sample dataset; it is a foundational educational tool for aspiring data analysts and a "digital relic" of the physical media era. Often used to demonstrate the capabilities of PostgreSQL , this schema models the business operations of a standard video store from the early 2000s. Structural Overview
The database consists of , which can be broadly categorized into static data (inventory and people) and dynamic data (transactions). Identify bottlenecks in queries by analyzing the query
This article provides a comprehensive guide to understanding, installing, and utilizing the dvdrental sample database to advance your SQL skills. What is the dvdrental Sample Database?
Contains numerous foreign keys, allowing for complex JOIN operations.
CREATE OR REPLACE VIEW overdue_rentals AS SELECT r.rental_id, c.customer_id, c.first_name, c.last_name, c.email, f.title AS film_title, r.rental_date, r.return_date, CURRENT_DATE - r.rental_date::DATE AS days_rented, f.rental_duration, CASE WHEN r.return_date IS NULL AND (CURRENT_DATE - r.rental_date::DATE) > f.rental_duration THEN (CURRENT_DATE - r.rental_date::DATE) - f.rental_duration ELSE 0 END AS days_overdue FROM rental r JOIN customer c ON r.customer_id = c.customer_id JOIN inventory i ON r.inventory_id = i.inventory_id JOIN film f ON i.film_id = f.film_id WHERE r.return_date IS NULL AND (CURRENT_DATE - r.rental_date::DATE) > f.rental_duration; Drop Procedure - PostgreSQL - GeeksforGeeks -- Send
Use the pg_restore utility in your terminal to import the data:
EXPLAIN ANALYZE SELECT title, release_year FROM film WHERE release_year > 2000; Use code with caution. Full-Text Search