sql for data science with r coursera answers week 1
Practice Quiz
1. Which of the following statements are correct about databases?
- A database can be populated with data and be queried
- There are different types of databases – Relational, Hierarchical, No SQL, etc.
- All of the above
- A database is a repository of data
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 DINSTINCT clause to specify a distinct year.
- A LIMIT clause to limit the results to films released in 2019.
- Nothing, the query is correct.
- A WHERE clause to limit the results to films released in 2019.
4. Which of the following statements would you use to add a new instructor to the Instructor table.
INSERT INTO Instructor(ins_id, lastname, firstname, city, country)
VALUES(4, ‘Doe’, ‘John’, ‘Sydney’, ‘AU’);
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’);
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 is never used with an UPDATE statement.
- A WHERE clause enables you to specify a new table to receive the updates.
- 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.
Graded Quiz: Basic SQL
6. True or False: The SELECT statement is called a query, and the output we get from executing the query is called a result set.
- True
- False
7. True or False: The INSERT statement can be used to insert multiple rows in a single statement.
- True
- False
8. 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
9. 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.
10. Which of the following SQL statements will delete the authors with IDs of A10 and A11?
- DELETE FROM AUTHOR WHERE AUTHOR_ID IS (‘A10’, ‘A11’)
- DELETE FROM AUTHOR WHERE AUTHOR_ID IN (‘A10’, ‘A11’)
- DELETE (‘A10’, ‘A11’) FROM AUTHOR
- D: DELETE AUTHOR_ID IS (‘A10’, ‘A11’) FROM AUTHOR