
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
- What is a SQL server?.1
- A relational database management system.
- A software whose main purpose is to store and retrieve data.
- A highly secure server and does not allow any database file manipulation during execution.
- All of the above.
 
- When was SQL created?2
- 1960s
- 1970s
- 1980s
- 1990s
- 2000s
 
- What type of databases is SQL designed for?3
- hierarchical database management systems.
- network database management systems.
- object-oriented database management systems.
- relational database management systems.
 
- Which is bigger:4
- computer’s hard drive / storage
- computer’s memory / RAM
 
- Where are each stored?5
- SQL tbland Rtibbleboth in storage
- SQL tbland Rtibbleboth in memory
- SQL tblin storage and Rtibblein memory
- SQL tblin memory and Rtibblein storage
 
- SQL 
- Which SQL clause is used to extract data from a database?6
- OPEN
- EXTRACT
- SELECT
- GET
 
- With SQL, how to you retrieve a column named “FirstName” from a table named “Persons”?7
- SELECTPersons.FirstName
- EXTRACT FIRSTNAME FROMPersons
- SELECTFirstName- FROMPersons
- SELECT“FirstName”- FROM“Persons”
 
- With SQL, how do you select all the columns from a table named “Persons”?8
- SELECTPersons
- SELECT*- FROMPersons
- SELECT[all]- FROMPersons
- SELECT*.Persons
 
- With SQL, how can you return the number of records in the “Persons” table?9
- SELECT- COLUMNS(*)- FROMPersons
- SELECT- COUNT(*)- FROMPersons
- SELECT- NO(*)- FROMPersons
- SELECT- LEN(*)- FROMPersons
 
- With SQL, how do you select all the records from a table named “Persons” where the value of the column “FirstName” is “Peter”?10
- SELECT*- FROMPersons- WHEREFirstName <> ‘Peter’
- SELECT*- FROMPersons- WHEREFirstName = ‘Peter’
- SELECT*- FROMPersons- WHEREFirstName == ‘Peter’
- SELECT[all]- FROMPersons- WHEREFirstName- LIKE‘Peter’
- SELECT[all]- FROMPersons- WHEREFirstName = ‘Peter’
- 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
- SELECTFirstName = ‘Peter’, LastName = ‘Jackson’- FROMPersons
- SELECT*- FROMPersons- WHEREFirstName <> ‘Peter’ AND LastName <> ‘Jackson’
- SELECT*- FROMPersons- WHEREFirstName = ‘Peter’ AND LastName = ‘Jackson’
- SELECT*- FROMPersons- WHEREFirstName == ‘Peter’ AND LastName == ‘Jackson’
- Which operator selects values within a range?12
- BEWTEEN
- WITHIN
- RANGE
 
- 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
- SELECTLastName > ‘Hansen’ AND LastName < ‘Pettersen’- FROMPersons
- SELECT*- FROMPersons- WHERELastName BETWEEN ‘Hansen’ AND ‘Pettersen’
- SELECT*- FROMPersons- WHERELastName > ‘Hansen’ AND LastName < ‘Pettersen’
 
- Which SQL statement returns only different values?14
- SELECT- UNIQUE
- SELECT- DISTINCT
- SELECT- DIFFERENT
 
- Which SQL keyword is used to sort the result-set?15
- ORDER BY
- ORDER
- SORT
- SORT BY
 
- With SQL, how can you return all the records from a table named “Persons” sorted descending by “FirstName”?16
- SELECT*- FROMPersons- ORDERFirstName- DESC
- SELECT*- FROMPersons- SORT‘FirstName’- DESC
- SELECT*- FROMPersons- ORDER BYFirstName- DESC
- SELECT*- FROMPersons- SORT BY‘FirstName’- DESC
 
- 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
- TRUE
- FALSE
 
- In order to SELECTthe records with foods that are either green or yellow fruit:18- … WHEREtype = ‘fruit’ AND color = ‘yellow’ OR color = ‘green’
 
