1+ select database();
2+ show databases;
3+ use challenges;
4+
5+ -- Create a database named 'challenges'
6+ CREATE TABLE reviewers (
7+ id INT PRIMARY KEY AUTO_INCREMENT,
8+ first_name VARCHAR (20 ) NOT NULL ,
9+ last_name VARCHAR (20 ) NOT NULL
10+ );
11+
12+ -- Create a table named 'series' with columns for id, title, released_year, and genre
13+ CREATE TABLE series (
14+ id INT PRIMARY KEY AUTO_INCREMENT,
15+ title VARCHAR (50 ),
16+ released_year YEAR,
17+ genre VARCHAR (20 )
18+ );
19+
20+ -- Create a table named 'reviews' with columns for id, rating, series_id, and reviewer_id
21+ CREATE TABLE reviews (
22+ id INT PRIMARY KEY AUTO_INCREMENT,
23+ rating DECIMAL (2 , 1 ),
24+ series_id INT ,
25+ reviewer_id INT ,
26+ FOREIGN KEY (series_id) REFERENCES series (id),
27+ FOREIGN KEY (reviewer_id) REFERENCES reviewers (id)
28+ );
29+
30+ show tables;
31+
32+ -- Insert sample data into the 'series' table
33+ INSERT INTO series (title, released_year, genre) VALUES
34+ (' Archer' , 2009 , ' Animation' ),
35+ (' Arrested Development' , 2003 , ' Comedy' ),
36+ (" Bob's Burgers" , 2011 , ' Animation' ),
37+ (' Bojack Horseman' , 2014 , ' Animation' ),
38+ (" Breaking Bad" , 2008 , ' Drama' ),
39+ (' Curb Your Enthusiasm' , 2000 , ' Comedy' ),
40+ (" Fargo" , 2014 , ' Drama' ),
41+ (' Freaks and Geeks' , 1999 , ' Comedy' ),
42+ (' General Hospital' , 1963 , ' Drama' ),
43+ (' Halt and Catch Fire' , 2014 , ' Drama' ),
44+ (' Malcolm In The Middle' , 2000 , ' Comedy' ),
45+ (' Pushing Daisies' , 2007 , ' Comedy' ),
46+ (' Seinfeld' , 1989 , ' Comedy' ),
47+ (' Stranger Things' , 2016 , ' Drama' );
48+
49+
50+ INSERT INTO reviewers (first_name, last_name) VALUES
51+ (' Thomas' , ' Stoneman' ),
52+ (' Wyatt' , ' Skaggs' ),
53+ (' Kimbra' , ' Masters' ),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