Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help with SQL questions using the following schema List store id, film title, and a count of how many times each film was rented at

Help with SQL questions using the following schema

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.

actor actor_id: SMALLINT NOT NULL [PK] first_name: VARCHAR(45) NOT NULL last_name: VARCHAR(45) NOT NULL last_update: TIMESTAMP NOT NULL language language_id: TINYINT NOT NULL [PK name: CHAR(20) NOT NULL last update: TIMESTAMP NOT NULL category category_id: TINYINT NOT NULL [PK name: VARCHAR(25) NOT NULL last update: TIMESTAMP NOT NULL * film_category film_id: SMALLINT NOT NULL PFK category_id: TINYINT NOT NULL [ PFK last_update: TIMESTAMP NOT NULL country country_id: SMALLINT NOT NULL (PK country: VARCHAR(50) NOT NULL last update: TIMESTAMP NOT NULL film actor actor_id: SMALLINT NOT NULL [ PFK film id SMALLINT NOT NULL [PFK ] last_update: TIMESTAMP NOT NULL film text film_id: SMALLINT NOT NULL I PEK title VARCHAR(64) NOT NULL description: LONGVARCHAR(255) city city_id: SMALLINT NOT NULL [PK] city: VARCHAR(50) NOT NULL country_id: SMALLINT NOT NULL FK last update: TIMESTAMP NOT NULL film film_id: SMALLINT NOT NULL [PK] title: VARCHAR(64) NOT NULL description: LONGVARCHAR(255) release_year: DATE language_id: TINYINT NOT NULL (FK) original_language_id: TINYINT NOT NULL [FK rental_duration: TINYINT NOT NULL rental_rate: DECIMAL(4,2) NOT NULL length. SMALLINT replacement cost: DECIMAL(5,2) NOT NULL rating: CHAR(5) special_features: CHAR(54) last_update: TIMESTAMP NOT NULL address address id: SMALLINT NOT NULL [PK] Haddress: VARCHAR(50) NOT NULL address 2: VARCHAR(50) district: VARCHAR(20) NOT NULL city_id: SMALLINT NOT NULL [FK] postal_code: VARCHAR(10) phone: VARCHAR(20) NOT NULL last_update: TIMESTAMP NOT NULL store store_id: TINYINT NOT NULL [PK 1 + manager staff_id: TINYINT NOT NULL [FK ] address_id: SMALLINT NOT NULL [FK1 #last_update: TIMESTAMP NOT NULL > inventory inventory_id: INTEGER NOT NULL [PK film_id: SMALLINT NOT NULL [FK ] store_id: TINYINT NOT NULL [FK ] last update: TIMESTAMP NOT NULL Ich staff staff_id: TINYINT NOT NULL [PK] first name: VARCHAR(45) NOT NULL last name: VARCHAR(45) NOT NULL address_id: SMALLINT NOT NULL [FK picture: BLOB(255) email: VARCHAR(50) store_id: TINYINT NOT NULL [ FK ] active: BIT NOT NULL username: VARCHAR(16) NOT NULL password: VARCHAR(40) Last update: TIMESTAMP NOT NULL 1 rental rental_id: INTEGER NOT NULL [PK] rental_date: TIMESTAMP NOT NULL inventory_id: INTEGER NOT NULL [FK ] customer_id: SMALLINT NOT NULL [FK1 return_date: TIMESTAMP staff_id. TINYINT NOT NULL [FK 1 last update: TIMESTAMP NOT NULL payment payment_id: SMALLINT NOT NULL [PK] customer_id: SMALLINT NOT NULL [FK) staff_id: TINYINT NOT NULL [FK ) rental_id: INTEGER NOT NULL [FK ] amount: DECIMAL(5,2) NOT NULL XO payment_date: TIMESTAMP NOT NULL Klast update: TIMESTAMP NOT NULL customer customer_id: SMALLINT NOT NULL [PK store_id: TINYINT NOT NULL (FK) first_name: VARCHAR(45) NOT NULL last_name: VARCHAR(45) NOT NULL email: VARCHAR(50) address_id: SMALLINT NOT NULL [FK1 active: BIT NOT NULL create_date: TIMESTAMP NOT NULL last_update: TIMESTAMP NOT NULL

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

Step: 3

blur-text-image

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

Managing Your Information How To Design And Create A Textual Database On Your Microcomputer

Authors: Tenopir, Carol, Lundeen, Gerald

1st Edition

1555700233, 9781555700232

More Books

Students also viewed these Databases questions

Question

7. Where Do We Begin?

Answered: 1 week ago

Question

a. What is the purpose of the team?

Answered: 1 week ago