- … WHERE(type = ‘fruit’ AND color = ‘yellow’) OR color = ‘green’
 
- … WHEREtype = ‘fruit’ AND (color = ‘yellow’ OR color = ‘green’)
 
- … WHEREtype = ‘fruit’ AND color = ‘yellow’ AND color = ‘green’
 
- … WHEREtype = ‘fruit’ AND (color = ‘yellow’ AND color = ‘green’)
 
- … 
- What is the purpose of a JOIN?19- it filters the rows returned by the SELECTstatement.
- it specifies the columns to be retrieved.
- it combines rows from two or more tables based on a related column.
- it orders the results in ascending or descending order.
 
- it filters the rows returned by the 
- What is the purpose of the UNIONoperator in SQL?20- it combines the results of two or more SELECTstatements.
- it performs a pattern match on a string.
- it retrieves the maximum value in a column.
- it filters the rows returned by the SELECTstatement.
 
- it combines the results of two or more 
- What is the purpose of the INNER JOINin SQL?21- it retrieves the maximum value in a column.
- it combines rows from two or more tables based on a related column.
- it filters the rows returned by the SELECTstatement.
- it performs a pattern match on a string.
 
- What is the purpose of the LEFT JOINin SQL?22- it combines rows from two or more tables based on a related column.
- it retrieves the maximum value in a column.
- it filters the rows returned by the SELECTstatement.
- it performs a pattern match on a string.
 
- RIGHT JOINkeeps all the rows in …?23- the first table.
- the second table.
- both tables.
- neither table
 
- Who is removed in a RIGHT JOIN?24- Mick
- John
- Paul
- Keith
 
- Which variable(s) are removed in a RIGHT JOIN?25- name
- band
- plays
- none of them
 

- In SQL, what happens to Mick’s “plays” variables in a FULL JOIN?26- Mick is removed
- guitar
- bass
- NA
- NULL
 

- grep("q[^u]", very.large.word.list)would not match which of the following?27- Iraqi
- Iraqian
- Iraq
- zaqqun (tree that “springs out of the bottom of Hell”, in the Quran)
- Qantas (the Australian airline)
 
- Which of the following regex would match to both “grey” and “gray”?28
- “gr[ae]y”
- “gr(a|e)y”
- “gray | grey”
- “gr[a|e]y”
- some / all of the above – which ones?
 
- What will the result be for the following code?29
- 10
- 1
- 0
- NA
 
str_extract("My dog is 10 years old", "\\d")- What will the result be for the following code?30
- 10
- 1
- 0
- NA
 
str_extract("My dog is 10 years old", "\\d+")- What will the result be for the following code?31
- .
- Episode 2: The pie whisperer. (4 August 2015)
- Episode
- E
 
str_extract("Episode 2: The pie whisperer. (4 August 2015)", ".")- What will the result be for the following code?32
- .
- Episode 2: The pie whisperer. (4 August 2015)
- Episode
- E
 
str_extract("Episode 2: The pie whisperer. (4 August 2015)", ".+")- What will the result be for the following code?33
- .
- Episode 2: The pie whisperer. (4 August 2015)
- Episode
- E
 
str_extract("Episode 2: The pie whisperer. (4 August 2015)", "\\.")- How can I pull out just the numerical information in $47?34
- “(?<=\$)\d”
- “(?<=\$)\d+”
- “\d(?=\$)”
- “\d+(?=\$)”
 
- You want to know all the types of pies in the text strings. They are written as, for example “apple pie”.35
- “\w+(?!pie)”
- “\w+(?! pie)”
- “\w+(?=pie)”
- “\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- We say that lookarounds are “zero-lenghth assertions”. What does that mean?36
- we return the string in the lookaround
- we replace the string in the lookaround
- we return the string at the lookaround
- we replace the string at the lookaround
 
