Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

**PART-2 MySQL Database Scripting (40%, 80 points)** When connected to your MySQL , open a new SQL tab. Write a complete script to create a

**PART-2 MySQL Database Scripting (40%, 80 points)**

When connected to your MySQL, open a new SQL tab.

Write a complete script to create a new database (also called 'schema' in MySQL) Bookstore. This database or schema should contain exactly the same pair of tables, Book and Subject (PROVIDED BELOW). That is, your script must contain SQL DDL statements of CREATE DATABASE and CREATE TABLE(s), plus SQL DML INSERTstatements to insert 30 books and 12 subjects into these two tables, respectively. All constraints, including data types, primary keys, not null, and foreign key must be included in your script.

You should test your script by executing the entire page as a whole to see if it can create Bookstore database without errors. For this test, use the 3rd icon, the yellow lighting without 'I', to execute the entire script of statements as one batch. If it runs with no errors, you can click 'Schemas' tab in Navigator and right-click on the white space area inside Schemas tab and select 'Refresh All' to view your Bookstore in detail (very similar to how it works in SSMS).

image text in transcribed

**PART-3 MySQL Querying (30%, 60 points)**

Open a new SQL tab when MySQL is connected.

Write one SQL statement to solve each of the following queries in Bookstore database.

Query 1: Display ISBN, Title, and Subject_Code of books that have the same subject code as the book 'The Art of Walt Disney'. The output should be sorted by title from a->z. This query must be solved by using a subquery. No hard coded values are allowed in the statement except the book title 'The Art of Walt Disney'.

Query 2: Solve Query 1 again by using a table join.

Query 3: Update the Shelf_Location to KD-2222 for books of a Subject_Code that has the least number of books. For example, if ART and PHL subjects each contains only two books and all other subjects have three or more books, then the Shelf_Location of four books of ART and PHL should be updated. Hint: subquery

Save the script of all three queries as Query_Bookstore.sql in 4703_Project folder.

E dbo.Book EColumns ISBN (PK, nvarchar(13), not null) Title (nvarchar(50), null) Author (nvarchar(30), null) Publisher (nvarchar(30), null) o Subjct Code (FK, nvarchar(3), null) E Shelf_ Location (nvarchar7, null) B Fiction (bit, null) EEdbo.Subject Columns SubjectCode (PK, nvarchar(3), not null) E Subject (nvarchar(15), null)

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

Students also viewed these Databases questions