Introduction to Structured Query Language (SQL) complete course is currently being offered by University of Michigan through Coursera platform.

This course is part of the Web Applications for Everybody Specialization.

About this Course

In this course, you'll walk through installation steps for installing a text editor, installing MAMP or XAMPP (or equivalent) and creating a MySql Database. You'll learn about single table queries and the basic syntax of the SQL language, as well as database design with multiple tables, foreign keys, and the JOIN operation. Lastly, you'll learn to model many-to-many relationships like those needed to represent users, roles, and courses.

SKILLS YOU WILL GAIN

Phpmyadmin
- MySQL
- Relational Database
- SQL


Introduction to Structured Query Language (SQL) Quiz Answers - Coursera!

Coursera - Introduction to Structured Query Language (SQL) Week 2 Quiz Answers

Database Models

Q1. Which of the following is NOT a good rule to follow when developing a database model?

  • Each “object” in the application should be modeled as one or more tables
  • Use integers as primary keys
  • Never repeat string data in more than one table in a data model
  • Use a persons email address as their primary key

Q2. What is the primary value add of relational databases over flat files?

  • Ability to scan large amounts of data quickly
  • Ability to execute PHP code within the file
  • Ability to execute JavaScript in the file
  • Ability to quickly convert data to HTML
  • Ability to store data in a format that can be sent across a network

Q3. If our user interface (i.e. like iTunes) has repeated strings on one column of the UI, how should we model this properly in a database:

  • We put the string in the first row it occurs and then put that row number in the column all of the rest of the rows where the string occurs
  • We make a table that maps the strings in the column to numbers and then use those numbers in the column
  • We put the string in the first row where it occurs and then NULL in all of the other rows
  • Encode the entire row as JSON and store it in a TEXT column in the database
  • We put the string in the last row where it occurs and put the number of that row in the column all of the rest of the rows where the string occurs

Q4. Which of the following is the label we give a column that the “outside world” uses to look up a particular row?

  • Logical key
  • Local key
  • Foreign key
  • Remote key
  • Primary key

Q5. What is the label we give to a column that is an integer and used to point to a row in a different table?

  • Local key
  • Remote key
  • Primary key
  • Logical key
  • Foreign key

Q6. What MySQL keyword is added to primary keys in a CREATE TABLE statement to indicate that the database is to provide a value for the column when records are inserted.

  • INSERT_AUTO_PROVIDE
  • AUTO_INCREMENT
  • PRIMARY
  • ASSERT_UNIQUE

Q7. What is the SQL keyword that reconnects rows with foreign keys with the corresponding data in the table that the foreign key points to?

  • CONNECT
  • JOIN
  • APPEND
  • CONSTRAINT
  • COUNT

Q8. What happens when you JOIN two tables together without an ON clause?

  • The rows of the left table are connected to the rows in the right table when their primary key matches
  • The number of rows you get is the number of rows in the first table times the number of rows in the second table
  • You get all of the rows of the left table in the JOIN and NULLs in all of the columns of the right table
  • Leaving out the ON clause when joining two tables is an SQL syntax error
  • You get no rows at all

Q9. What does an “ON DELETE CASCADE” clause imply in a foreign key constraint in a MySQL CREATE TABLE statement?

  • When a row in the parent table is deleted all the rows in a child table that point to that row via a foreign key are deleted
  • Whenever a row is deleted from the table, the other rows are scanned to insure that the logical key is unique and any duplicates are removed
  • Whenever a row is deleted, it is moved into a table named “CASCADE”
  • When rows in a child table are deleted, the primary key of the corresponding row in the parent table is set to NULL

Q10. Which of the following types of tables often are created without a primary key?

  • Many-to-many
  • One-to-one
  • B-Trees
  • Hash Map
  • One-to-many

Q11. When might one prefer the CHAR column type over VARCHAR?

  • When the data needs to be searched using a LIKE clause
  • When the data has widely varying lengths
  • When the data is prose like a discussion comment versus a logical key
  • When the data is relatively short and almost always present

Q12. What is the built-in MySQL function that gives you the current time in an SQL statement?

  • TODAY()
  • CURR_DATE()
  • DATE(false)
  • NOW()

Q13. Which of the following indexes would be best for fast look up for exact key matches but not so good for prefix lookups or sorting?

  • HASH
  • INDEX2
  • BTREE
  • EXACT

Q14. When you add an index to a field in a database table, how are performance and storage affected?

  • Read performance is faster, insert performance is slower and extra storage is required
  • Read performance is the faster, insert performance is faster and extra storage is required
  • Read performance is faster, insert performance is the same and no extra storage is required
  • Read performance is the same, insert performance is faster and no extra storage is required

Q15. Why is it a good idea to add “CONSTRAINT FOREIGN KEY” statements when creating database tables? (Check all that apply)

  • So that database modeling tools know the relationships between tables
  • So that MySql knows which columns are foreign keys and which columns are just integers
  • So that you can specify default behaviors when records are deleted or updated
  • So that prefix-based lookups perform well

Post a Comment

Previous Post Next Post