Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using the BOOKSTORE database, write a query that finds the City of the store that has 3 3 books in stock. For your answer, only
Using the BOOKSTORE database, write a query that finds the City of the store that has books in stock.
For your answer, only write the Cityin the answer without any commas or extra spaces. ie xxxxx Do not type your SQL query into the answer box.
For example, if the city is Townsville, write Townsville ONLY in the answer box,
this below is database
Page
of
DROP DATABASE IF EXISTS bookstore;
CREATE DATABASE IF NOT EXISTS bookstore;
USE bookstore;
# Table structure for table author
DROP TABLE IF EXISTS author;
CREATE TABLE author
authorID int NOT NULL,
firstName varchar DEFAULT NULL,
lastName varchar DEFAULT NULL,
PRIMARY KEY authorID
;
INSERT INTO author VALUES 'Sansa','Stark''Stephen','King'
'Prakash','Bhandari''Laurianne','Sitbon''Sophie','Monk'
'George','Costanza''Nikki','Peever''Amanda','Jarvinen'
'Jake','Bradford''Wayne','Wood''Sam','Roy''Ned','Stark';
# Table structure for table publisher
DROP TABLE IF EXISTS publisher;
CREATE TABLE publisher
publisherCode int NOT NULL,
publisherName varchar NOT NULL,
publisherCity varchar DEFAULT NULL,
publisherState enumQLD'VIC',NSWWA'TAS',NTSA NOT NULL,
PRIMARY KEY publisherCode
;
INSERT INTO publisher VALUES 'Publishing House','Perth',WA'Storm Pty
Ltd'Melbourne','VIC''Rooster House','Sydney',NSW'Rainforest
Publishing','Hobart','TAS''Cavill Press','Gold Coast',QLD'South
Publishing','Adelaide',SA'James Bond','Gold Coast',QLD;
# Table structure for table branch
DROP TABLE IF EXISTS branch;
CREATE TABLE branch
branchNumber int NOT NULL AUTOINCREMENT,
branchName varchar DEFAULT NULL,
streetNo varchar DEFAULT NULL,
streetName varchar DEFAULT NULL,
branchCity varchar DEFAULT NULL,
branchState enumQLD'VIC',NSWWA'TAS',NTSA NOT NULL,
numberEmployees int DEFAULT NULL,
PRIMARY KEY branchNumber
;
INSERT INTO branch VALUES 'QUT Bookstore','Fake
Street','Brisbane',QLD'Pickabook','Level 'Martin
Place','Sydney',NSW'Paging all Readers','Brunswick
Street','Melbourne','VIC','Books by the Ocean','Jane
Street','Hobart','TAS','Look Inna Book','Lake View','Darwin',NT
'Radelaide Books','North Street','Adelaide',SA'South Perth
Books','Level 'Wilston Avenue','Perth',WA'Once Upon A
Bookstore',A'The Strand Road','Townsville',QLD'Bookmark
Joes'Red Road','Ayers Rock',NT'North Perth books','Western
Road','Perth',WA;
# Table structure for table book
DROP TABLE IF EXISTS book;
CREATE TABLE book
ISBN char NOT NULL,
title varchar NOT NULL,
publisherCode int NOT NULL,
genre enumNonFiction','Science Fiction','Fantasy','Crime','Mystery','Young
Adult','Romance','General Fiction' DEFAULT NULL,
retailPrice decimal DEFAULT NULL,
paperback enumTrue'False' NOT NULL,
PRIMARY KEY ISBN
KEY publisherCodepublisherCode
CONSTRAINT publisherCode FOREIGN KEY publisherCode REFERENCES publisher
publisherCode
;
INSERT INTO book VALUES 'True Crime','Crime','True'
'The Neverending Story','Fantasy','False'
MySQL 'NonFiction','True'
'Teenage Mutant Ninja Turtles','General Fiction','False'
'The Bachelorette','Romance','True''Game
of Thrones','General Fiction','True''A Clockwork
Orange','General Fiction','True'
'Ghostrider','Mystery','True''Steven
Avery guilty or innocent?'Crime','True''The
Habibs','General Fiction','True''American Horror
Story','NonFiction','False''Arrow','Young
Adult','True''Stranger Things 'Science
Fiction','False';
# Table structure for table inventory
DROP TABLE IF EXISTS inventory;
CREATE TABLE inventory
ISBN char NOT NULL,
branchNumber int NOT NULL,
quantityInStock int DEFAULT
PRIMARY KEY ISBNbranchNumber
CONSTRAINT branchNumber FOREIGN KEY branchNumber REFERENCES branch
branchNumber
CONSTRAINT inventoryISBN FOREIGN KEY ISBN REFERENCES bookISBN
;
INSERT INTO inventory VALUES
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started