Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DONT use chegg or chatgpt!!!! AND Dont copy from chegg cuz its wrongBuild a music recommendation service. You are given a template database with genres,

DONT use chegg or chatgpt!!!! AND Dont copy from chegg cuz its wrongBuild a music recommendation service.
You are given a template database with genres, regions, and bands. See attached file.
Tasks:
(9 points) Create db user called "api" with limited access of read only of initially given tables in the template, and
read/write/update permissions for all additional tables created for this project in the next steps.
(9 points) Create a "User" relation. User needs an ID, name, and home country.
(9 points) Create a "Favorites" relation. Favorites needs to reference user, and bands.
(9 points) Create a query to determine which sub_genres come from which regions.
(9 points) Create a query to determine what other bands, not currently in their favorites, are of the same sub_genres as those
which are.
(9 points) Create a query to determine what other bands, not currently in their favorites, are of the same genres as those which
are.
(9 points) Create a query which finds other users who have the same band in their favorites, and list their other favorite bands.
(9 points) Create a query to list other countries, excluding the user's home country, where they could travel to where they could
hear the same genres as the bands in their favorites.
(9 points) Add appropriate indexing to all tables and optimize all queries.
(9 points) Write an application in the back end language of your choice (BE languages only, no JS or Node) to access the
database using the created user in task # 1 with a function to run each query in tasks 4-8 with the user ID passed as a
parameter where needed.
(10 points) Create 3 functions, 1 each to insert users and insert & delete favorites. Insert at least 3 users and 4 favorites for each
user. You may use static data in the program to call these functions programmatically so long as SQL calls are still properly
parameterized. Note that a user may only add existing bands to favorites list and function should return an error if they add a
band not in the database. (You may add your favorite bands to the template provided, just remember to add matching
genre/sub_genre and region/country.)
Extra Credit: Create a User with "Paul Pena" and "The Hu" in their favorites list. Create 2 other Users, each with only one of those in
their favorites, (1 each) as well as both users with "Tengger Cavalry", "Sade", and "Battuvshin" in their favorites. Modify query #7 so
that Tengger Cavalry will be ranked first in the results order without using name in the order by. Hint: consider country, genre, and/or
sub_genre.
Submit both the updated SQL file (with answers for tasks 1 through 9) and program source code (with answers for tasks 10 & 11)
only. These should be concise files in proper format (.sql,.txt,.py,.cpp, etc) and not screenshots, executables, build files or anything
besides your source code - preferably a single file for each. Don't forget to comment your source, specifying which task # a query
answers, and to exercise proper db security.
CREATE DATABASE IF NOT EXISTS CSC315Final2023;
USE CSC315Final2023;
CREATE TABLE IF NOT EXISTS Genre (
gid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
gname CHAR(20) NOT NULL
);
INSERT INTO Genre (gname) VALUES ('Rock'),('Jazz'),('Country'),('Classical'),('Throat Singing');
CREATE TABLE IF NOT EXISTS Sub_Genre (
sgid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
gname CHAR(20) NOT NULL,
sgname CHAR(20) NOT NULL
);
INSERT INTO Sub_Genre (gname, sgname) VALUES ('Rock', 'Blues'),('Rock', 'Classic Rock'),('Rock', 'Power Metal'),('Rock', 'Thrash Metal'),('Rock', 'Death Metal'),('Rock', 'Folk Metal');
INSERT INTO Sub_Genre (gname, sgname) VALUES ('Jazz', 'Swing'),('Jazz', 'Smooth Jazz'),('Jazz', 'Bossa Nova'),('Jazz', 'Ragtime');
INSERT INTO Sub_Genre (gname, sgname) VALUES ('Country', 'Bluegrass'),('Country', 'Country and Western'),('Country', 'Jug Band');
INSERT INTO Sub_Genre (gname, sgname) VALUES ('Classical', 'Chamber Music'),('Classical', 'Opera'),('Classical', 'Orchestral');
INSERT INTO Sub_Genre (gname, sgname) VALUES ('Throat Singing', 'Khoomii'),('Throat Singing', 'Kargyraa'),('Throat Singing', 'Khamryn');
CREATE TABLE IF NOT EXISTS Region (
rid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
rname CHAR(20) NOT NULL
);
INSERT INTO Region (rname) VALUES ('Central Asia'),('Europe'),('North Americ'),('South America');
CREATE TABLE IF NOT EXISTS Country (
rid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
rname CHAR(20) NOT NULL,
cname CHAR(20) NOT NULL
);
INSERT INTO Country (rname, cname) VALUES ('Central Asia', 'Mongolia'),('Central Asia', 'Tibet'),('Central Asia', 'Tuva');
INSERT INTO Country (rname, cname) VALUES ('North Americ', 'Canada'),('North Americ', 'United States'),('North Americ', 'Mexico');
INSERT INTO Country (rname, cname) VALUES ('South Americ', 'Brazil');
INSERT INTO Country (rname, cname) VALUES ('Europe', 'Norway'),('Europe', 'Austria'),('Europe', 'England'),('Europe', 'Russia');
CREATE
image text in transcribed

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

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

What is the formula to calculate the mth Fibonacci number?

Answered: 1 week ago

Question

8. Explain the contact hypothesis.

Answered: 1 week ago

Question

7. Identify four antecedents that influence intercultural contact.

Answered: 1 week ago