Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. Consider the following schema for an online streaming service, where users are allowed to play (stream) songs performed by different artists. Primary and foreign

4. Consider the following schema for an online streaming service, where users are allowed to play (stream) songs performed by different artists. Primary and foreign key constraints are also listed for the schema of each table.

User (ID, Password, Name, Location) Primary key = ID Artist (ID, Name, Birthyear) Primary key = ID Song (ID, Title, Album, ArtistID) Primary key = ID Song(ArtistID) references Artist(ID) Play (ID, UserID, SongID, Timestamp) Primary key = ID Play(UserID) references User(ID) Play(SongID) references Song(ID) 

Express each of the following query in SQL.

(a) Find the unique IDs of users who have played songs performed by the artist named Michael Jackson.

Solution:

(b) Find the unique IDs of users who have played more than one song performed by the artist named Michael Jackson. In other words, your query result must include only those users who have played at least 2 different songs performed by Michael Jackson.

Solution:

(c) Find the title of the most popular song, i.e., the song that received the highest play count (i.e., number of times it was played), and its corresponding play count. Note that a user can play the same song more than once (so the play count should sum up the total number of times each user has played a given song).

Solution:

(d) Find the titles of songs that have never been streamed (played) by any user.

Solution:

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

From Herds To Insights Harnessing Data Analytics For Sustainable Livestock Farming

Authors: Prof Suresh Neethirajan

1st Edition

B0CFD6K6KK, 979-8857075487

More Books

Students also viewed these Databases questions