Question: Write a SQL Query to find the population of this table named 'Caprica'. Code provided. Include the semicolons and screenshots of the outputs. -- Given

Write a SQL Query to find the population of this table named 'Caprica'.

Code provided. Include the semicolons and screenshots of the outputs.

Write a SQL Query to find the population of this table named

-- Given the bsg_people table created by using the following definition query :

--

-- 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

--

-- Find the first name, last name, and age of people from bsg_people whose age is NULL - 12 points

-- Write your query BELOW this line.

'Caprica'. Code provided. Include the semicolons and screenshots of the outputs. --

-- Given the bsg_planets table created by using the following definition query :

--

-- 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 DEFAULT CHARSET=latin1

--

-- Insert information about the planet Mars which has a population of 2,

-- language as "Binary" and "Olympus Mons" as Capital, in bsg_planets. Then

-- list the row(s), with all the information for that planet. - 12 points

-- Write your query BELOW this line.

Given the bsg_people table created by using the following definition query :

-- Given the bsg_people table created from

--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;

--

-- INSERT INTO `bsg_people` (`id`, `fname`, `lname`, `homeworld`, `age`) VALUES

-- (1, 'William', 'Adama', 3, 61),

-- (2, 'Lee', 'Adama', 3, 30),

-- (3, 'Laura', 'Roslin', 3, NULL),

-- (4, 'Kara', 'Thrace', 3, NULL),

-- (5, 'Gaius', 'Baltar', 3, NULL),

-- (6, 'Saul', 'Tigh', NULL, 71),

-- (7, 'Karl', 'Agathon', 1, NULL),

-- (8, 'Galen', 'Tyrol', 1, 32),

-- (9, 'Callandra', 'Henderson', NULL, NULL);

--

--Delete all people whose age is NULL. Then, list all such people whose age is NOT NULL

-- -- CREATE TABLE `bsg_people` ( -- `id` int(11) NOT NULL AUTO_INCREMENT,

-- Create a table with the following columns, named bsg_spaceship

--

-- id - an auto-incrementing integer which is also the primary key

-- name - variable-length string with a max of 255 characters, cannot be null

-- separate_saucer_section - a boolean property which specifies whether or not there is a separate saucer section on the spaceship. This defaults to No.

-- length - integer, cannot be null

--

-- Once you have created the table, run the query "DESCRIBE bsg_spaceship;"

-- Write your queries BELOW this line

4. Find the first name, last name, and age of people from bsg_people whose age is NULL -- 12 points 5. Insert information about the planet Mars which has a population of 2, language as "Binary" and "Olympus Mons" as Capital, in bsg_planets. Then list the row(s), with all the information for that planet. -- 12 points 7. Delete all people whose age is NULL. Then, list all such people whose age is NOT NULL. -- 13 points 8. Create a table with the following columns, named bsg_spaceship. -- 20 points id - an auto-incrementing integer which is also the primary key name - variable-length string with a max of 255 characters, cannot be null separate_saucer_section - a boolean property which specifies whether or not there is a separate saucer section on the spaceship. This defaults to No. Cannot be null length - integer, cannot be null Once you have created the table, run the query "DESCRIBE bsg_spaceship;" This question is going to be somewhat difficult since we didn't cover Data Definition yet. This is where the Recommended Reading for this week will be useful to figure out how exactly to create a table

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!