- 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
- SELECT*- FROMPersons- WHEREFirstName = ’a.*’
- SELECT*- FROMPersons- WHEREFirstName = ’a*’
- SELECT*- FROMPersons- WHEREFirstName- REGEXP’a.*’
- SELECT*- FROMPersons- WHEREFirstName- REGEXP’a*’
- SELECT*- FROMPersons- WHEREFirstName- REGEXP’(?i)a.*’
 
- What is the main way to absolutely recognize a record within a database?38
- Foreign key
- Primary key
- Unique key
- Natural key
- Alternate key
 
- What does a foreign key do?39
- Directly identifies another table
- Directly identifies another column
- Gives access to another entire database
- Translates the database into another language
 
- Which of these would likely be used as a foreign key between a table on student enrollment and student grades?40
- grades
- tuition
- student_name
- student_hometown
 
- For the student records (for two tables: enrollment and grades), which is the most likely combination?41
- name as primary key to both
- name as foreign to both
- name as primary in enrollment and foreign in grades
- name as foreign in enrollment and primary in grades
 
- Which SQL statement is used to create a database table called ‘Customers’?42
- CREATE DATABASE TABCustomers
- CREATE DATABASECustomers
- CREATE DATABASE TABLECustomers
- CREATE TABLECustomers
- CREATE DBCustomers
 
- Which SQL statement revises data in a database?43
- SAVE AS
- MODIFY
- SAVE
- UPDATE
 
- Which SQL statement takes out data from a database?44
- REMOVE
- DELETE
- COLLAPSE
 
- The NOT NULLconstraint enforces a column to not acceptNULLvalues.45- FALSE
- TRUE
 
- Which SQL statement places new data in a database?46
- ADD RECORD
- INSERT INTO
- ADD NEW
- INSERT NEW
 
- With SQL, how can you insert a new record into the “Persons” table?47
- INSERT- INTOPersons VALUES (‘Jimmy’, ‘Jackson’)
- INSERT(‘Jimmy’, ‘Jacskon’)- INTOPersons
- INSERTVALUES (‘Jimmy’, ‘Jackson’)- INTOPersons
 
- With SQL, how can you insert “Olsen” as the “LastName” in the “Persons” table?48
- INSERT- INTOPersons (LastName) VALUES (‘Olsen’)
- INSERT- INTOPersons (’Olsen)- INTOLastName
- INSERT(‘Olsen’)- INTOPersons (LastName)
 
- How can you change “Hansen” into “Nilsen” in the “LastName” column in the Persons table?49
- MODIFYPersons- SETLastName=‘Nilsen’- WHERELastName=‘Hansen’
- UPDATEPersons- SETLastName=‘Hansen’- INTOLastName=‘Nilsen’
- MODIFYPersons- SETLastName=‘Hansen’- INTOLastName=‘Nilsen’
- UPDATEPersons- SETLastName=‘Nilsen’- WHERELastName=‘Hansen’
 
- With SQL, how can you delete the records where the “FirstName” is “Peter” in the Persons Table?50
- DELETE- FROMPersons- WHEREFirstName=‘Peter’
- DELETEFirstName=‘Peter’- FROMPersons
- DELETE ROWFirstName=‘Peter’- FROMPersons
 
- In the flightstable, the followingINDEXes exist:Tailnum,Year, andDate. How many rows would be looked through if theWHEREfilter was onmonthonly?51- more than 6.3 million
- less than 6.3 million
- more than 700,000
- less than 700,000
 
- Which has a larger cardinality, TailnumorYear?52- Tailnum
- Year
- they have the same cardinality
- neither has a cardinality
 
- Which index takes up more storage space, the one on Tailnumor the one onYear?53- Tailnum
- Year
- they take up the same space
- you can’t index on either variable
 
- Which index is more effective at reducing querying time, the one on Tailnumor the one onYear?54- Tailnum
- Year
- the queries would be the same
- you can’t query on either variable
 
