Question: here is my script: - - Step 1 : Create the database DROP DATABASE IF EXISTS DisneyPrincesses; CREATE DATABASE DisneyPrincesses; - - Step 2 :
here is my script:
Step : Create the database
DROP DATABASE IF EXISTS DisneyPrincesses;
CREATE DATABASE DisneyPrincesses;
Step : Use the created database
USE DisneyPrincesses;
Step : Create tables
CREATE TABLE Kingdom
KingdomID INT PRIMARY KEY,
KingdomName VARCHAR
;
CREATE TABLE Princesses
PrincessID INT PRIMARY KEY,
PrincessName VARCHAR
Age INT,
KingdomID INT,
FOREIGN KEY KingdomID REFERENCES KingdomKingdomID
;
CREATE TABLE Princes
PrinceID INT PRIMARY KEY,
PrinceName VARCHAR
PrincessID INT,
FOREIGN KEY PrincessID REFERENCES PrincessesPrincessID
;
CREATE TABLE Movies
MovieID INT PRIMARY KEY,
MovieName VARCHAR
PrincessID INT,
SongName VARCHAR
ReleaseDate DATE, New column added
FOREIGN KEY PrincessID REFERENCES PrincessesPrincessID
;
Step : Insert data
INSERT INTO Kingdom KingdomID KingdomName VALUES
'Arendelle'
'Atlantica'
'Agrabah'
'Maldonia'
'Corona';
INSERT INTO Princesses PrincessID PrincessName, Age, KingdomID VALUES
'Elsa',
'Anna',
'Ariel',
'Jasmine',
'Tiana',
'Rapunzel', ;
INSERT INTO Princes PrinceID PrinceName, PrincessID VALUES
'Prince Hans',
'Kristoff',
'Prince Eric',
'Aladdin',
'Naveen',
Flynn Rider', ;
INSERT INTO Movies MovieID MovieName, PrincessID, SongName, ReleaseDate VALUES
'Frozen', 'Let It Go
'Frozen', 'For the First Time in Forever',
'The Little Mermaid', 'Part of Your World',
'Aladdin', 'A Whole New World',
'The Princess and the Frog', 'Almost There',
'Tangled', 'I See the Light', ;
Step : Write queries
Query : Retrieve Princess names and their corresponding Kingdom names
SELECT Princesses.PrincessName, Kingdom.KingdomName
FROM Princesses
JOIN Kingdom ON Princesses.KingdomID Kingdom.KingdomID;
Query : Retrieve Princes' names and the corresponding Princesses they belong to
SELECT Princes.PrinceName, Princesses.PrincessName
FROM Princes
JOIN Princesses ON Princes.PrincessID Princesses.PrincessID;
Query : Retrieve Princess names and the main songs of the movies they are featured in
SELECT Princesses.PrincessName, Movies.MovieName, Movies.SongName
FROM Princesses
JOIN Movies ON Princesses.PrincessID Movies.PrincessID;
Query : Count the number of movies each Princess is featured in
SELECT Princesses.PrincessName, COUNT AS NumMovies
FROM Princesses
JOIN Movies ON Princesses.PrincessID Movies.PrincessID
GROUP BY Princesses.PrincessName;
Additional Queries
Query : Retrieve movies released after a certain date
SELECT MovieName, SongName
FROM Movies
WHERE ReleaseDate ;
Query : Calculate the average age of Princesses
SELECT AVGAge AS AverageAge
FROM Princesses;
Query : Retrieve Princess names and their corresponding Kingdom names
SELECT PPrincessName, KKingdomName
FROM Princesses P
JOIN Kingdom K ON PKingdomID KKingdomID;
Query : Count the number of movies each Princess is featured in for Princesses featured in at least two movies
SELECT PPrincessName, COUNT AS NumMovies
FROM Princesses P
JOIN Movies M ON PPrincessID MPrincessID
GROUP BY PPrincessName
HAVING COUNT;
PLEASE MODIFY MY SCRIPT BY THE DIRECTIONS BELOW
Update your final script from module by adding one more record to each table.
Add a command that updates an existing record
Add a command that deletes a record
Create a query that concatenates fields from multiple tables. Requires a join.
Create a new user called riley
riley must be able to read all of the tables in your project database.
riley must not be able to add, update or delete any records.
Create a script that uses one of your custom queries not select and run it as riley. Make sure rows appear.
Update the script to attempt insert, update or delete a record and run it as riley. Confirm that access is denied.
Create a new user called irene
irene must be able to create, read, update and delete records for all of the tables in your project database.
Rerun the script you made for riley but run it as irene.
Confirm that the queries and the modifications work
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
