databases and sql for data science with python coursera week 1 quiz answers
Practice Quiz
1. Which of the following statements are correct about databases?
- A database is a repository of data
- There are different types of databases – Relational, Hierarchical, No SQL, etc.
- A database can be populated with data and be queried
- All of the above
2. True or False: A SELECT statement is used to retrieve data from a table.
- True
- False
3. You are working on a Film database, with a FilmLocations table. You want to retrieve a list of films that were released in 2019.You run the following query but find that all the films in the FilmLocations table are listed.
SELECT Title,ReleaseYear, Locations FROMFilmLocations;
What is missing?
- A WHERE clause to limit the results to films released in 2019.
- A LIMIT clause to limit the results to films released in 2019.
- Nothing, the query is correct.
- A DINSTINCT clause to specify a distinct year.
4. Which of the following statements would you use to add a new instructor to the Instructor table.
ADD INTO Instructor(ins_id, lastname, firstname, city, country)
VALUES(4, ‘Doe’, ‘John’, ‘Sydney’, ‘AU’);
UPDATE Instructor(ins_id, lastname, firstname, city, country)
WITH VALUES(4, ‘Doe’, ‘John’, ‘Sydney’, ‘AU’);
INSERT INTO Instructor(ins_id, lastname, firstname, city, country)
VALUES(4, ‘Doe’, ‘John’, ‘Sydney’, ‘AU’);
SELECT Instructor(ins_id, lastname, firstname, city, country)
FROM VALUES(4, ‘Doe’, ‘John’, ‘Sydney’, ‘AU’);
5. What is the function of a WHERE clause in an UPDATE statement?
- A WHERE clause enables you to list the column and data to be updated.
- A WHERE clause enables you to specify which rows will be updated.
- A WHERE clause enables you to specify a new table to receive the updates.
- A WHERE clause is never used with an UPDATE statement.
Graded Quiz: Basic SQL
6. True or False: The INSERT statement can be used to insert multiple rows in a single statement.
- True
- False
7. Assume there exists an INSTRUCTOR table with several columns including FIRSTNAME, LASTNAME, etc. Which of the following is the most likely result set for the following query:
SELECT DISTINCT(FIRSTNAME) FROM INSTRUCTOR
LEON
LEON
PAUL
PAUL
LEON
PAUL
JOE
LEON
PAUL
LEON
JOE
LEON KATSNELSON
PAUL ZIKOPOLOUS
JOE SANTARCANGELO
8. What does the following SQL statement do?
UPDATE INSTRUCTOR SET LASTNAME = 'Brewster' WHERE LASTNAME = 'Smith'
- Changes all rows for the instructor with a last name of Smith to have a last name of Brewster.
- Change the row for the instructor with a last name of Brewster to have a last name of Smith.
- Change all rows in the table to have a last name of Smith.
- Change all rows in the table to have a last name of Brewster.