Question
Write SQL queries for the database and questions below. Question 1. Find how many unique artists produced at least 1 classical songs. Question 2. For
Write SQL queries for the database and questions below.
Question 1. Find how many unique artists produced at least 1 classical songs.
Question 2. For each genre of songs that has songs(one or more) with a length of 60 minutes or more, print the genre and total length of those songs.
Question 3. For each user who has more than 3 followers since 1980, find their email, and zipcode.
Question 4. Views:
Congratulations! The CTO has formed a data science team to analyze the reaction of users for artists who produced songs, and she made you the head of the team. We expect to analyze reactors email, reactors zipcode, reactor id, reaction type, artist id, artist bio, songs ID, and its genre. As a team leader, you have been asked to create a SQL view so that the rest of the team can look at the data and draw a meaningful conclusion without having to deal with all of its underlying complexity.
This view should provide access to a combination of the following information:
Artist (id, bio)
Produce (id, cid)
Song (cid, genre)
User (id,email, zipcode)
React (id, cid, type)
a) Create the desired view(UserReactionToArtistView) by writing an appropriate CREATE VIEW statement.
b) Show the usefulness of your view by writing a SELECT query against the view that prints the id, bio of the artist(s) who have produced song(s) with highest number of like in the genre classical. And the artists bio includes Rerum.
Question 5. Alter Table
The CTO wishes to modify the original schema to accommodate a new feature. As the database already has valuable information that we need to retain, we just want to alter one of the existing tables to fulfill the CTOs Request. The new feature request is to delete images when the advertising company name is deleted. Recall that the current Images table definition is as follow:
CREATE TABLE Images(
company_name VARCHAR(20),
id VARCHAR(20),
images VARCHAR(20),
PRIMARY KEY (company_name,id, images),
FOREIGN Key (company_name,id) REFERENCES Ads(company_name,id) ON DELETE CASCADE
);
a) Write and execute the ALTER TABLE statement(s) needed to modify the Images table so that whenever the ads company is deleted, then all the images associated with the company (across all ads by said company) are also deleted. (You may assume that the name of the current foreign key in Images table is Images_ibfk_1):
b) Execute the following DELETE and SELECT statements to show the effect of your change(Put the result for both before and after). Write down the result returned by the SELECT statement.
Before:
SELECT * from Images where Images.company_name = King Group;
Duration --pid firstname lastname Playlist People interest User Artist title Type Content Free Premiumm exp date rating Song Video Ads image Playlist Create People User Artist Follower Follow Followee since Content Free Premium Watch User AND Artist OVERLAP Song Video User AND Artist COVER People Free AND Premium COVER User Ads
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started