Coursera Answers

Building Database Applications in PHP Week 2 Practice Quiz Answer

Building Database Applications in PHP Week 2 Quiz Answer

Building Database Applications in PHP 

Week 2 Practice Quiz Answer

PDO



Question 1)

Why is it important to have extensive error checking on SQL statements when an application is in production?


  • Tracebacks make your application look bad
  • The developer/production team needs good detail on any errors
  • Users will rarely report errors and never give enough detail
  • Some errors are subtle and only show up very rarely
  • All of the above




Question 2)

What is the purpose of the PDO::errorinfo() data?


  • It combines the prepare() and execute() phases of PDO into a single call
  • It allows you to choose the style of error handling for your application
  • It allows you to register a callback function to be called in case of an unhandled error
  • It gives extended detail when a PDO function returns an error




Question 3)

How is a LEFT JOIN different from a regular JOIN?


  • In a LEFT JOIN rows can come from either the left table or right table as long as the row matches the WHERE clause
  • All of the text fields are left aligned in the result set
  • In a LEFT JOIN rows are included form the left table even if there is no matching row in the right table
  • You do not need an ON clause for the LEFT JOIN




Question 4)

What is a common use of GROUP BY in SQL?


  • When combined with the COUNT function, it provides a way to compute sub-totals
  • It is a faster way to sort fields than ORDER BY
  • It is a way to choose which rows from a JOINed table are to be included in a result set
  • It allows a result set to be broken into 20 row chunks for efficiency




Question 5)

Why do subqueries have the potential to cause a query to execute slowly?


  • Because subqueries don’t make use of indexes
  • Because subqueries cannot use integer foreign keys
  • Because subqueries must include all of the fields that are selected by the main query
  • Because MySQL executes the subquery independently from the main query