sql for data science with r coursera answers week 4

R and Relational Databases

Practice Quiz

1. How can a relational database help R handle memory issues?

  • Using a relational database increases memory use in R.Using a relational database with R has no impact on memory.
  • Using a relational database with R has no impact on memory.
  • Loading all the data from the relational database into a dataframe reduces memory demands.
  • Running SQL queries in a relational database reduces memory demands in the R client.

2. Which R function saves a single data structure to a .Rda file?

  • readRDS()  
  • save.image() 
  • saveRDS()
  • save()

3. A dataframe in R is like which of the following relational database concept?

  • Database
  • Table
  • Schema
  • Column

4. When mapping data types between R and a database, you should consider converting which of the following to strings?

  • Double
  • Logical
  • Factor
  • Date

5. When designing a database and making decisions, which potential issue is not helped by normalization?

  • Transaction processing problems
  • Data redundancy
  • Performance issues
  • Lack of security

Graded Quiz: R and Relational Databases

6. Which amongst the following is the simplest way to update individual observations in a dataframe?

  • There is no way to update individual observations directly in a dataframe.
  • Make the updates in the dataframe and then store the results in a binary format.
  • Convert the dataframe into a text file and make the changes there. 
  • Store the data in a relational database instead and make the updates there. 

7. Which R function loads multiple R data structures from a .Rda file?

  • load()
  • save()
  • save.image() 
  • readRDS()

8. A variable in R is like which of the following relational database concept?

  • Column (or attribute) 
  • Table
  • Schema 
  • Row (or tuple)

9. Which R variable holds the platform numeric limits for your R environment?

  • .Computer
  • .Precision
  • .Numeric 
  • .Machine

10. What is declarative referential integrity?

  • Manages transactions by adhering to the ACID properties.
  • Validates data normalization. 
  • Protects databases from the corruption, destruction, or removal of data.
  • Manages dependency relationships between two tables. 

Connecting to Databases from R

Practice Quiz

11. Which of the following statements about database packages for R are true? Select two answers.

  • DBI-based packages are database server specific. 

  • The RODBC package can only be used with Microsoft database server products.
  • A DBI-based package can be used with many different database servers.
  • The RODBC package can be used with many different database servers. 

12. Which RJDBC function retrieves the content of the result set in the form of a dataframe?

  • fetch
  • print
  • get_data
  • retrieve 

13. The ODBC Driver Manager is:

  • Database server specific 
  • Vendor specific 
  • Platform specific
  • Package specific

14. What are the two steps you must complete outside of R before installing the RODBC package? Select two answers.

  • List the names of the registered DSNs on your database server.
  • Configure the ODBC DSN. 

  • Install the RODBC package from the CRAN website. 
  • Install the ODBC driver for your database server.

15. Which RODBC function returns metadata that can help you preserve data integrity when working with database data in R?

  • sqlER 
  • sqlTypeInfo() 
  • sqlTables()
  • sqlColumns()

Graded Quiz: Connecting to Databases from R

16. What are the two categories of relational database access packages in R?

  • JDBC 
  • ISO SQL/CLI 
  • ODBC

  • Database Interface-Based (DBI)

17. What is the first step you must take before using the RJDBC package for R?

  • Query the database using a SELECT statement.
  • Create a connection object for a database on a remote server. 
  • Load the RJDBC library.
  • Load the DB2 JDBC type 4 driver and create a driver object. 

18. Which of the following is one of the two components of ODBC?

  • Data sources 
  • Registered DNS
  • ODBC Driver Manager
  • ODBC Runtime Environment

19. Which SQL command returns the list of registered DSNs?

  • names()
  • print()
  • registered()
  • odbcDataSources()

20. Which RODBC function does NOT help you learn about the schema of your database?

  • odbcGetInfo() 
  • sqlTypeInfo()
  • sqlColumns() 
  • sqlTables()

Leave a Reply