Question: Hi I will provide you with my sql code and I need you to help me complete this task. - Write a sql statement to

Hi I will provide you with my sql code and I need you to help me complete this task. - Write a sql statement to find distinct names of the planets visited by rebel affiliated humans.. Code: CREATE TABLE Characters(
cName varchar(75) PRIMARY KEY,
cRace varchar(50) DEFAULT NULL,
cHomeworld varchar (50) DEFAULT NULL,
cAffiliation enum ('rebels', 'empire', 'neutral', 'free-lancer')
);
CREATE TABLE Planets (
pName varchar(50) PRIMARY KEY,
pType enum ('gas', 'swamp', 'forest', 'handmade', 'ice', 'desert', 'temperate', 'artificial'),
pAffiliation enum ('rebels', 'empire', 'neutral')
);
CREATE TABLE TimeTable (
cName varchar (50),
pName varchar (50),
Movie varchar(75),
Time_of_Arrival int,
Time_of_Departure int,
PRIMARY KEY (cName, pName, Movie),
Foreign Key (cName) references Characters(cName),
Foreign key (pName) references Planets (pName)
);
INSERT INTO Characters (cName, cRace, cHomeworld, cAffiliation) VALUES
('C-3 PO', 'Droid', 'Unknown', 'rebels'),
('Chewbacca', 'Wookie', 'Kashyyyk', 'rebels'),
('Darth Vader', 'Human', 'Unknown', 'empire'),
('Han Solo', 'Human', 'Corellia', 'rebels'),
('Jabba the Hutt', 'Hutt', 'Unknown', 'neutral'),
('Lando Calrissian', 'Human', 'Unknown', 'rebels'),
('Luke Skywalker', 'Human', 'Tatooine', 'rebels'),
('Obi-Wan Kanobi', 'Human', 'Tatooine', 'rebels'),
('Owen Lars', 'Human', 'Tatooine', 'neutral'),
('Princess Leia', 'Human', 'Alderaan', 'rebels'),
('R2-D2', 'Droid', 'Unknown', 'rebels'),
('Rancor', 'Rancor', 'Unknown', 'neutral'),
('Yoda', 'Unknown', 'Unknown', 'neutral');
INSERT INTO Planets (pName, pType, pAffiliation) VALUES
('Alderaan', 'temperate', 'rebels'),
('Bespin', 'gas', 'neutral'),
('Corellia', 'temperate', 'rebels'),
('Dagobah', 'swamp', 'neutral'),
('Death Star', 'artificial', 'empire'),
('Endor', 'forest', 'neutral'),
('Hoth', 'ice', 'rebels'),
('Kashyyyk', 'forest', 'rebels'),
('Star Destroyer', 'artificial', 'empire'),
('Tatooine', 'desert', 'neutral');
INSERT INTO TimeTable (cName, pName, Movie, Time_of_Arrival, Time_of_Departure) VALUES
('C-3 PO', 'Bespin', 2,5,9),
('C-3 PO', 'Hoth', 2,0,2),
('C-3 PO', 'Tatooine', 1,0,2),
('C-3 PO', 'Tatooine', 3,0,2),
('Chewbacca', 'Bespin', 2,5,9),
('Chewbacca', 'Endor', 3,5,10),
('Chewbacca', 'Hoth', 2,0,2),
('Chewbacca', 'Tatooine', 1,0,2),
('Chewbacca', 'Tatooine', 3,0,2),
('Darth Vader', 'Bespin', 2,5,10),
('Darth Vader', 'Death Star', 1,9,10),
('Darth Vader', 'Death Star', 3,1,9),
('Darth Vader', 'Hoth', 2,3,4),
('Darth Vader', 'Star Destroyer', 1,0,9),
('Han Solo', 'Bespin', 2,5,9),
('Han Solo', 'Endor', 3,5,10),
('Han Solo', 'Hoth', 2,0,4),
('Han Solo', 'Star Destroyer', 1,3,5),
('Han Solo', 'Tatooine', 1,0,2),
('Han Solo', 'Tatooine', 3,0,2),
('Jabba the Hutt', 'Tatooine', 1,0,10),
('Jabba the Hutt', 'Tatooine', 2,0,10),
('Jabba the Hutt', 'Tatooine', 3,0,2),
('Lando Calrissian', 'Bespin', 2,0,9),
('Lando Calrissian', 'Endor', 3,9,10),
('Lando Calrissian', 'Tatooine', 3,0,2),
('Luke Skywalker', 'Bespin', 2,8,10),
('Luke Skywalker', 'Dagobah', 2,4,8),
('Luke Skywalker', 'Dagobah', 3,4,5),
('Luke Skywalker', 'Death Star', 1,9,10),
('Luke Skywalker', 'Death Star', 3,8,10),
('Luke Skywalker', 'Endor', 3,5,8),
('Luke Skywalker', 'Hoth', 2,0,2),
('Luke Skywalker', 'Star Destroyer', 1,3,5),
('Luke Skywalker', 'Tatooine', 1,0,2),
('Luke Skywalker', 'Tatooine', 3,1,2),
('Obi-Wan Kanobi', 'Star Destroyer', 1,3,5),
('Obi-Wan Kanobi', 'Tatooine', 1,0,2),
('Owen Lars', 'Tatooine', 1,0,1),
('Princess Leia', 'Bespin', 2,5,9),
('Princess Leia', 'Endor', 3,5,10),
('Princess Leia', 'Hoth', 2,0,4),
('Princess Leia', 'Star Destroyer', 1,1,5),
('Princess Leia', 'Tatooine', 3,0,2),
('R2-D2', 'Bespin', 2,8,10),
('R2-D2', 'Dagobah', 2,4,8),
('R2-D2', 'Dagobah', 3,4,5),
('R2-D2', 'Endor', 3,5,8),
('R2-D2', 'Hoth', 2,0,2),
('Rancor', 'Tatooine', 1,0,10),
('Rancor', 'Tatooine', 2,0,10),
('Rancor', 'Tatooine', 3,0,3),
('Yoda', 'Dagobah', 1,0,10),
('Yoda', 'Dagobah', 2,0,10),
('Yoda', 'Dagobah', 3,0,5);

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 Databases Questions!