Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Help with SQL questions using the following schema and data: https://drive.google.com/file/d/15e98eAoiZCMx4aMKagC13qhGlquLbCVe/view List store id, film title, and a count of how many times each film

Help with SQL questions using the following schema and data:

https://drive.google.com/file/d/15e98eAoiZCMx4aMKagC13qhGlquLbCVe/view

image text in transcribed

  1. List store id, film title, and a count of how many times each film was rented at each store in 2006. Sort by store id then film title.

    1. (Hint: Use the rental count column in the rental fact table. Join the rental fact to the dimension tables you need. Use the rental date key in the fact table to join the date dimension. DO NOT use the year() function on the rental date key in the fact or dimension tables. Instead, use columns in the date dimension table that already extract the year from the date.)

  2. How many rentals did each store achieve for each month in 2005? Sort by store and month.

    1. (Hint: As in question 1, do not extract the month or year from the rental date key. Use columns in the date dimension that already have the month and year extracted from the date.)

  3. List the top 5 films by total rental count in May 2005. Dont worry about ties just output 5 rows. Include the film title and the total number of times it was rented in that month. Order by the number of rentals in decreasing order.

dim customer dim_staff customer_key: INTEGER NOT NULL [PK] staff_key: INTEGER NOT NULL [PK] customer_last_update: TIMESTAMP NOT NULL staff_last_update: TIMESTAMP NOT NULL customer_id: INTEGER staff_id: INTEGER customer_first_name: VARCHAR(45) staff_first_name: VARCHAR(45) customer_last_name: VARCHAR(45) staff_last_name: VARCHAR(45) customer email: VARCHAR(50) staff_store_id: INTEGER customer_active: CHAR(3) staff_version_number: SMALLINT customer_created: DATE staff_valid_from: DATE customer_address: VARCHAR(64) staff valid through: DATE customer_district: VARCHAR(20) staff active: CHAR(3) customer postal code: VARCHAR(10) customer_phone_number: VARCHAR(20) customer_city. VARCHAR(50) customer_country: VARCHAR(50) customer version number: SMALLINT customer_valid_from: DATE customer_valid_through: DATE dim film film_key: INTEGER NOT NULL [PK] film_last_update: TIMESTAMP NOT NULL film_id: INTEGER NOT NULL film_title: VARCHAR(64) NOT NULL film_description: LONGVARCHAR(255) NOT NULL film release year: SMALLINT NOT NULL film_language: VARCHAR(20) NOT NULL film_original_language: VARCHAR(20) NOT NULL film_rental_duration: TINYINT film rental rate: DECIMAL(4,2) film duration: INTEGER film_replacement_cost: DECIMAL(5, 2) film_rating_code: CHAR(5) film_rating_text: VARCHAR(30) film_has trailers: CHAR(4) film_has commentaries: CHAR(4) film_has_deleted scenes: CHAR(4) film has behind the scenes: CHAR(4) film_in_category_action: CHAR(4) film in category animation: CHAR(4) film_in_category_children: CHAR(4) film_in_category_classics: CHAR(4) film_in_category_comedy: CHAR(4) film_in_category_documentary: CHAR(4) film_in_category_drama: CHAR(4) film_in_category_family: CHAR(4) film_in_category foreign: CHAR(4) film_in_category_games: CHAR(4) film_in_category_horror: CHAR(4) film_in_category_music: CHAR(4) film_in_category_new: CHAR(4) film_in_category scifi: CHAR(4) film_in_category_sports: CHAR(4) film_in_category_travel: CHAR(4) fact_rental rental_id: INTEGER NOT NULL (PK) rental_last_update: TIMESTAMP NOT NULL customer_key: INTEGER NOT NULL [FK] > staff_key: INTEGER NOT NULL [FK ] film_key: INTEGER NOT NULL [FK ] store_key: INTEGER NOT NULL (FK) rental_date_key: INTEGER NOT NULL [FK] return_date_key: INTEGER NOT NULL (FK) return_time_key: INTEGER NOT NULL (FKI count_returns: INTEGER NOT NULL count rentals: INTEGER NOT NULL rental_duration: INTEGER dim_date date_key: INTEGER NOT NULL [PK] date_value: DATE NOT NULL [AK] date_short: CHAR(12) NOT NULL date_medium: CHAR(16) NOT NULL date_long: CHAR(24) NOT NULL date_full: CHAR(32) NOT NULL day_in_year: SMALLINT NOT NULL day in month: TINYINT NOT NULL is first day in month: CHAR(10) NOT NULL is_last_day_in_month: CHAR(10) NOT NULL day abbreviation: CHAR(3) NOT NULL day_name: CHAR(12) NOT NULL week in year: TINYINT NOT NULL week_in_month: TINYINT NOT NULL is_first_day_in_week: CHAR(10) NOT NULL is_last_day_in_week: CHAR(10) NOT NULL month_number: TINYINT NOT NULL month abbreviation: CHAR(3) NOT NULL month_name: CHAR(12) NOT NULL year 2: CHAR(2) NOT NULL year 4: SMALLINT NOT NULL quarter_name: CHAR(2) NOT NULL quarter_number: TINYINT NOT NULL year_quarter: CHAR(7) NOT NULL Iyear month number: CHAR(7) NOT NULL year_month_abbreviation: CHAR(8) NOT NULL + dim_time time_key: INTEGER NOT NULL [PK time_value: TIME NOT NULL hours 24: TINYINT NOT NULL hours 12: TINYINT minutes: TINYINT seconds: TINYINT am pm: CHAR(3) dim film actor bridge film_key: INTEGER NOT NULL [ PFK) actor_weighting factor: DECIMAL(3, 2) NOT NULL dim_actor actor_id: INTEGER NOT NULL actor_key: INTEGER NOT NULL actor_last_update: TIMESTAMP NOT NULL actor_last_name: VARCHAR(45) NOT NULL actor_first_name: VARCHAR(45) NOT NULL dim_store store_key: INTEGER NOT NULL [PK] store_last_update: TIMESTAMP NOT NULL store_id: INTEGER store_address: VARCHAR(64) store district: VARCHAR(20) store_postal_code: VARCHAR(10) store phone number: VARCHAR(20) store_city: VARCHAR(50) store_country: VARCHAR(50) store_manager_staff_id: INTEGER store_manager_first name: VARCHAR(45) store manager last name: VARCHAR(45) store_version number: SMALLINT store_valid_from: DATE store_valid through: DATE

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 12c SQL

Authors: Joan Casteel

3rd edition

1305251032, 978-1305251038

More Books

Students explore these related Databases questions