Clicker Questions

to go with Modern Data Science with R, 3rd edition by Baumer, Kaplan, and Horton.

Many questions taken directly from * w3schools SQL quiz. * Java Guides * study.com


  1. What is a SQL server?.1
    1. A relational database management system.
    2. A software whose main purpose is to store and retrieve data.
    3. A highly secure server and does not allow any database file manipulation during execution.
    4. All of the above.

  1. When was SQL created?2
    1. 1960s
    2. 1970s
    3. 1980s
    4. 1990s
    5. 2000s

  1. What type of databases is SQL designed for?3
    1. hierarchical database management systems.
    2. network database management systems.
    3. object-oriented database management systems.
    4. relational database management systems.

  1. Which is bigger:4
    1. computer’s hard drive / storage
    2. computer’s memory / RAM

  1. Where are each stored?5
    1. SQL tbl and R tibble both in storage
    2. SQL tbl and R tibble both in memory
    3. SQL tbl in storage and R tibble in memory
    4. SQL tbl in memory and R tibble in storage

  1. Which SQL clause is used to extract data from a database?6
    1. OPEN
    2. EXTRACT
    3. SELECT
    4. GET

  1. With SQL, how to you retrieve a column named “FirstName” from a table named “Persons”?7
    1. SELECT Persons.FirstName
    2. EXTRACT FIRSTNAME FROM Persons
    3. SELECT FirstName FROM Persons
    4. SELECT “FirstName” FROM “Persons”

  1. With SQL, how do you select all the columns from a table named “Persons”?8
    1. SELECT Persons
    2. SELECT * FROM Persons
    3. SELECT [all] FROM Persons
    4. SELECT *.Persons

  1. With SQL, how can you return the number of records in the “Persons” table?9
    1. SELECT COLUMNS(*) FROM Persons
    2. SELECT COUNT(*) FROM Persons
    3. SELECT NO(*) FROM Persons
    4. SELECT LEN(*) FROM Persons

  1. With SQL, how do you select all the records from a table named “Persons” where the value of the column “FirstName” is “Peter”?10
  1. SELECT * FROM Persons WHERE FirstName <> ‘Peter’
  2. SELECT * FROM Persons WHERE FirstName = ‘Peter’
  3. SELECT * FROM Persons WHERE FirstName == ‘Peter’
  4. SELECT [all] FROM Persons WHERE FirstName LIKE ‘Peter’
  5. SELECT [all] FROM Persons WHERE FirstName = ‘Peter’

  1. With SQL, how do you select all the records from a table named “Persons” where the “FirstName” is “Peter” and the “LastName” is “Jackson”?11
  1. SELECT FirstName = ‘Peter’, LastName = ‘Jackson’ FROM Persons
  2. SELECT * FROM Persons WHERE FirstName <> ‘Peter’ AND LastName <> ‘Jackson’
  3. SELECT * FROM Persons WHERE FirstName = ‘Peter’ AND LastName = ‘Jackson’
  4. SELECT * FROM Persons WHERE FirstName == ‘Peter’ AND LastName == ‘Jackson’

  1. Which operator selects values within a range?12
    1. BEWTEEN
    2. WITHIN
    3. RANGE

  1. With SQL, how do you select all the records from a table named “Persons” where the “LastName” is alphabetically between (and including) “Hansen” and “Pettersen”?13
    1. SELECT LastName > ‘Hansen’ AND LastName < ‘Pettersen’ FROM Persons
    2. SELECT * FROM Persons WHERE LastName BETWEEN ‘Hansen’ AND ‘Pettersen’
    3. SELECT * FROM Persons WHERE LastName > ‘Hansen’ AND LastName < ‘Pettersen’

  1. Which SQL statement returns only different values?14
    1. SELECT UNIQUE
    2. SELECT DISTINCT
    3. SELECT DIFFERENT

  1. Which SQL keyword is used to sort the result-set?15
    1. ORDER BY
    2. ORDER
    3. SORT
    4. SORT BY

  1. With SQL, how can you return all the records from a table named “Persons” sorted descending by “FirstName”?16
    1. SELECT * FROM Persons ORDER FirstName DESC
    2. SELECT * FROM Persons SORT ‘FirstName’ DESC
    3. SELECT * FROM Persons ORDER BY FirstName DESC
    4. SELECT * FROM Persons SORT BY ‘FirstName’ DESC

  1. The OR operator displays a record if ANY conditions listed are true. The AND operator displays a record if ALL of the conditions listed are true.17
    1. TRUE
    2. FALSE

  1. In order to SELECT the records with foods that are either green or yellow fruit:18
    1. WHERE type = ‘fruit’ AND color = ‘yellow’ OR color = ‘green’
    2. WHERE (type = ‘fruit’ AND color = ‘yellow’) OR color = ‘green’
    3. WHERE type = ‘fruit’ AND (color = ‘yellow’ OR color = ‘green’)
    4. WHERE type = ‘fruit’ AND color = ‘yellow’ AND color = ‘green’
    5. WHERE type = ‘fruit’ AND (color = ‘yellow’ AND color = ‘green’)

  1. What is the purpose of a JOIN?19
    1. it filters the rows returned by the SELECT statement.
    2. it specifies the columns to be retrieved.
    3. it combines rows from two or more tables based on a related column.
    4. it orders the results in ascending or descending order.

  1. What is the purpose of the UNION operator in SQL?20
    1. it combines the results of two or more SELECT statements.
    2. it performs a pattern match on a string.
    3. it retrieves the maximum value in a column.
    4. it filters the rows returned by the SELECT statement.

  1. What is the purpose of the INNER JOIN in SQL?21
    1. it retrieves the maximum value in a column.
    2. it combines rows from two or more tables based on a related column.
    3. it filters the rows returned by the SELECT statement.
    4. it performs a pattern match on a string.

  1. What is the purpose of the LEFT JOIN in SQL?22
    1. it combines rows from two or more tables based on a related column.
    2. it retrieves the maximum value in a column.
    3. it filters the rows returned by the SELECT statement.
    4. it performs a pattern match on a string.

  1. RIGHT JOIN keeps all the rows in …?23
    1. the first table.
    2. the second table.
    3. both tables.
    4. neither table

  1. Who is removed in a RIGHT JOIN?24
    1. Mick
    2. John
    3. Paul
    4. Keith


  1. Which variable(s) are removed in a RIGHT JOIN?25
    1. name
    2. band
    3. plays
    4. none of them


  1. In SQL, what happens to Mick’s “plays” variables in a FULL JOIN?26
    1. Mick is removed
    2. guitar
    3. bass
    4. NA
    5. NULL


  1. grep("q[^u]", very.large.word.list) would not match which of the following?27
    1. Iraqi
    2. Iraqian
    3. Iraq
    4. zaqqun (tree that “springs out of the bottom of Hell”, in the Quran)
    5. Qantas (the Australian airline)

  1. Which of the following regex would match to both “grey” and “gray”?28
    1. “gr[ae]y”
    2. “gr(a|e)y”
    3. “gray | grey”
    4. “gr[a|e]y”
    5. some / all of the above – which ones?

  1. What will the result be for the following code?29
    1. 10
    2. 1
    3. 0
    4. NA
