Write a single SQL statement to create a new playlist called 'Background music'; and write another single SQL statement to associate the new playlist with the 10 longest duration tracks of jazz music from the Track table.
CREATE TABLE MediaType
(
MediaTypeID INTEGER PRIMARY KEY NOT NULL,
Name TEXT
);
CREATE TABLE Playlist
(
PlaylistID INTEGER PRIMARY KEY NOT NULL,
Name TEXT
);
CREATE TABLE PlaylistTrack
(
PlaylistID INTEGER NOT NULL,
TrackID INTEGER NOT NULL,
PRIMARY KEY (PlaylistID, TrackID),
FOREIGN KEY (PlaylistID) REFERENCES Playlist (PlaylistID)
ON DELETE NO ACTION ON UPDATE NO
ACTION,
FOREIGN KEY (TrackID) REFERENCES Track (TrackID)
ON DELETE NO ACTION ON UPDATE NO
ACTION
);
CREATE TABLE Track
(
TrackID INTEGER PRIMARY KEY NOT NULL,
Name TEXT NOT NULL,
AlbumID INTEGER,
MediaTypeID INTEGER NOT NULL,
GenreID INTEGER,
Composer TEXT,
Millisecond INTEGER NOT NULL,
Byte INTEGER,
UnitPrice REAL NOT NULL,
FOREIGN KEY (AlbumID) REFERENCES Album (AlbumID)
ON DELETE NO ACTION ON UPDATE NO
ACTION,
FOREIGN KEY (GenreID) REFERENCES Genre (GenreID)
ON DELETE NO ACTION ON UPDATE NO
ACTION,
FOREIGN KEY (MediaTypeID) REFERENCES MediaType (MediaTypeID)
ON DELETE NO ACTION ON UPDATE NO
ACTION
);
CREATE TABLE Genre
(
GenreID INTEGER PRIMARY KEY NOT NULL,
Name TEXT
INSERT INTO playlist values (1,'Background Music')
-- here we are inserting values into playlsit table

INSERT INTO playlisttrack (PlaylistID,TrackID) SELECT playlist.PlaylistID,track.TrackID FROM playlist,track,genre where genre.Name = 'Jazz music' and genre.GenreID = track.GenreID order by track.Millisecond DESC limit 10
-- here we are taking select statement for inserting the values
into playlisttrack
--Playlisttrack playlistID is selcted from playlist table and
trackID is selected from track table
--in select statement we are sorting the tracks with Millisecond
descending so that the top 10 are selected by limit 10
--below i have inserted manually for sample testing
--genre table values:

--trackid table values:

--executing the insert into query

--now the values are inserted into playlist track table

**************************************************************************
Please give an upvote,as it matters to me a lot :)
********************************************************************************
Write a single SQL statement to create a new playlist called 'Background music'; and write another...
SQL Create a database called MyMusician Create three tables, one named “User”, one named “Song”, and one named “Playlist”. The “User” table should have a column for userID (integer, autoincrement, not null, primary key), username, and password. It should also have one column for a foreign key we will assign later called “playlistID” (integer). The “Playlist” table should have a “playlistID” (integer, autoincrement, not null, primary key), and a column for a foreign key we will assign later called “songID”...
Based on the CREATE TABLE
statements, make an ER model of the database. Give suitable names
to the relationships. (Remember cardinality and participation
constraints.) The diagram must use either the notation used in the
textbook (and the lectures) or the crow’s foot notation. To save
you some time: There are a few tables that include the following
address fields: Address, City, State, Country and PostalCode (and
the same fields with the prefix Billing-). You are allowed to
replace these attributes...
Utilize the JigSaw SQL file below to create a Star Schema diagram. Remember, to create a Star Schema from a normalized data model, you will need to denormalize the data model into fact and dimension tables. The diagram should contain all of the facts and dimension tables necessary to integrate the JigSaw operational database into a data warehouse. Write a brief paper describing the challenges you experienced in completing this assignment. -- CREATE DATABASE js; CREATE TABLE buy_methods ( buy_code...
a. Write five select statements to select data from each table individually. b. Write one select statement with joins to list the playlist name, playlist track number, song name, artist name, album name, sorted by playlist name and playlist track number. DROP TABLE Artists CASCADE CONSTRAINTS; DROP TABLE Albums CASCADE CONSTRAINTS; DROP TABLE Songs CASCADE CONSTRAINTS; DROP TABLE Playlists CASCADE CONSTRAINTS; DROP TABLE PlaylistSongs CASCADE CONSTRAINTS; CREATE TABLE Artists ( ArtistID int NOT NULL, ArtistName varchar(255), PRIMARY KEY (ArtistID) );...
Hi i need Help. i use MYSQL command line.
THE QUESTION ARE BELOW
please check the answer before you submit because sometimes
query gives error thank you
For Full database of SQL you can DOWNLOAD from this link:
https://drive.google.com/file/d/1xh1TcBfMtvKoxvJr7Csgnts68fF53Q1t/view?usp=sharing
-------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
What are the total sales for each year. Note that you will need
to use the YEAR function. Order by year with the newest year
first.
-------------------------------------------------------
How many employees have no customers?
------------------------------------------------------------------
List the total sales for...
Write SQL to create a table called City in your account. The schema of the table is listed below. You must define the data types and not null constraint (if needed) of every column and all the primary key and foreign key constraints for the table. No screenshot needed for this question. City (Name, Country, Population, Capital). Name: the name of the city. Text string with maximum 50 characters. Must not be null. Country: the name of the country where...
Write an SQL query against the Chinook Database v1.4. Each query
must run successfully using DB Browser for SQLite. Create the exact
query below. Must use sub query. I saw that a
similar solution for this question used IF and CONCAT functions
which do not work and return errors. If it is possible to use the
CASE function in place of IF that would be greatly appreciated.
Also I really hate to ask but if it could be organized neatly...
Use an INSERT INTO statement with a subquery containing a SQL string function to create user names for the volunteers based on their legal names and insert them into the table. +----------------------+ | Tables_in_volunteers | +----------------------+ | address | | email | | funds | | hours | | person | | phone | | users | +----------------------+ users legal names are in the address table user table is : CREATE TABLE USERS(volunteer_id INT NOT NULL, username VARCHAR(50), PRIMARY KEY...
solve: Write a single SQL statement to create a new table named Login with five columns: User(Text), Password (Text), Update (Date), Status (Text) and CustomerID (Integer) Set the default value of LastUpdate to the current date and time ( time) Define a check on Status to make sure the value could either be 'active' or 'inactive' and Write a single SQL statement to list all the tracks that have the exact word 'hello' (including both upper and lower cases) as...
SQL CHECK CONSTRAINT AND TEST CASE... SQL Query Here are the tables: CREATE TABLE Movies( movieID INT, name VARCHAR(30) NOT NULL, year INT, rating CHAR(1), length INT, totalEarned NUMERIC(7,2), PRIMARY KEY(movieID), UNIQUE(name, year) ); CREATE TABLE Showings( theaterID INT, showingDate DATE, startTime TIME, movieID INT, priceCode CHAR(1), PRIMARY KEY(theaterID, showingDate, startTime), FOREIGN KEY(theaterID) REFERENCES Theaters, FOREIGN KEY(movieID) REFERENCES Movies ); CREATE TABLE Tickets( theaterID INT, seatNum INT, showingDate DATE, startTime TIME, customerID INT, ticketPrice NUMERIC(4,2), PRIMARY KEY(theaterID, seatNum, showingDate, startTime)...