Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using SQL and the following info Question 3: Find the people who do not have Viper Certification but are still assigned to Viper class ship

Using SQL and the following info 

Question 3: Find the people who do not have Viper Certification but are still assigned to Viper class ship

Find the fname, lname, and ship_instance_id for all people who do not have Viper certification but are assigned to at least one instance of a Viper class ship (this includes all variants of Viper class ships).

Return a row for every ship/person combination. Order your results by fname in ascending order.

Use the BSG database from the Quiz Description.

I have gotten this far but all of the output isn't correct. thank you for the help!

select fname,lname from bsg_people p,bsg_ship_assignment a,bsg_ship_instance i,bsg_ship_class c where p.id=a.pid and a.sid=i.id and i.class=c.id and c.name='Viper' group by a.pid; CREATE TABLE `bsg_cert` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB 
CREATE TABLE `bsg_cert_people` ( `cid` int(11) NOT NULL DEFAULT '0', `pid` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`cid`,`pid`), KEY `pid` (`pid`), CONSTRAINT `bsg_cert_people_ibfk_1` FOREIGN KEY (`cid`) REFERENCES `bsg_cert` (`id`), CONSTRAINT `bsg_cert_people_ibfk_2` FOREIGN KEY (`pid`) REFERENCES `bsg_people` (`id`) ) ENGINE=InnoDB 
CREATE TABLE `bsg_people` ( `id` int(11) NOT NULL AUTO_INCREMENT, `fname` varchar(255) NOT NULL, `lname` varchar(255) DEFAULT NULL, `homeworld` int(11) DEFAULT NULL, `age` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `homeworld` (`homeworld`), CONSTRAINT `bsg_people_ibfk_1` FOREIGN KEY (`homeworld`) REFERENCES `bsg_planets` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB 
CREATE TABLE `bsg_planets` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `population` bigint(20) DEFAULT NULL, `language` varchar(255) DEFAULT NULL, `capital` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB

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