- What does the R function ifelse(a, b, c)do?55- a = TRUE option, b = FALSE option, c = question
- a = FALSE option, b = TRUE option, c = question
- a = question, b = TRUE option, c = FALSE option
- a = question, b = FALSE option, c = TRUE option
 
- What does the R function case_when()do?56- renames a variable
- changes the data type of a variable
- partitions a numeric variable
- creates a new variable by re-coding an original variable
 
- What does the R function cut()do?57- renames a variable
- changes the data type of a variable
- partitions a numeric variable
- creates a new variable by re-coding an original variable
 
Footnotes
- A relational database management system.
 
- 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.
 
- relational database management systems.
 
- computer’s hard drive / storage
 
- SQL tblin storage and Rtibblein memory
 
- SQL 
- SELECT
 
- SELECTFirstName- FROMPersons
 
- SELECT*- FROMPersons
 
- SELECT- COUNT(*)- FROMPersons
 
- SELECT*- FROMPersons- WHEREFirstName = ‘Peter’ (d. would also work.)
 
- SELECT*- FROMPersons- WHEREFirstName = ‘Peter’ AND LastName = ‘Jackson’
 
- BEWTEEN
 
- SELECT*- FROMPersons- WHERELastName BETWEEN ‘Hansen’ AND ‘Pettersen’
 
- SELECT- DISTINCT
 
- ORDER BY
 
- SELECT*- FROMPersons ORDER BY FirstName DESC
 
- TRUE
 
- … WHEREtype = ‘fruit’ AND (color = ‘yellow’ OR color = ‘green’)
 
- … 
- it combines rows from two or more tables based on a related column.
 
- it combines the results of two or more SELECTstatements.
 
- it combines the results of two or more 
- it combines rows from two or more tables based on a related column.
 
- it combines rows from two or more tables based on a related column.
 
- the first table
 
- Mick
 
- none of them (all variables are kept in all joins)
 
- NULL(it would be NA in R)
 
- neither c. nor e. would match. Inside the bracket “[^u]” matches anything other than a “u”, but it has to match something.↩︎ 
- 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”.
 
- all of the above. Inside a character class 
- 1 (because \dmatches only a single digit).
 
- 1 (because 
- 10 (because \d+matches at least one digit).
 
- 10 (because 
- E (because .matches anything, and returns only a single character).
 
- E (because 
- Episode 2: The pie whisperer. (4 August 2015) (because .matches anything, and with the+it returns multiple characters).
 
- Episode 2: The pie whisperer. (4 August 2015) (because 
- . (because \.matches the period, .).
 
- . (because 
- “(?<=\$)\d+”
 
- “\w+(?= pie)”
 
- we return the string at the lookaround
 
- SELECT*- FROMPersons- WHEREFirstName- REGEXP’(?i)a.*’ (n.b., the- LIKEfunction will give you a similar result, with- %as a wildcard: SELECT- *FROM- PersonsWHERE` FirstName LIKE ‘a%’)
 
- Primary key
 
- Directly identifies another column
 
- student_name
 
- 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.)
 
- CREATE TABLECustomers
 
- UPDATE
 
- DELETE
 
- TRUE
 
- INSERT INTO
 
- INSERT- INTOPersons VALUES (‘Jimmy’, ‘Jackson’)
 
- INSERT- INTOPersons (LastName) VALUES (‘Olsen’)
 
- UPDATEPersons- SETLastName=‘Nilsen’- WHERELastName=‘Hansen’
 
- DELETE- FROMPersons- WHEREFirstName=‘Peter’
 
- 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.
 
- Tailnum. The cardinality is the number of unique values, and there are many more unique planes than years.
 
- Tailnum. Because the cardinality is higher, it will take up much more space in the index.
 
- Tailnum. Because the index is more complete, it will make the querying more efficient.
 
- a = question, b = TRUE option, c = FALSE option
 
- creates a new variable by re-coding an original variable
 
- partitions a numeric variable