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 1: Create the database
DROP DATABASE IF EXISTS DisneyPrincesses;
CREATE DATABASE DisneyPrincesses;
-- Step 2: Use the created database
USE DisneyPrincesses;
-- Step 3: Create tables
CREATE TABLE Kingdom (
KingdomID INT PRIMARY KEY,
KingdomName VARCHAR(100)
);
CREATE TABLE Princesses (
PrincessID INT PRIMARY KEY,
PrincessName VARCHAR(100),
Age INT,
KingdomID INT,
FOREIGN KEY (KingdomID) REFERENCES Kingdom(KingdomID)
);
CREATE TABLE Princes (
PrinceID INT PRIMARY KEY,
PrinceName VARCHAR(100),
PrincessID INT,
FOREIGN KEY (PrincessID) REFERENCES Princesses(PrincessID)
);
CREATE TABLE Movies (
MovieID INT PRIMARY KEY,
MovieName VARCHAR(100),
PrincessID INT,
SongName VARCHAR(100),
ReleaseDate DATE, -- New column added
FOREIGN KEY (PrincessID) REFERENCES Princesses(PrincessID)
);
-- Step 4: Insert data
INSERT INTO Kingdom (KingdomID, KingdomName) VALUES
(1, 'Arendelle'),
(2, 'Atlantica'),
(3, 'Agrabah'),
(4, 'Maldonia'),
(5, 'Corona');
INSERT INTO Princesses (PrincessID, PrincessName, Age, KingdomID) VALUES
(1, 'Elsa', 21,1),
(2, 'Anna', 18,1),
(3, 'Ariel', 16,2),
(4, 'Jasmine', 18,3),
(5, 'Tiana', 19,4),
(6, 'Rapunzel', 18,5);
INSERT INTO Princes (PrinceID, PrinceName, PrincessID) VALUES
(1, 'Prince Hans', 1),
(2, 'Kristoff', 1),
(3, 'Prince Eric', 3),
(4, 'Aladdin', 4),
(5, 'Naveen', 5),
(6,'Flynn Rider', 6);
INSERT INTO Movies (MovieID, MovieName, PrincessID, SongName, ReleaseDate) VALUES
(1, 'Frozen', 1, 'Let It Go','2022-11-23'),
(2, 'Frozen', 2, 'For the First Time in Forever', '2022-11-23'),
(3, 'The Little Mermaid', 3, 'Part of Your World', '1989-11-17'),
(4, 'Aladdin', 4, 'A Whole New World', '1992-11-25'),
(5, 'The Princess and the Frog', 5, 'Almost There', '2009-12-11'),
(6, 'Tangled', 6, 'I See the Light', '2010-11-24');
-- Step 5: Write queries
-- Query 1: Retrieve Princess names and their corresponding Kingdom names
SELECT Princesses.PrincessName, Kingdom.KingdomName
FROM Princesses
JOIN Kingdom ON Princesses.KingdomID = Kingdom.KingdomID;
-- Query 2: 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 3: 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 4: 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 1: Retrieve movies released after a certain date
SELECT MovieName, SongName
FROM Movies
WHERE ReleaseDate >'2023-01-01';
-- Query 2: Calculate the average age of Princesses
SELECT AVG(Age) AS AverageAge
FROM Princesses;
-- Query 3: Retrieve Princess names and their corresponding Kingdom names
SELECT P.PrincessName, K.KingdomName
FROM Princesses P
JOIN Kingdom K ON P.KingdomID = K.KingdomID;
-- Query 4: Count the number of movies each Princess is featured in, for Princesses featured in at least two movies
SELECT P.PrincessName, COUNT(*) AS NumMovies
FROM Princesses P
JOIN Movies M ON P.PrincessID = M.PrincessID
GROUP BY P.PrincessName
HAVING COUNT(*)>=2;
PLEASE MODIFY MY SCRIPT BY THE DIRECTIONS BELOW
Update your final script from module 7 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.
Re-run 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!