Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USE mysql to alter this bandinfo table. Add a column called releases. This column will contain a JSON document with the list of releases, type

USE mysql to alter this bandinfo table.

Add a column called releases.

This column will contain a JSON document with

the list of releases,

type of release,

release year

and release title.

See JSON example provided. Choose a number of bands (a minimum of 5) and create a JSON document to list releases

sql for creating bandinfo table

CREATE TABLE bandinfo ( PRIMARY KEY (BandName), BandName VARCHAR(255) NOT NULL, FormationYear INT(4) NOT NULL, CurrentStatus ENUM('Active', 'Inactive') NOT NULL, BaseCity VARCHAR(255) NOT NULL, BaseCountry VARCHAR(255) NOT NULL, NumberOfBandMembers INT(1) NOT NULL, NumberOfReleases INT(1) NOT NULL, Genre VARCHAR(255) NOT NULL ); INSERT INTO bandinfo VALUES ( "BTS", 2010, "Active", "Soel", "South Korea", 5, 25, "KPop" ); INSERT INTO bandinfo VALUES ( "Mirror", 2018, "Active", "HongKong", "China", 12, 1, "Cantopop" ); INSERT INTO bandinfo VALUES ( "Wallows", 2017, "Active", "Los Angelos", "United States", 3, 3, "Rock" ); INSERT INTO bandinfo VALUES ( "The Beatles", 1960, "Inactive", "Liverpool", "United Kingdom", 4, 54, "Rock" ); INSERT INTO bandinfo VALUES ( "The Rolling Stones", 1962, "Active", "London", "United Kingdom", 3, 71, "Rock" ); INSERT INTO bandinfo VALUES ( "Led Zeppelin", 1968, "Inactive", "London", "United Kingdom", 4, 8, "Rock" ); INSERT INTO bandinfo VALUES ( "Nirvana", 1987, "Inactive", "Aberdeen", "United States", 3, 18, "Rock" ); INSERT INTO bandinfo VALUES ( "Coldplay", 1997, "Active", "London", "United Kingdom", 4, 9, "Rock" ); INSERT INTO bandinfo VALUES ( "Twice", 2015, "Active", "Soel", "South Korea", 9, 7, "KPop" ); INSERT INTO bandinfo VALUES ( "Green Day", 1987, "Active", "Los Angelos", "United States", 3, 13, "Rock" ); INSERT INTO bandinfo VALUES ( "Pink Floyd", 1965, "Inactive", "London", "United Kingdom", 4, 15, "Rock" ); INSERT INTO bandinfo VALUES ( "The Beach Boys", 1961, "Active", "Hawthorne", "United States", 5, 29, "Rock" ); INSERT INTO bandinfo VALUES ( "Simon & Garfunkel", 2009, "Inactive", "New York", "United States", 2, 5, "Folk" ); INSERT INTO bandinfo VALUES ( "U2", 1976, "Active", "Dublin", "Ireland", 4, 14, "Rock" ); INSERT INTO bandinfo VALUES ( "BLACKPINK", 2016, "Active", "Soel", "South Korea", 4, 3, "KPop" ); INSERT INTO bandinfo VALUES ( "The Kinks", 1963, "Inactive", "London", "United Kingdom", 4, 24, "Rock" ); INSERT INTO bandinfo VALUES ( "Maneskin", 2016, "Active", "Rome", "Italy", 4, 4, "Rock" ); INSERT INTO bandinfo VALUES ( "AC/DC", 1973, "Active", "Sydney", "Australia", 5, 17, "Rock" ); INSERT INTO bandinfo VALUES ( "One Direction", 2010, "Inactive", "London", "United Kingdom", 5, 5, "Pop" ); INSERT INTO bandinfo VALUES ( "The Kooks", 2004, "Active", "Brighton", "United Kingdom", 4, 6, "Pop" ); 

Here is the sample data for the JSON. Please fix the syntax.

releases = '{ " releases ": [ { " type ": " Album ", " year ": 2020, " title ": " Map of the Soul 7 " }, { " type ": " Single ", " year ": 2021, " title ": " Butter " WHERE BandName = 'BTS'; UPDATE bandinfo SET releases = '{ " releases ": [ { " type ": " Album ", " year ": 2018, " title ": " Spring " }, { " type ": " Single ", " year ": 2019, " title ": " Are You Bored Yet? " }, ] }' WHERE BandName = 'Wallows'; UPDATE bandinfo SET releases = '{ " releases ": [ { " type ": " Album ", " year ": 2020, " title ": " The Album " }, { " type ": " Single ", " year ": 2020, " title ": " Ice Cream " }, ] }' WHERE BandName = 'BLACKPINK'; UPDATE bandinfo SET releases = '{ " releases ": [ { " type ": " Album ", " year ": 1991, " title ": " Nevermind " }, { " type ": " Single ", " year ": 1991, " title ": " Something in the Way " }, ] }' WHERE BandName = 'Nirvana'; UPDATE bandinfo SET releases = '{ " releases ": [ { " type ": " Album ", " year ": 2000, " title ": " Parachutes " }, { " type ": " Single ", " year ": 2014, " title ": " A Sky Full of Stars " }, ] }' WHERE BandName = 'Coldplay';

JSON example not for sample data

-- CONNECT TO SAMPLE; -- DROP TABLE BOOKS; -- CREATE TABLE BOOKS (BOOK VARCHAR(1000)); INSERT INTO BOOKS VALUES '{ "authors": [ { "first_name": "Paul", "last_name" : "Bird" }, { "first_name": "George", "last_name" : "Baklarz" } ], "foreword": { "primary": { "first_name": "Thomas", "last_name" : "Hronis" } }, "formats": { "hardcover": 19.99, "paperback": 9.99, "ebook" : 1.99, "pdf" : 1.99 } } '; 

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

Recommended Textbook for

How Do I Use A Database Research Tools You Can Use

Authors: Laura La Bella

1st Edition

1622753763, 978-1622753765

More Books

Students also viewed these Databases questions