Relational Database Sophia Unit 1 Quizzes
Solved 100% Correct
Which of the following is a correctly formatted INSERT statement that will successfully
add a record into the genre table? - ANSWER insert into genre (genre_id, name) values
(30, 'Funk' )
Consider the following new table:
CREATE TABLE contact(user_id SERIAL PRIMARY KEY,phone VARCHAR
NOT NULL);
Given this new table, which INSERT statement would query from the customer table
to insert the phone number of all customers that have an email address that contains
the word "apple" in it? - ANSWER INSERT INTO contact (phone)SELECT phone
FROM customerWHERE email LIKE '%apple%';
Which of the following would set the track name to "A New Road" for the track with a
track_id equal to 5? - ANSWER UPDATE trackset name = 'A New Road'where track_id
=5
, Identify the correctly constructed ALTER TABLE statement to add a UNIQUE constraint
to the column student_number with the constraint name student_number_unique on the
table called 'student'. - ANSWER ALTER TABLE student ADD CONSTRAINT
student_number_unique UNIQUE (student_number);
Using the WHERE and HAVING clauses, filter the track table for the tracks having the
milliseconds greater than 100,000, grouped by the album_id having the number of
tracks greater than 20. Provide the list of album_id's and the count of tracks that fit
these criteria.
Which of the following queries would provide the correct results? - ANSWER SELECT
album_id, count(track_id)FROM trackWHERE milliseconds > 100000GROUP BY
album_idHAVING count(track_id) > 20
Identify the SQL command that uses an aggregate function that could be used to find
the youngest employee in the employee table. - ANSWER SELECT max(birth_date)
FROM employee;
Which of these SELECT statements would successfully display exactly five columns of
data from the customer table? - ANSWER SELECT customer_id, city, state, phone,
companyFROM customer;
Solved 100% Correct
Which of the following is a correctly formatted INSERT statement that will successfully
add a record into the genre table? - ANSWER insert into genre (genre_id, name) values
(30, 'Funk' )
Consider the following new table:
CREATE TABLE contact(user_id SERIAL PRIMARY KEY,phone VARCHAR
NOT NULL);
Given this new table, which INSERT statement would query from the customer table
to insert the phone number of all customers that have an email address that contains
the word "apple" in it? - ANSWER INSERT INTO contact (phone)SELECT phone
FROM customerWHERE email LIKE '%apple%';
Which of the following would set the track name to "A New Road" for the track with a
track_id equal to 5? - ANSWER UPDATE trackset name = 'A New Road'where track_id
=5
, Identify the correctly constructed ALTER TABLE statement to add a UNIQUE constraint
to the column student_number with the constraint name student_number_unique on the
table called 'student'. - ANSWER ALTER TABLE student ADD CONSTRAINT
student_number_unique UNIQUE (student_number);
Using the WHERE and HAVING clauses, filter the track table for the tracks having the
milliseconds greater than 100,000, grouped by the album_id having the number of
tracks greater than 20. Provide the list of album_id's and the count of tracks that fit
these criteria.
Which of the following queries would provide the correct results? - ANSWER SELECT
album_id, count(track_id)FROM trackWHERE milliseconds > 100000GROUP BY
album_idHAVING count(track_id) > 20
Identify the SQL command that uses an aggregate function that could be used to find
the youngest employee in the employee table. - ANSWER SELECT max(birth_date)
FROM employee;
Which of these SELECT statements would successfully display exactly five columns of
data from the customer table? - ANSWER SELECT customer_id, city, state, phone,
companyFROM customer;