str_extract("My dog is 10 years old", "\\d")

  1. What will the result be for the following code?30
    1. 10
    2. 1
    3. 0
    4. NA
str_extract("My dog is 10 years old", "\\d+")

  1. What will the result be for the following code?31
    1. .
    2. Episode 2: The pie whisperer. (4 August 2015)
    3. Episode
    4. E
str_extract("Episode 2: The pie whisperer. (4 August 2015)", ".")

  1. What will the result be for the following code?32
    1. .
    2. Episode 2: The pie whisperer. (4 August 2015)
    3. Episode
    4. E
str_extract("Episode 2: The pie whisperer. (4 August 2015)", ".+")

  1. What will the result be for the following code?33
    1. .
    2. Episode 2: The pie whisperer. (4 August 2015)
    3. Episode
    4. E
str_extract("Episode 2: The pie whisperer. (4 August 2015)", "\\.")

  1. How can I pull out just the numerical information in $47?34
    1. “(?<=\$)\d”
    2. “(?<=\$)\d+”
    3. “\d(?=\$)”
    4. “\d+(?=\$)”

  1. You want to know all the types of pies in the text strings. They are written as, for example “apple pie”.35
    1. “\w+(?!pie)”
    2. “\w+(?! pie)”
    3. “\w+(?=pie)”
    4. “\w+(?= pie)”

