-- Process payment for customer ID 5 CALL process_late_fee_payment(5, 15.00);

Because it possesses a rich schema containing various data types, constraints, and relationships, it provides an ideal playground for practicing SQL queries ranging from simple selects to complex joins, window functions, and stored procedures.

CREATE OR REPLACE FUNCTION calculate_late_fee( p_rental_id INTEGER ) RETURNS NUMERIC AS $$ DECLARE v_days_overdue INTEGER; v_late_fee NUMERIC; v_film_title TEXT; BEGIN -- Calculate days overdue SELECT GREATEST(0, (CURRENT_DATE - r.rental_date::DATE) - f.rental_duration), f.title INTO v_days_overdue, v_film_title FROM rental r JOIN inventory i ON r.inventory_id = i.inventory_id JOIN film f ON i.film_id = f.film_id WHERE r.rental_id = p_rental_id AND r.return_date IS NULL; -- Late fee: $0.50 per day overdue v_late_fee := v_days_overdue * 0.50;

EXPLAIN ANALYZE SELECT title, release_year FROM film WHERE release_year > 2000; Use code with caution. Full-Text Search

You can create stored procedures to handle business logic, such as updating inventory or inserting new actor records. Conclusion

The is a de facto standard example database used for learning and teaching SQL, specifically within the PostgreSQL ecosystem. It serves as a robust model for a fictional DVD rental store business, designed to mimic the real-world operational data of a business that manages inventory, customers, and transactions.