Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 4 Weeks Ago, 4 Days Ago |
Questions Answered: | 7559 |
Tutorials Posted: | 7341 |
BS,MBA, PHD
Adelphi University/Devry
Apr-2000 - Mar-2005
HOD ,Professor
Adelphi University
Sep-2007 - Apr-2017
CIS 111 SOPHIA-STRAYER Introduction to Relational Database Management Systems Unit 2 Milestone-sobtell.com
Click link for Answers All CorrectÂ
1
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following queries will use a subquery to find all of the rows in the track table that has the genre_id equal to 2 and has the length of the song in milliseconds longer than the maximum track length of all songs where the genre_id = 3?
•         Â
SELECT *
FROM TRACK
WHERE milliseconds >
(SELECT MAX(milliseconds)
FROM track
WHERE genre_id = 3)
AND genre_id = 2;
•         Â
SELECT *
FROM TRACK
WHERE milliseconds >
SELECT MAX(milliseconds)
FROM track
WHERE genre_id = 3
AND genre_id = 2;
•         Â
SELECT *
FROM TRACK
WHERE milliseconds >
(SELECT MAX(milliseconds)
FROM track
WHERE genre_id = 2)
AND genre_id = 3;
•         Â
SELECT *
FROM TRACK
WHERE milliseconds >
(SELECT MIN(milliseconds)
FROM track
WHERE genre_id = 3)
AND genre_id = 2;
2
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
https://postgres.sophia.org/
Which of the following query does NOT correctly use aliases?
•         Â
SELECT i.customer_id, total, last_name
FROM invoice AS i
JOIN customer AS c
USING (customer_id);
•         Â
SELECT i.customer_id, i.total, c.last_name
FROM invoice AS i
JOIN customer AS c
USING (customer_id);
•         Â
SELECT c.customer_id, c.total, c.last_name
FROM invoice AS i
JOIN customer AS c
USING (customer_id);
•         Â
SELECT c.customer_id, i.total, c.last_name
FROM invoice AS i
JOIN customer AS c
USING (customer_id);
3
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
https://postgres.sophia.org/
Use the following data model for this question:
Â
Outfit
outfit_id
name
Â
ClothingPiece
piece_id
name
Â
OutfitPiece
outfit_piece_id
outfit_id
piece_id
Â
Which of the following is a situation where an OUTER JOIN could be useful?
•         Â
To view all the clothing pieces, even if they haven't been associated with an outfit in the outfits table
•         Â
To view clothing pieces that are assigned to multiple outfits
•         Â
To view outfits with just one clothing piece
•         Â
To view clothing pieces that have already been assigned to outfits
4
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Given the following view that has been created, how would you query it to find the customers that have ordered more than $30 over their lifetime as a customer?
Â
CREATE VIEW customer_order
AS
SELECT invoice.customer_id, first_name, last_name, SUM(total) as total
FROM invoice
INNER JOIN customer
ON invoice.customer_id = customer.customer_id
GROUP BY invoice.customer_id, first_name, last_name;
•         Â
SELECT *
FROM order
WHERE SUM(total) > 30;
•         Â
SELECT *
FROM customer_order
WHERE total < 30;
•         Â
SELECT *
FROM customer_order
WHERE total > 30;
•         Â
SELECT *
FROM customer_order
WHERE lifetime_total > 30;
5
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Genre
genre_id         name
1Â Â Â Â Â Â Â Â Â Broadway
2Â Â Â Â Â Â Â Â Â Rock
3Â Â Â Â Â Â Â Â Â Classical
4Â Â Â Â Â Â Â Â Â Salsa
Â
Track
track_id          name  genre_id
1         Highway to Hell        2
2         Everlong        2
3         Smells Like Teen Spirit         2
Â
Given the above genres and tracks, how many results will be returned for the following query?
SELECT genre.name, track.name
FROM track
RIGHT JOIN genre
USING (genre_id);
•         Â
6
•         Â
5
•         Â
3
•         Â
4
6
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Given the tables have been created without foreign keys added, which of the following ALTER TABLE statements would create a foreign key on the coordinator_id in the email table to reference the coordinator_id in the coordinator table?
•         Â
ALTER TABLE email
ADD CONSTRAINT fk_email
FOREIGN KEY coordinator (coordinator_id)
REFERENCES coordinator_id;
•         Â
ALTER TABLE coordinator
ADD CONSTRAINT fk_email
FOREIGN KEY (coordinator_id)
REFERENCES email (coordinator_id);
•         Â
ALTER TABLE email
ADD CONSTRAINT
FOREIGN KEY (coordinator_id)
REFERENCES coordinator (coordinator_id);
•         Â
ALTER TABLE email
ADD CONSTRAINT fk_email
FOREIGN KEY (coordinator_id)
REFERENCES coordinator (coordinator_id);
7
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Given the following queries, which of these would be the most efficient?
Â
1. SELECT *
FROM invoice
WHERE customer_id IN
(SELECT customer_id
FROM customer
WHERE country like 'U%');
Â
2. SELECT invoice.*
FROM invoice
INNER JOIN customer
ON customer.customer_id = invoice.customer_id
WHERE country like 'U%';
•         Â
Both would be the same as both use the same indices for the join and filter.
•         Â
Query #1 would be more efficient as it is based on primary and foreign keys.
•         Â
Query #2 would be more efficient as it is not using indexed columns.
•         Â
Query #2 would be more efficient as it is based on primary and foreign keys.
Check other also
8
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
https://postgres.sophia.org/
Why is the following query NOT valid as a NATURAL JOIN?
Â
SELECT customer.first_name, customer.last_name, employee.first_name, employee.last_name
FROM customer
NATURAL JOIN employee;
•         Â
The tables have a shared column, but their column names are not identical, so a JOIN... ON is needed.
•         Â
The syntax used for NATURAL JOIN is not correct.
•         Â
The tables do not have a foreign key relationship.
•         Â
These two tables do not share any identical columns/fields.
9
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following statements would create a UNION between all of the columns of invoice where the total of the invoice is greater than 10, combined with the invoices that have an invoice_date greater or equal to 2013-08-01, and combined with the billing country in the USA with the billing state in FL?
•         Â
SELECT *
FROM invoice
WHERE total > 10
SELECT *
FROM invoice
WHERE invoice_date >= '2013-08-01'
UNION
SELECT *
FROM invoice
WHERE billing_country = 'USA' AND billing_state = 'FL';
•         Â
SELECT *
FROM invoice
UNION
WHERE total > 10
SELECT *
FROM invoice
UNION
WHERE invoice_date >= '2013-08-01'
SELECT *
FROM invoice
WHERE billing_country = 'USA' AND billing_state = 'FL';
•         Â
SELECT *
FROM invoice
WHERE total > 10
UNION
SELECT *
FROM invoice
WHERE invoice_date >= '2013-08-01'
UNION
SELECT *
FROM invoice
WHERE billing_country = 'USA' AND billing_state = 'FL';
•         Â
SELECT *
FROM invoice
WHERE total > 10
SELECT *
FROM invoice
WHERE invoice_date >= '2013-08-01'
SELECT *
FROM invoice
WHERE billing_country = 'USA' AND billing_state = 'FL';
10
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
In trying to insert into the playlist_track table, what is the cause of this error?
Query failed because of: error: insert or update on table "playlist_track" violates foreign key constraint "playlist_track_playlist_id_fkey"
•         Â
The playlist_id needs to be added to the playlist table first.
•         Â
The playlist_track_id is not unique.
•         Â
The playlist_id being referenced doesn't exist in the playlist table.
•         Â
The playlist_id in the playlist_track table doesn't exist yet.
11
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which results would show if the employee table LEFT JOINed the customer table?
•         Â
Only customers that have employees associated with them and vice-versa
•         Â
All rows from the customer table even if they don't have an employee supporting them
•         Â
All employees, even those that aren't supporting customers
•         Â
Only employees that have customers that they support
12
Â
Which of the following statements would be a valid DROP VIEW statement for an invoice_verification table that would prevent the removal of a view if there are any objects depending on it?
•         Â
DROP VIEW invoice_verification RESTRICT;
•         Â
DROP VIEW IF EXISTS invoice_verification;
•         Â
DROP VIEW CASCADE invoice_verification;
•         Â
DROP VIEW invoice_verification;
13
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following statements would query the invoice_line table to sum up the totals by multiplying the unit_price with the quantity grouped by track_id?
•         Â
SELECT track_id, SUM(quantity * unit_price) AS total
FROM invoice_line
GROUP BY track_id
ORDER BY total DESC;
•         Â
SELECT track_id, (quantity * unit_price) AS total
FROM invoice_line
GROUP BY track_id
ORDER BY total DESC;
•         Â
SELECT track_id, SUM(quantity * unit_price) AS total
FROM invoice_line
ORDER BY total DESC;
•         Â
SELECT track_id, (quantity / unit_price) AS total
FROM invoice_line
GROUP BY track_id
ORDER BY total DESC;
14
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Animal
animal_id
name
adopter_id
Â
Adopter
adopter_id
name
Â
Given the above data for an adoption agency, what does the result set for the following query represent?
Â
SELECT adopter.name, animal.name
FROM Animal
CROSS JOIN Adopter;
•         Â
It represents every single Animal in the animal table regardless of whether they have been adopted or not.
•         Â
It represents all adopters regardless of whether they have claimed an animal in the animal table.
•         Â
It represents each animal, with the name of their adopter if that has been specified via a Foreign Key.
•         Â
It represents every single animal matches with every single adopter.
15
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following data models appropriately models the relationship of recipes and their ingredients?
•         Â
recipe
recipe_id
recipe_name
ingredient_id (FK)
Â
ingredient
ingredient_id
ingredient_name
ingredient_amount
•         Â
recipe
recipe_id
recipe_name
ingredient_name_1
ingredient_amount_1
ingredient_name_2
ingredient_amount_2
•         Â
recipe
recipe_id
recipe_name
Â
ingredient
ingredient_id
recipe_id (FK)
ingredient_name
ingredient_amount
•         Â
ingredient
ingredient_id
recipe_name
ingredient_name
ingredient_amount
16
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
What will be the result of the query based on the following criteria?
<columnname>Â <=Â ANY (<subquery>)
•         Â
Returns true if the value is less than the smallest value returned by the subquery.
•         Â
Returns true if the value is less than or equal to the smallest value returned by the subquery.
•         Â
Returns true if the value is less than or equal to any of the values returned by the subquery.
•         Â
Returns true if the value is less than any of the values returned by the subquery.
17
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following is true of foreign keys?
•         Â
A foreign key can be linked to a NOT NULL column.
•         Â
A foreign key may be linked to a unique column that establishes a 1 to 1 relationship.
•         Â
A foreign key is not needed if the data type is different.
•         Â
Foreign keys are not needed when we require referential integrity.
18
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following queries would check for the duplicate of reports_to WITHOUT returning the count of each?
•         Â
SELECT reports_to, count(*)
FROM employee
GROUP BY reports_to
HAVING COUNT(*) > 1;
•         Â
SELECT reports_to
FROM employee
GROUP BY reports_to
HAVING COUNT(*) > 1;
•         Â
SELECT reports_to, count(*)
FROM employee
GROUP BY reports_to
HAVING > 1;
•         Â
SELECT reports_to
FROM employee
HAVING COUNT(*) > 1;
Find Duplicate Rows
Report an issue with this question
19
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
https://postgres.sophia.org/
Which of the following statements will show the following result set?
Â
Â
•         Â
SELECT track_id, name
FROM track
JOIN playlist_track
USING (track.name = playlist.name);
•         Â
SELECT track_id, name
FROM track
JOIN playlist_track
WHERE track_id != NULL;
•         Â
SELECT track_id, name
FROM track
JOIN playlist_track
USING (track_id);
•         Â
SELECT track_id, name
FROM track, playlist_track;
20
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
https://postgres.sophia.org/
Which of the following is a correctly formatted SELECT statement to show the following result set with the media type's name and the track's name?
•         Â
SELECT media_type.name, track.name
FROM track
JOIN media_type
ON media_type.media_type_id = track.media_type_id;
•         Â
SELECT media_type.name, track.name
FROM track
JOIN media_type
ON mediatype.media_type_id = track.media_type_id;
•         Â
SELECT media_type.name, track.name
FROM track
JOIN media_type
ON media_type.media_type_id = track.track_id;
•         Â
SELECT media_type.name, track.name
FROM track
JOIN media_type
ON media_type.media_type.id = track.media_type.id;
21
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which result set requires a JOIN?
•         Â
Showing invoice_dates with invoice totals
•         Â
Showing invoice totals, invoice_dates, and customer_id's
•         Â
Showing customer names with invoice_dates
•         Â
Showing invoice_dates with customer_id's
CONCEPT
Joins
Report an issue with this question
22
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following is the valid syntax for creating a VIEW to view a subset of a table?
•         Â
CREATE VIEW album_cost
AS track
GROUP BY album_id;
•         Â
CREATE VIEW album_cost
AS
SELECT album_id, SUM(unit_price)
FROM track
GROUP BY album_id;
•         Â
CREATE VIEW album_cost
SELECT album_id, SUM(unit_price)
FROM track
GROUP BY album_id;
•         Â
CREATE VIEW album_cost
AS
SELECT album_id, SUM(unit_price)
GROUP BY album_id;
23
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Given the initial tables in our example database, if we wanted to delete artists, tracks, and albums that HAVE NOT been purchased before, in what order do we need to delete data from our tables?
•         Â
track
album
artist
•         Â
artist
album
track
media_type
genre
•         Â
invoice_line
invoice
track
album
artist
•         Â
artist
album
track
24
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
What type of situation would you need to create or replace a view?
•         Â
The view is no longer being used.
•         Â
Data has been imported from other databases.
•         Â
The underlying query is not efficient and needs to be updated.
•         Â
On a daily basis so that the data is refreshed.
25
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following is the valid syntax for creating a VIEW to view data from multiple tables?
•         Â
CREATE VIEW customer_order
AS
SELECT invoice.customer_id, first_name, last_name, SUM(total) as total
FROM invoice
INNER JOIN customer
ON invoice.customer_id = customer.customer_id
GROUP BY invoice.customer_id, first_name, last_name;
•         Â
CREATE VIEW customer_order
SELECT invoice.customer_id, first_name, last_name, SUM(total) as total
FROM invoice
INNER JOIN customer
ON invoice.customer_id = customer.customer_id
GROUP BY invoice.customer_id, first_name, last_name;
•         Â
CREATE VIEW customer_order
AS
SELECT invoice.customer_id, first_name, last_name, SUM(total) as total
ON invoice.customer_id = customer.customer_id
GROUP BY invoice.customer_id, first_name, last_name;
•         Â
CREATE VIEW customer order
AS
SELECT invoice.customer_id, first_name, last_name, SUM(total) as total
FROM invoice
INNER JOIN customer
ON invoice.customer_id = customer.customer_id
GROUP BY invoice.customer_id, first_name, last_name;
Â
1
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following statements would create a UNION between all of the countries we have customers, employees, or invoices in?
•         Â
SELECT billing_country
FROM invoice
UNION
SELECT country
FROM customer
UNION
SELECT country
FROM employee;
•         Â
SELECT billing_country
FROM invoice
SELECT country
FROM customer
SELECT country
FROM employee
UNION;
•         Â
SELECT country
FROM invoice
UNION
SELECT country
FROM customer
UNION
SELECT country
FROM employee;
•         Â
SELECT billing_country
FROM invoice
SELECT country
FROM customer
SELECT country
FROM employee;
2
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
https://postgres.sophia.org/
When is a natural join possible between two tables?
•         Â
When columns in two separate tables contain the same data
•         Â
When the tables being joined both contain a column with the same name and data type
•         Â
When two tables have a foreign key relationship
•         Â
When the tables being joined have only one column each other than the primary key
3
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following statements would calculate the average bytes per millisecond grouped by the media_type_id in the track table?
•         Â
SELECT media_type_id, AVG(bytes/milliseconds)
FROM track;
•         Â
SELECT media_type_id, (bytes/milliseconds)
FROM track
GROUP BY media_type_id;
•         Â
SELECT media_type_id, AVG(bytes/milliseconds)
FROM track
GROUP BY media_type_id;
•         Â
SELECT media_type_id, AVG(milliseconds/bytes)
FROM track
GROUP BY media_type_id;
4
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
https://postgres.sophia.org/
Which of the following statements will be able to show the following result set?
Â
Â
•         Â
SELECT name, title
FROM album
JOIN track
WHERE album_id != NULL;
•         Â
SELECT name, title
FROM album
JOIN track
USING (track_id);
•         Â
SELECT name, title
FROM album
JOIN track
USING (album_id);
•         Â
SELECT name, title
FROM album, track;
5
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Genre
genre_id         name
1Â Â Â Â Â Â Â Â Â Broadway
2Â Â Â Â Â Â Â Â Â Rock
3Â Â Â Â Â Â Â Â Â Classical
4Â Â Â Â Â Â Â Â Â Salsa
Â
Â
Track
track_id          name  genre_id
1         Highway to Hell        2
2         Everlong        2
3         Smells Like Teen Spirit         2
Â
Given the above genres and tracks, how many results will be returned for the following query?
Â
SELECT genre.name, track.name
FROM genre
RIGHT JOIN track
USING (genre_id);
•         Â
5
•         Â
3
•         Â
4
•         Â
6
6
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following data models appropriately models the relationship of coordinators and their email addresses?
•         Â
email_id
coordinator_name
email_type
email_address
•         Â
Coordinator
coordinator_id
coordinator_name
Â
email_id
coordinator_id (FK)
email_type
email_address
•         Â
Coordinator
coordinator_id
coordinator_name
email_type_1
email_address_1
email_type_2
email_address_2
•         Â
Coordinator
coordinator_id
coordinator_name
email_id (FK)
Â
email_id
email_type
email_address
7
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which result set requires a JOIN?
•         Â
Showing track name with track ID
•         Â
Showing media type name with track name
•         Â
Showing media type ID with track name
•         Â
Showing track ID, media type ID, and track name
8
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following is the valid syntax for creating a VIEW to view data from multiple tables?
•         Â
CREATE VIEW album_artist_names
AS
SELECT album.title, artist.name
FROM album
INNER JOIN artist
ON album.artist_id = artist.artist_id;
•         Â
CREATE VIEW album artist names
AS
SELECT album.title, artist.name
FROM album
INNER JOIN artist
ON album.artist_id = artist.artist_id;
•         Â
CREATE VIEW album_artist_names
SELECT album.title, artist.name
FROM album
INNER JOIN artist
ON album.artist_id = artist.artist_id;
•         Â
CREATE VIEW album_artist_names
AS
SELECT album.title, artist.name
FROM album
ON album.artist_id = artist.artist_id;
9
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Given the initial tables in our example database, if we wanted to delete tracks, albums, and artists that HAVE been purchased before, in what order do we need to delete data from our tables?
•         Â
invoice_line
invoice
track
album
artist
•         Â
artist
album
track
media_type
genre
•         Â
track
album
artist
•         Â
artist
album
track
10
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Given the tables have been created without foreign keys added, which of the following ALTER TABLE statements would create a foreign key on the customer_id in the department table to reference the customer_id in the customer table?
•         Â
ALTER TABLE department
ADD CONSTRAINT
FOREIGN KEY (customer_id)
REFERENCES customer (customer_id);
•         Â
ALTER TABLE department
ADD CONSTRAINT fk_department
FOREIGN KEY (customer_id)
REFERENCES customer (customer_id);
•         Â
ALTER TABLE customer
ADD CONSTRAINT fk_department
FOREIGN KEY (customer_id)
REFERENCES department (customer_id);
•         Â
ALTER TABLE department
ADD CONSTRAINT fk_department
FOREIGN KEY customer (customer_id)
REFERENCES customer_id;
11
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following statements would be a valid DROP VIEW statement to remove the two views, which will also display an error if either view doesn't exist?
•         Â
DROP VIEW album_cost, album_artist_names CASCADE;
•         Â
DROP VIEW album_cost, album_artist_names;
•         Â
DROP VIEW album_cost AND album_artist_names;
•         Â
DROP VIEW IF EXISTS album_cost, album_artist_names;
12
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
https://postgres.sophia.org/
Select the query that properly uses table aliases to show the genres of each track in the Album with the id of 6.
•         Â
SELECT g.name, t.name
FROM t AS track
JOIN g AS genre
USING (genre_id)
WHERE t.album_id=6;
•         Â
SELECT g(name), t(name)
FROM track AS t
JOIN genre AS g
USING (genre_id)
WHERE t(album_id)=6;
•         Â
SELECT g.name, t.name
FROM track AS t
JOIN genre AS g
USING (genre_id)
WHERE t.album_id=6;
•         Â
SELECT genre.name, track.name
FROM track
JOIN genre
USING (genre_id)
WHERE track.album_id=6;
13
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following queries will use a subquery to find all of the rows in the track table that has a unit_price of 0.99 and has the length of the song in milliseconds that is longer than the AVG track length of all tracks in the album_id between 5 and 10?
•         Â
SELECT *
FROM TRACK
WHERE milliseconds >
SELECT AVG(milliseconds)
FROM track
WHERE album_id BETWEEN 5 AND 10
AND unit_price = 0.99;
•         Â
SELECT *
FROM TRACK
WHERE milliseconds >
(SELECT AVG(milliseconds)
FROM track
WHERE album_id BETWEEN 5 AND 10)
AND unit_price = 0.99;
•         Â
SELECT AVG(milliseconds)
FROM TRACK
WHERE milliseconds >
(SELECT *
FROM track
WHERE album_id BETWEEN 5 AND 10)
AND unit_price = 0.99;
•         Â
SELECT *
FROM TRACK
WHERE milliseconds >
(SELECT AVG(milliseconds)
FROM track
WHERE unit_price = 0.99)
AND album_id BETWEEN 5 AND 10;
14
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
https://postgres.sophia.org/
Which of the following is a correctly formatted SELECT statement to show the following result set with the invoice total, customer's customer_id, and the invoice's billing_state?
•         Â
SELECT total, invoice.customer_id, billing_state
FROM invoice
JOIN customer
ON invoice.customer_id = customer.customer_id;
•         Â
SELECT total, invoice.customer_id, billing_state
FROM invoice
JOIN customer
ON invoice.customer_id = consumer.customer_id;
•         Â
SELECT invoice_total, invoice.customer_id, billing_state
FROM invoice
JOIN customer
ON invoice.invoice_id = customer.customer_id;
•         Â
SELECT invoice_total, invoice.customer_id, billing_state
FROM invoice
JOIN customer
ON invoice.id = customer.id;
15
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
What is incorrect regarding the following statement intended to create a VIEW?
Â
CREATE VIEW priority_invoices AS
FROM invoice
WHERE total > 100;
•         Â
The name "priority_invoices" is not a table that exists in the database.
•         Â
The name of the VIEW belongs after the word "AS".
•         Â
It's not possible to create a view that only shows a subset of the data from a table.
•         Â
The fields that should belong in the result set are not specified.
16
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which results would show if the genre table LEFT JOINed the track table?
•         Â
All rows from the track table, even those that have NULL genre_id's
•         Â
Only genres that don't have tracks in the track table
•         Â
All genres, even those with no tracks in the track table
•         Â
Only genres with tracks in the track table
17
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
https://postgres.sophia.org/
Use the following data model for this question:
Â
Recipe
recipe_id
title
Â
Ingredient
ingredient_id
name
Â
Recipe_Ingredient
recipe_ingredient_id
recipe_id
ingredient_id
Â
Which of the following is a situation where an OUTER JOIN could be useful?
•         Â
To view only ingredients that are being utilized for particular recipes
•         Â
To view recipes that have ingredients in the ingredients table
•         Â
To view all ingredients in the database even if they are not being used for a particular recipe
•         Â
To view recipes that have the word "banana" in their title
18
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Given the following queries, which of these would be the most efficient?
Â
1. SELECT customer.*
FROM invoice
INNER JOIN customer
ON customer.city = invoice.billing_city
WHERE COUNTRY like '%m';
Â
2. SELECT *
FROM customer
WHERE city IN
(SELECT billing_city
FROM invoice
WHERE COUNTRY like '%m');
•         Â
Query #2 would be more efficient as it is based on primary and foreign keys.
•         Â
Query #1 would be more efficient as it is based on primary and foreign keys.
•         Â
Query #1 would be more efficient as it is index indices.
•         Â
Both would be the same as both use the same indices for the join and filter.
Check other also
Â
19
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following queries would check for duplicates of first names in the customer table and how many there are of each?
•         Â
SELECT first_name, COUNT(*)
FROM customer
WHERE COUNT(*) > 1;
•         Â
SELECT first_name
FROM customer
GROUP BY first_name
HAVING COUNT(*) > 0;
•         Â
SELECT first_name
FROM customer
GROUP BY first_name
HAVING COUNT(*) > 1;
•         Â
SELECT first_name, COUNT(*)
FROM customer
GROUP BY first_name
HAVING COUNT(*) > 1;
20
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
What will be the result of the query based on the following criteria?
<columnname>Â =Â ALL (<subquery>)
•         Â
Returns true if the value is equal to every value returned by the subquery.
•         Â
Returns true if the value is not equal to any values returned by the subquery.
•         Â
Returns true if the value is not equal to any value returned by the subquery.
•         Â
Returns true if the value is equal to any value returned by the subquery.
21
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
What type of situation would you need to create or replace a view?
•         Â
On a daily basis so that the data is refreshed.
•         Â
A view has already been created with the same name but needs to be changed.
•         Â
The view is no longer being used.
•         Â
The view needs to have update, insert, and delete statements allowed.
22
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Outfit
ID: 1, Name: Rainy day outfit
ID: 2, Name: Important meeting outfit
ID: 3, Name: Fancy event outfit
ID: 4, Name: Beach outfit
Â
Piece
ID: 1, Name: Gray button-up shirt
ID: 2, Name: Rainboots
ID: 3, Name: Velvet pants
Â
Â
Given the above data for an outfit generator, how many records would be included in the result set for the following query?
Â
SELECT Outfit.name, Piece.name
FROM Outfit
CROSS JOIN Piece;
•         Â
12
•         Â
9
•         Â
4
•         Â
7
23
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following is true of foreign keys?
•         Â
A foreign key could be linked to a candidate key of a table.
•         Â
A foreign key can be linked to any foreign key.
•         Â
A foreign key should always be linked to a primary key of another table.
•         Â
A foreign key is not needed if the data type is different.
24
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Given the following view that has been created, how would you query the view to list the artist names in ascending order and album titles in desc order?
CREATE VIEW album_artist_names
AS
SELECT album.title, artist.name
FROM album
INNER JOIN artist
ON album.artist_id = artist.artist_id;
•         Â
SELECT *
FROM album, artist
ORDER BY name ASC, title DESC;
•         Â
SELECT *
FROM album_artist_names
ORDER BY name DESC, title;
•         Â
SELECT *
FROM album_artist_names
ORDER BY name, title DESC;
•         Â
SELECT *
FROM album_artist_names
ORDER BY name DESC, title ASC;
25
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
In trying to delete from the playlist table, what is the cause of this error?
"Query failed because of: error: update or delete on table "playlist" violates foreign key constraint "playlist_track_playlist_id_fkey" on table "playlist_track"
•         Â
The playlist_id doesn't exist in the playlist table.
•         Â
The track has to be deleted first before the playlist is deleted.
•         Â
The playlist_id doesn't exist in the playlist_track table.
•         Â
The playlist_track table has a reference to the playlist_id that is being deleted.
Â
1
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following is true of foreign keys?
•         Â
A foreign key should always be linked to a primary key of another table.
•         Â
A foreign key can be linked to any foreign key.
•         Â
Tables could be created first to avoid having to create foreign keys in order.
•         Â
A foreign key is not needed if the data type is different.
2
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following statements would create a UNION between all of the countries we have customers, employees, or invoices in?
•         Â
SELECT country
FROM invoice
UNION
SELECT country
FROM customer
UNION
SELECT country
FROM employee;
•         Â
SELECT billing_country
FROM invoice
SELECT country
FROM customer
SELECT country
FROM employee;
•         Â
SELECT billing_country
FROM invoice
SELECT country
FROM customer
SELECT country
FROM employee
UNION;
•         Â
SELECT billing_country
FROM invoice
UNION
SELECT country
FROM customer
UNION
SELECT country
FROM employee;
3
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Given the tables have been created without foreign keys added, which of the following ALTER TABLE statements would create a foreign key on the customer_id in the department table to reference the customer_id in the customer table?
•         Â
ALTER TABLE customer
ADD CONSTRAINT fk_department
FOREIGN KEY (customer_id)
REFERENCES department (customer_id);
•         Â
ALTER TABLE department
ADD CONSTRAINT
FOREIGN KEY (customer_id)
REFERENCES customer (customer_id);
•         Â
ALTER TABLE department
ADD CONSTRAINT fk_department
FOREIGN KEY (customer_id)
REFERENCES customer (customer_id);
•         Â
ALTER TABLE department
ADD CONSTRAINT fk_department
FOREIGN KEY customer (customer_id)
REFERENCES customer_id;
Â
4
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Given the initial tables in our example database, if we wanted to delete tracks, albums, and artists that HAVE been purchased before, in what order do we need to delete data from our tables?
•         Â
track
album
artist
•         Â
artist
album
track
•         Â
invoice_line
invoice
track
album
artist
•         Â
artist
album
track
media_type
genre
5
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
https://postgres.sophia.org/
Which of the following query does NOT correctly use aliases?
•         Â
SELECT i.customer_id, i.total, c.last_name
FROM invoice AS i
JOIN customer AS c
USING (customer_id);
•         Â
SELECT c.customer_id, i.total, c.last_name
FROM invoice AS i
JOIN customer AS c
USING (customer_id);
•         Â
SELECT i.customer_id, total, last_name
FROM invoice AS i
JOIN customer AS c
USING (customer_id);
•         Â
SELECT c.customer_id, c.total, c.last_name
FROM invoice AS i
JOIN customer AS c
USING (customer_id);
6
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
https://postgres.sophia.org/
Which of the following statements will show the following result set?
Â
Â
•         Â
SELECT track_id, name
FROM track
JOIN playlist_track
WHERE track_id != NULL;
•         Â
SELECT track_id, name
FROM track
JOIN playlist_track
USING (track.name = playlist.name);
•         Â
SELECT track_id, name
FROM track
JOIN playlist_track
USING (track_id);
•         Â
SELECT track_id, name
FROM track, playlist_track;
7
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which result set requires a JOIN?
•         Â
Showing all album titles with both artist ID and album ID
•         Â
Showing artist_id with album title
•         Â
Showing all album_id's with artist names
•         Â
Showing artist names with artist_id's
8
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which results would show if the artist table LEFT JOINed the album table?
•         Â
All artists, even those with no albums in the album table
•         Â
All rows from the album table, even those that have NULL artist_id's
•         Â
Only artists from the artist table that have albums
•         Â
Only rows from the artist table that do not have related albums in the album table
9
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following is the valid syntax for creating a VIEW to view a subset of a table?
•         Â
CREATE VIEW USA_customers
AS customer
SELECT *
WHERE country = 'USA';
•         Â
CREATE VIEW USA_customers
SELECT *
FROM customer
WHERE country = 'USA';
•         Â
CREATE VIEW USA_customers
AS
SELECT *
FROM customer
WHERE country = 'USA';
•         Â
CREATE VIEW USA_customers
AS customer
WHERE country = 'USA';
10
Â
Which of the following statements would be a valid DROP VIEW statement for an invoice_verification table that would prevent the removal of a view if there are any objects depending on it?
•         Â
DROP VIEW CASCADE invoice_verification;
•         Â
DROP VIEW invoice_verification RESTRICT;
•         Â
DROP VIEW IF EXISTS invoice_verification;
•         Â
DROP VIEW invoice_verification;
11
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
https://postgres.sophia.org/
Why is the following query valid for a NATURAL join?
Â
SELECT album.title, artist.name
FROM album
NATURAL JOIN artist;
•         Â
The two tables share identical columns.
•         Â
The tables do not have a foreign key relationship.
•         Â
The tables have a shared column, but their column names are not identical which makes it a candidate for a NATURAL JOIN.
•         Â
The query is not a valid NATURAL JOIN query and must use a JOIN... ON instead.
12
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Given the following view that has been created, how would you query the playlist names and track names both in descending order?
CREATE VIEW playlist_track_names
AS
SELECT playlist.name as playlist_name, track.name as track_name
FROM playlist
INNER JOIN playlist_track
ON playlist.playlist_id = playlist_track.playlist_id
INNER JOIN track
ON playlist_track.track_id = track.track_id;
•         Â
SELECT *
FROM playlist_track_names
ORDER BY track_name, playlist_name;
•         Â
SELECT *
FROM playlist_track_names
ORDER BY playlist_name, track_name DESC;
•         Â
SELECT *
FROM playlist_track_names
ORDER BY playlist_name DESC, track_name DESC;
•         Â
SELECT *
FROM playlist_track_names
ORDER BY playlist_name ASC, track_name ASC;
13
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following queries will use a subquery to find all of the rows in the track table that has the genre_id equal to 2 and has the length of the song in milliseconds longer than the maximum track length of all songs where the genre_id = 3?
•         Â
SELECT *
FROM TRACK
WHERE milliseconds >
(SELECT MAX(milliseconds)
FROM track
WHERE genre_id = 2)
AND genre_id = 3;
•         Â
SELECT *
FROM TRACK
WHERE milliseconds >
SELECT MAX(milliseconds)
FROM track
WHERE genre_id = 3
AND genre_id = 2;
•         Â
SELECT *
FROM TRACK
WHERE milliseconds >
(SELECT MIN(milliseconds)
FROM track
WHERE genre_id = 3)
AND genre_id = 2;
•         Â
SELECT *
FROM TRACK
WHERE milliseconds >
(SELECT MAX(milliseconds)
FROM track
WHERE genre_id = 3)
AND genre_id = 2;
14
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
https://postgres.sophia.org/
Use the following data model for this question:
Â
Outfit
outfit_id
name
Â
ClothingPiece
piece_id
name
Â
OutfitPiece
outfit_piece_id
outfit_id
piece_id
Â
Which of the following is a situation where an OUTER JOIN could be useful?
•         Â
To view outfits with just one clothing piece
•         Â
To view all the clothing pieces, even if they haven't been associated with an outfit in the outfits table
•         Â
To view clothing pieces that are assigned to multiple outfits
•         Â
To view clothing pieces that have already been assigned to outfits
15
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following queries would check for duplicates of a track's composer in the track table and how many there are of each?
•         Â
SELECT composer, COUNT(*)
FROM track
GROUP BY composer
HAVING COUNT(*) > 1;
•         Â
SELECT composer, COUNT(*)
FROM track
HAVING COUNT(*) > 1;
•         Â
SELECT composer
FROM track
GROUP BY composer
HAVING COUNT(*) > 1;
•         Â
SELECT track_id, COUNT(*)
FROM track
GROUP BY track_id
HAVING COUNT(*) > 1;
16
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Given the following queries, which of these would be the most efficient?
Â
1. SELECT *
FROM invoice
WHERE customer_id IN
(SELECT customer_id
FROM customer
WHERE country like 'U%');
Â
2. SELECT invoice.*
FROM invoice
INNER JOIN customer
ON customer.customer_id = invoice.customer_id
WHERE country like 'U%';
•         Â
Both would be the same as both use the same indices for the join and filter.
•         Â
Query #1 would be more efficient as it is based on primary and foreign keys.
•         Â
Query #2 would be more efficient as it is not using indexed columns.
•         Â
Query #2 would be more efficient as it is based on primary and foreign keys.
Check other also
Â
17
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following is the valid syntax for creating a VIEW to view data from multiple tables?
•         Â
CREATE VIEW album_artist_names
AS
SELECT album.title, artist.name
FROM album
ON album.artist_id = artist.artist_id;
•         Â
CREATE VIEW album_artist_names
SELECT album.title, artist.name
FROM album
INNER JOIN artist
ON album.artist_id = artist.artist_id;
•         Â
CREATE VIEW album artist names
AS
SELECT album.title, artist.name
FROM album
INNER JOIN artist
ON album.artist_id = artist.artist_id;
•         Â
CREATE VIEW album_artist_names
AS
SELECT album.title, artist.name
FROM album
INNER JOIN artist
ON album.artist_id = artist.artist_id;
18
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
In trying to insert into the playlist_track table, what is the cause of this error?
Query failed because of: error: insert or update on table "playlist_track" violates foreign key constraint "playlist_track_playlist_id_fkey"
•         Â
The playlist_id needs to be added to the playlist table first.
•         Â
The playlist_id being referenced doesn't exist in the playlist table.
•         Â
The playlist_track_id is not unique.
•         Â
The playlist_id in the playlist_track table doesn't exist yet.
19
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following data models appropriately models the relationship of companies and their phone numbers?
•         Â
Company
company_id
company_name
phone_id (FK)
Â
Phone
phone_id
phone_type
phone_number
•         Â
Company
company_id
company_name
Â
Phone
phone_id
company_id (FK)
phone_type
phone_number
•         Â
Phone
phone_id
company_name
phone_type
phone_number
•         Â
Company
company_id
company_name
phone_type_1
phone_number_1
phone_type_2
phone_number_2
20
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Genre
genre_id         name
1Â Â Â Â Â Â Â Â Â Broadway
2Â Â Â Â Â Â Â Â Â Rock
3Â Â Â Â Â Â Â Â Â Classical
4Â Â Â Â Â Â Â Â Â Salsa
Â
Track
track_id          name  genre_id
1         Highway to Hell        2
2         Everlong        2
3         Smells Like Teen Spirit         2
Â
Given the above genres and tracks, how many results will be returned for the following query?
SELECT genre.name, track.name
FROM track
RIGHT JOIN genre
USING (genre_id);
•         Â
5
•         Â
4
•         Â
3
•         Â
6
21
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
What will be the result of the query based on the following criteria?
<columnname>Â <=Â ANY (<subquery>)
•         Â
Returns true if the value is less than or equal to any of the values returned by the subquery.
•         Â
Returns true if the value is less than any of the values returned by the subquery.
•         Â
Returns true if the value is less than or equal to the smallest value returned by the subquery.
•         Â
Returns true if the value is less than the smallest value returned by the subquery.
22
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following statements would query the invoice_line table to sum up the totals by multiplying the unit_price with the quantity grouped by track_id?
•         Â
SELECT track_id, (quantity * unit_price) AS total
FROM invoice_line
GROUP BY track_id
ORDER BY total DESC;
•         Â
SELECT track_id, SUM(quantity * unit_price) AS total
FROM invoice_line
ORDER BY total DESC;
•         Â
SELECT track_id, SUM(quantity * unit_price) AS total
FROM invoice_line
GROUP BY track_id
ORDER BY total DESC;
•         Â
SELECT track_id, (quantity / unit_price) AS total
FROM invoice_line
GROUP BY track_id
ORDER BY total DESC;
23
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
What type of situation would you need to create or replace a view?
•         Â
On a daily basis so that the data is refreshed.
•         Â
The view needs to have update, insert, and delete statements allowed.
•         Â
The view is no longer being used.
•         Â
A view has already been created with the same name but needs to be changed.
24
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Animal
animal_id
name
adopter_id
Â
Adopter
adopter_id
name
Â
Given the above data for an adoption agency, what does the result set for the following query represent?
Â
SELECT adopter.name, animal.name
FROM Animal
CROSS JOIN Adopter;
•         Â
It represents all adopters regardless of whether they have claimed an animal in the animal table.
•         Â
It represents each animal, with the name of their adopter if that has been specified via a Foreign Key.
•         Â
It represents every single Animal in the animal table regardless of whether they have been adopted or not.
•         Â
It represents every single animal matches with every single adopter.
25
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
https://postgres.sophia.org/
Which of the following is a correctly formatted SELECT statement to show the following result set with the media type's name and the track's name?
•         Â
SELECT media_type.name, track.name
FROM track
JOIN media_type
ON media_type.media_type_id = track.track_id;
•         Â
SELECT media_type.name, track.name
FROM track
JOIN media_type
ON media_type.media_type.id = track.media_type.id;
•         Â
SELECT media_type.name, track.name
FROM track
JOIN media_type
ON mediatype.media_type_id = track.media_type_id;
•         Â
SELECT media_type.name, track.name
FROM track
JOIN media_type
ON media_type.media_type_id = track.media_type_id;
Â
Â
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
https://postgres.sophia.org/
Which of the following statements will be able to show the following result set?
Â
•         Â
SELECT invoice_id, billing_state, state
FROM invoice, customer;
•         Â
SELECT invoice_id, billing_state, state
FROM inuoice
JOIN consumer
USING (customer_id);
•         Â
SELECT invoice_id, billing_state, state
FROM invoice
WHERE customer_id != NULL;
•         Â
SELECT invoice_id, billing_state, state
FROM invoice
JOIN customer
USING (customer_id);
Â
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following statements would create a UNION between all of the cities we have customers, employees, or invoices in?
•         Â
SELECT billing_city
FROM invoice
SELECT city
FROM customer
SELECT city
FROM employee
UNION;
•         Â
SELECT city
FROM invoice
UNION
SELECT city
FROM customer
UNION
SELECT city
FROM employee;
•         Â
SELECT billing_city
FROM invoice
UNION
SELECT city
FROM customer
UNION
SELECT city
FROM employee;
•         Â
SELECT billing_city
FROM invoice
SELECT city
FROM customer
SELECT city
FROM employee;
Â
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
https://postgres.sophia.org/
Which of the following is a correctly formatted SELECT statement to show the following result set with the track's name, the track's millisecond, and the playlist_track's playlist_id?
•         Â
SELECT name, milliseconds, playlist_id
FROM track
JOIN playlist_track
ON track_id;
•         Â
SELECT name, milliseconds, playlist_id
FROM track
JOIN playlist_track
ON track.trackid = playlisttrack.trackid;
•         Â
SELECT name, milliseconds, playlist_id
FROM track
JOIN playlist_track
ON track.playlist_id = playlist_track.playlist_id;
•         Â
SELECT name, milliseconds, playlist_id
FROM track
JOIN playlist_track
ON track.track_id = playlist_track.track_id;
Â
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following statements would calculate the max bytes per millisecond grouped by the album_id in the track table?
•         Â
SELECT album_id, MAX(bytes/milliseconds)
FROM track
GROUP BY album_id;
•         Â
SELECT album_id, MAX(milliseconds/bytes)
FROM track
GROUP BY album_id;
•         Â
SELECT album_id, MIN(bytes/milliseconds) FROM track
GROUP BY album_id;
•         Â
SELECT album_id, SUM(bytes/milliseconds)
FROM track
GROUP BY album_id;
Â
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
What type of situation would you need to create or replace a view?
•         Â
On a daily basis so that the data is refreshed.
•         Â
The view's underlying data has to be changed to other tables.
•         Â
Data has been imported from other databases.
•         Â
The data in the tables have changed.
Â
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Given the tables have been created without foreign keys added, which of the following ALTER TABLE statements would create a foreign key on the organization_id in the donor table to reference the organization_id in the organization table?
•         Â
ALTER TABLE donor
ADD CONSTRAINT
FOREIGN KEY (organization_id)
REFERENCES organization (organization_id);
•         Â
ALTER TABLE donor
ADD CONSTRAINT fk_donor
FOREIGN KEY organization (organization_id)
REFERENCES organization_id;
•         Â
ALTER TABLE organization
ADD CONSTRAINT fk_donor
FOREIGN KEY (organization_id)
REFERENCES donor (organization_id);
•         Â
ALTER TABLE donor
ADD CONSTRAINT fk_donor
FOREIGN KEY (organization_id)
REFERENCES organization (organization_id);
Â
Â
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Which of the following queries will use a subquery to find all of the rows in the track table that has a unit_price of 0.99 and has the length of the song in milliseconds that is longer than the AVG track length of all tracks in the album_id between 5 and 10?
•         Â
SELECT *
FROM TRACK
WHERE milliseconds >
(SELECT AVG(milliseconds)
FROM track
WHERE unit_price = 0.99)
AND album_id BETWEEN 5 AND 10;
•         Â
SELECT AVG(milliseconds)
FROM TRACK
WHERE milliseconds >
(SELECT *
FROM track
WHERE album_id BETWEEN 5 AND 10)
AND unit_price = 0.99;
•         Â
SELECT *
FROM TRACK
WHERE milliseconds >
SELECT AVG(milliseconds)
FROM track
WHERE album_id BETWEEN 5 AND 10
AND unit_price = 0.99;
•         Â
SELECT *
FROM TRACK
WHERE milliseconds >
(SELECT AVG(milliseconds)
FROM track
WHERE album_id BETWEEN 5 AND 10)
AND unit_price = 0.99;
Â
Â
In each milestone, you may want or need to use the database and query tool to answer some of the questions. We suggest you open the tool in another browser tab while you are working on this assessment.
Â
https://postgres.sophia.org/
Genre
genre_id         name
1Â Â Â Â Â Â Â Â Â Broadway
2Â Â Â Â Â Â Â Â Â Rock
3Â Â Â Â Â Â Â Â Â Classical
4Â Â Â Â Â Â Â Â Â Salsa
Â
Â
Track
track_id          name  genre_id
1         Highway to Hell        2
2         Everlong        2
3         Smells Like Teen Spirit         2
Â
Given the above genres and tracks, how many results will be returned for the following query?
Â
SELECT genre.name, track.name
FROM genre
RIGHT JOIN track
USING (genre_id);
•         Â
5
•         Â
4
•         Â
3
•         Â
6
Â
Â
CIS----------- 11-----------1 S-----------OPH-----------IA------------STR-----------AYE-----------R I-----------ntr-----------odu-----------cti-----------on -----------to -----------Rel-----------ati-----------ona-----------l D-----------ata-----------bas-----------e M-----------ana-----------gem-----------ent----------- Sy-----------ste-----------ms -----------Uni-----------t 2----------- Mi-----------les-----------ton-----------e-s-----------obt-----------ell-----------.co-----------m -----------Cli-----------ck -----------lin-----------k f-----------or -----------Ans-----------wer-----------s A-----------ll -----------Cor-----------rec-----------t-----------