str_extract(c("apple pie", "chocolate pie", "peach pie"), "\\w+(?= pie)")
[1] "apple"     "chocolate" "peach"    
str_extract(c("apple pie", "chocolate pie", "peach pie"), "\\w+(?=pie)")
[1] NA NA NA

  1. We say that lookarounds are “zero-lenghth assertions”. What does that mean?36
    1. we return the string in the lookaround
    2. we replace the string in the lookaround
    3. we return the string at the lookaround
    4. we replace the string at the lookaround

  1. With SQL, how do you select all the records from a table named “Persons” where the value of the column “FirstName” starts with an “a”?37
    1. SELECT * FROM Persons WHERE FirstName = ’a.*’
    2. SELECT * FROM Persons WHERE FirstName = ’a*’
    3. SELECT * FROM Persons WHERE FirstName REGEXP ’a.*’
    4. SELECT * FROM Persons WHERE FirstName REGEXP ’a*’
    5. SELECT * FROM Persons WHERE FirstName REGEXP ’(?i)a.*’

  1. What is the main way to absolutely recognize a record within a database?38
    1. Foreign key
    2. Primary key
    3. Unique key
    4. Natural key
    5. Alternate key

  1. What does a foreign key do?39
    1. Directly identifies another table
    2. Directly identifies another column
    3. Gives access to another entire database
    4. Translates the database into another language

  1. Which of these would likely be used as a foreign key between a table on student enrollment and student grades?40
    1. grades
    2. tuition
    3. student_name
    4. student_hometown

  1. For the student records (for two tables: enrollment and grades), which is the most likely combination?41
    1. name as primary key to both
    2. name as foreign to both
    3. name as primary in enrollment and foreign in grades
    4. name as foreign in enrollment and primary in grades

  1. Which SQL statement is used to create a database table called ‘Customers’?42
    1. CREATE DATABASE TAB Customers
    2. CREATE DATABASE Customers
    3. CREATE DATABASE TABLE Customers
    4. CREATE TABLE Customers
    5. CREATE DB Customers

  1. Which SQL statement revises data in a database?43
    1. SAVE AS
    2. MODIFY
    3. SAVE
    4. UPDATE

  1. Which SQL statement takes out data from a database?44
    1. REMOVE
    2. DELETE
    3. COLLAPSE

  1. The NOT NULL constraint enforces a column to not accept NULL values.45
    1. FALSE
    2. TRUE

  1. Which SQL statement places new data in a database?46
    1. ADD RECORD
    2. INSERT INTO
    3. ADD NEW
    4. INSERT NEW

  1. With SQL, how can you insert a new record into the “Persons” table?47
    1. INSERT INTO Persons VALUES (‘Jimmy’, ‘Jackson’)
    2. INSERT (‘Jimmy’, ‘Jacskon’) INTO Persons
    3. INSERT VALUES (‘Jimmy’, ‘Jackson’) INTO Persons

  1. With SQL, how can you insert “Olsen” as the “LastName” in the “Persons” table?48
    1. INSERT INTO Persons (LastName) VALUES (‘Olsen’)
    2. INSERT INTO Persons (’Olsen) INTO LastName
    3. INSERT (‘Olsen’) INTO Persons (LastName)

  1. How can you change “Hansen” into “Nilsen” in the “LastName” column in the Persons table?49
    1. MODIFY Persons SET LastName=‘Nilsen’ WHERE LastName=‘Hansen’
    2. UPDATE Persons SET LastName=‘Hansen’ INTO LastName=‘Nilsen’
    3. MODIFY Persons SET LastName=‘Hansen’ INTO LastName=‘Nilsen’
    4. UPDATE Persons SET LastName=‘Nilsen’ WHERE LastName=‘Hansen’

  1. With SQL, how can you delete the records where the “FirstName” is “Peter” in the Persons Table?50
    1. DELETE FROM Persons WHERE FirstName=‘Peter’
    2. DELETE FirstName=‘Peter’ FROM Persons
    3. DELETE ROW FirstName=‘Peter’ FROM Persons

  1. In the flights table, the following INDEXes exist: Tailnum, Year, and Date. How many rows would be looked through if the WHERE filter was on month only?51
    1. more than 6.3 million
    2. less than 6.3 million
    3. more than 700,000
    4. less than 700,000

  1. Which has a larger cardinality, Tailnum or Year?52
    1. Tailnum
    2. Year
    3. they have the same cardinality
    4. neither has a cardinality

  1. Which index takes up more storage space, the one on Tailnum or the one on Year?53
    1. Tailnum
    2. Year
    3. they take up the same space
    4. you can’t index on either variable

  1. Which index is more effective at reducing querying time, the one on Tailnum or the one on Year?54
    1. Tailnum
    2. Year
    3. the queries would be the same
    4. you can’t query on either variable

  1. What does the R function ifelse(a, b, c) do?55
    1. a = TRUE option, b = FALSE option, c = question
    2. a = FALSE option, b = TRUE option, c = question
    3. a = question, b = TRUE option, c = FALSE option
    4. a = question, b = FALSE option, c = TRUE option

  1. What does the R function case_when() do?56
    1. renames a variable
    2. changes the data type of a variable
    3. partitions a numeric variable
    4. creates a new variable by re-coding an original variable

  1. What does the R function cut() do?57
    1. renames a variable
    2. changes the data type of a variable
    3. partitions a numeric variable
    4. creates a new variable by re-coding an original variable

