Introduction to Structured Query Language (SQL) Quiz Answers

Introduction to Structured Query Language (SQL) Week 01 Quiz Answers

Q1. DBA stands for

  • Database administrator

Q2. Structured Query Language (SQL) is used to (check all that apply)

  • Delete data
  • Insert data
  • Create a table
  • Run php

Q3. Which statement is the right syntax to make a new database using command line?

  • CREATE people;
  • MAKE DATASET people;
  • MAKE people;
  • CREATE DATABASE people;

Q4. “INSERT INTO” is the keyword used to insert data into tables.

  • True
  • False

Q5. Which keyword is used to add conditions to your query?

  • IF
  • WHERE
  • ONLYIF
  • SELECT

Q6. Which command is used to retrieve all records from the table?

  • SELECT all FROM Users
  • RETRIVE * FROM Users
  • RETRIVE all FROM Users
  • SELECT * FROM Users

Q7. Which keyword will cause the results of the query to be displayed in sorted order?

  • WHERE
  • GROUP BY
  • ORDER BY
  • None of these

Q8he LIMIT clause helps to narrow down the scope of the query.

  • True
  • False

Q9.A [_____] column allocates a string with a variable amount of space depending on the data length that is actually stored.

  • varchar

Q10. A column of type CHAR cannot be indexed.

  • True
  • False

Q11. Images, PDF, movies cannot be stored in a database.

  • True
  • False

Q12. Column of type TIMESTAMP stores the number of seconds from January 1, [_____] in the column.

  • 1970

Q13. A primary key can be set to null.

  • True
  • False

Q14. An UNSIGNED int can be a negative number.

  • True
  • False

Q15. Primary keys are used to distinguish rows within in a table. [_____] keys are used to reference the primary key from a different table.

  • foreign

Introduction to Structured Query Language (SQL) Week 02 Quiz Answers

Q1. 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

Q2. 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

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. 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

Q15. 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
Get All Course Quiz Answers of Web Applications for Everybody Specialization

Building Web Applications in PHP Coursera Quiz Answers

Introduction to Structured Query Language (SQL) Quiz Answers

Building Database Applications in PHP Coursera Quiz Answers

JavaScript, jQuery, and JSON Coursera Quiz Answers

Share your love

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Your email address will not be published. Required fields are marked *