databases and sql for data science with python coursera course answers

Final Exam

1. True or False: The SELECT statement is called a query, and the output we get from executing the query is called a result set.

  • False
  • True

2. Which of the following SQL statements will delete the authors with IDs of A10 and A11?

  • DELETE (‘A10’, ‘A11’) FROM AUTHOR
  • DELETE FROM AUTHOR WHERE AUTHOR_ID IN (‘A10’, ‘A11’)
  • DELETE FROM AUTHOR WHERE AUTHOR_ID IS (‘A10’, ‘A11’)
  • D: DELETE AUTHOR_ID IS (‘A10’, ‘A11’) FROM AUTHOR

3. The primary key of a relational table uniquely identifies each _______ in a table.

  • attribute
  • relation
  • column
  • row

4. The basic categories of the SQL language based on functionality are Data Definition Language (DDL) and _________.

  • Data Input Language (DIL)
  • Data Manipulation Language (DML)
  • Data Entry Language (DEL)
  • Data Update Language (DUL)

5. When querying a table called Representative that contains a list of representatives and the state that they represent, which of the following queries will return the number of representatives from each state?

  • SELECT State, count(State) FROM Representative
  • SELECT State, count(State) FROM Representative GROUP BY State
  • SELECT distinct(State) FROM Representative
  • SELECT State, distinct(State) FROM Representative GROUP BY State

6. You want to retrieve a list of books that have between 450 and 600 pages. Which clause would you add to the following SQL statement: SELECT Title, Pages FROM Book ________________________________

  • IF Pages >= 450 and Pages <= 600
  • WHERE Pages = 450
  • WHERE Pages >= 450 and pages <= 600
  • WHERE Pages 450 – 600

7. Which of the following queries will retrieve the LOWEST value of PRICE in a table called PRODUCTS?

  • SELECT LOWEST(PRICE) FROM PRODUCTS
  • SELECT LEAST(PRICE) FROM PRODUCTS
  • SELECT MIN(PRICE) FROM PRODUCTS
  • SELECT MAX(PRICE) FROM PRODUCTS

8. Which of the following queries will retrieve the last name of the employee who earns the lowest salary?

  • SELECT LAST_NAME FROM EMPLOYEES WHERE SALARY =

    (SELECT MIN(SALARY) FROM EMPLOYEES)

  • SELECT LAST_NAME, MIN(SALARY) FROM EMPLOYEES GROUP BY F_NAME
  • SELECT MIN(SALARY) FROM EMPLOYEES
  • SELECT FIRST_NAME FROM EMPLOYEES WHERE SALARY IS LOWEST

9. A database cursor is a control structure that;

  • Does not allow communication with a database
  • Enables traversal over the records in a database
  • Does not allow you to create tables
  • Does not allow you to update records within a database

10. To query data from tables in database a connection to the database needs to be established. Which of the following is required to establish a connection with a relational database from a Python notebook?

  • Database Name
  • All of the above
  • A SQL or Database API
  • Username and Password

Leave a Reply