Footnotes

    1. A relational database management system.
    ↩︎
    1. The first versions were created in the 1970s and called SEQUEL (Structured English QUEry Language). c. SQL came about in particular systems in the 1980s.
    ↩︎
    1. relational database management systems.
    ↩︎
    1. computer’s hard drive / storage
    ↩︎
    1. SQL tbl in storage and R tibble in memory
    ↩︎
    1. SELECT
    ↩︎
    1. SELECT FirstName FROM Persons
    ↩︎
    1. SELECT * FROM Persons
    ↩︎
    1. SELECT COUNT(*) FROM Persons
    ↩︎
    1. SELECT * FROM Persons WHERE FirstName = ‘Peter’ (d. would also work.)
    ↩︎
    1. SELECT * FROM Persons WHERE FirstName = ‘Peter’ AND LastName = ‘Jackson’
    ↩︎
    1. BEWTEEN
    ↩︎
    1. SELECT * FROM Persons WHERE LastName BETWEEN ‘Hansen’ AND ‘Pettersen’
    ↩︎
    1. SELECT DISTINCT
    ↩︎
    1. ORDER BY
    ↩︎
    1. SELECT * FROM Persons ORDER BY FirstName DESC
    ↩︎
    1. TRUE
    ↩︎
    1. WHERE type = ‘fruit’ AND (color = ‘yellow’ OR color = ‘green’)
    ↩︎
    1. it combines rows from two or more tables based on a related column.
    ↩︎
    1. it combines the results of two or more SELECT statements.
    ↩︎
    1. it combines rows from two or more tables based on a related column.
    ↩︎
    1. it combines rows from two or more tables based on a related column.
    ↩︎
    1. the first table
    ↩︎
    1. Mick
    ↩︎
    1. none of them (all variables are kept in all joins)
    ↩︎
    1. NULL (it would be NA in R)
    ↩︎
  1. neither c. nor e. would match. Inside the bracket “[^u]” matches anything other than a “u”, but it has to match something.↩︎

    1. all of the above. Inside a character class | is a normal character and would therefore match “grey” and “gray” and “gr|y”. Which is not what we want, but would work to match both “grey” and “gray”.
    ↩︎
    1. 1 (because \d matches only a single digit).
    ↩︎
    1. 10 (because \d+ matches at least one digit).
    ↩︎
    1. E (because . matches anything, and returns only a single character).
    ↩︎
    1. Episode 2: The pie whisperer. (4 August 2015) (because . matches anything, and with the + it returns multiple characters).
    ↩︎
    1. . (because \. matches the period, .).
    ↩︎
    1. “(?<=\$)\d+”
    ↩︎
    1. “\w+(?= pie)”
    ↩︎
    1. we return the string at the lookaround
    ↩︎
    1. SELECT * FROM Persons WHERE FirstName REGEXP ’(?i)a.*’ (n.b., the LIKE function will give you a similar result, with % as a wildcard: SELECT*FROMPersonsWHERE` FirstName LIKE ‘a%’)
    ↩︎
    1. Primary key
    ↩︎
    1. Directly identifies another column
    ↩︎
    1. student_name
    ↩︎
    1. name as primary in enrollment and foreign in grades (the primary key must uniquely identify the records, and name is unlikely to do that in a grades database.)
    ↩︎
    1. CREATE TABLE Customers
    ↩︎
    1. UPDATE
    ↩︎
    1. DELETE
    ↩︎
    1. TRUE
    ↩︎
    1. INSERT INTO
    ↩︎
    1. INSERT INTO Persons VALUES (‘Jimmy’, ‘Jackson’)
    ↩︎
    1. INSERT INTO Persons (LastName) VALUES (‘Olsen’)
    ↩︎
    1. UPDATE Persons SET LastName=‘Nilsen’ WHERE LastName=‘Hansen’
    ↩︎
    1. DELETE FROM Persons WHERE FirstName=‘Peter’
    ↩︎
    1. more than 6.3 million. Because there is no index on month (and we don’t have a year to incorporate month into the Date index), we need to look through all 48 million rows.
    ↩︎
    1. Tailnum. The cardinality is the number of unique values, and there are many more unique planes than years.
    ↩︎
    1. Tailnum. Because the cardinality is higher, it will take up much more space in the index.
    ↩︎
    1. Tailnum. Because the index is more complete, it will make the querying more efficient.
    ↩︎
    1. a = question, b = TRUE option, c = FALSE option
    ↩︎
    1. creates a new variable by re-coding an original variable
    ↩︎
    1. partitions a numeric variable
    ↩︎

Reuse