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
tbl
and R tibble
both in storagetbl
and R tibble
both in memorytbl
in storage and R tibble
in memorytbl
in memory and R tibble
in storageSELECT
Persons.FirstNameFROM
PersonsSELECT
FirstName FROM
PersonsSELECT
“FirstName” FROM
“Persons”SELECT
PersonsSELECT
* FROM
PersonsSELECT
[all] FROM
PersonsSELECT
*.PersonsSELECT
COLUMNS(*)
FROM
PersonsSELECT
COUNT(*)
FROM
PersonsSELECT
NO(*)
FROM
PersonsSELECT
LEN(*)
FROM
PersonsSELECT
* FROM
Persons WHERE
FirstName <> ‘Peter’SELECT
* FROM
Persons WHERE
FirstName = ‘Peter’SELECT
* FROM
Persons WHERE
FirstName == ‘Peter’SELECT
[all] FROM
Persons WHERE
FirstName LIKE
‘Peter’SELECT
[all] FROM
Persons WHERE
FirstName = ‘Peter’SELECT
FirstName = ‘Peter’, LastName = ‘Jackson’ FROM
PersonsSELECT
* FROM
Persons WHERE
FirstName <> ‘Peter’ AND LastName <> ‘Jackson’SELECT
* FROM
Persons WHERE
FirstName = ‘Peter’ AND LastName = ‘Jackson’SELECT
* FROM
Persons WHERE
FirstName == ‘Peter’ AND LastName == ‘Jackson’BEWTEEN
WITHIN
RANGE
SELECT
LastName > ‘Hansen’ AND LastName < ‘Pettersen’ FROM
PersonsSELECT
* FROM
Persons WHERE
LastName BETWEEN ‘Hansen’ AND ‘Pettersen’SELECT
* FROM
Persons WHERE
LastName > ‘Hansen’ AND LastName < ‘Pettersen’SELECT
UNIQUE
SELECT
DISTINCT
SELECT
DIFFERENT
ORDER BY
ORDER
SORT
SORT BY
SELECT
* FROM
Persons ORDER
FirstName DESC
SELECT
* FROM
Persons SORT
‘FirstName’ DESC
SELECT
* FROM
Persons ORDER BY
FirstName DESC
SELECT
* FROM
Persons SORT BY
‘FirstName’ DESC
SELECT
the records with foods that are either green or yellow fruit:18
WHERE
type = ‘fruit’ AND color = ‘yellow’ OR color = ‘green’WHERE
(type = ‘fruit’ AND color = ‘yellow’) OR color = ‘green’WHERE
type = ‘fruit’ AND (color = ‘yellow’ OR color = ‘green’)WHERE
type = ‘fruit’ AND color = ‘yellow’ AND color = ‘green’WHERE
type = ‘fruit’ AND (color = ‘yellow’ AND color = ‘green’)JOIN
?19
SELECT
statement.UNION
operator in SQL?20
SELECT
statements.SELECT
statement.INNER JOIN
in SQL?21
SELECT
statement.LEFT JOIN
in SQL?22
SELECT
statement.RIGHT JOIN
keeps all the rows in …?23
RIGHT JOIN
?24
RIGHT JOIN
?25
FULL JOIN
?26
NULL
grep("q[^u]", very.large.word.list)
would not match which of the following?27
[1] "apple" "chocolate" "peach"
SELECT
* FROM
Persons WHERE
FirstName = ’a.*’SELECT
* FROM
Persons WHERE
FirstName = ’a*’SELECT
* FROM
Persons WHERE
FirstName REGEXP
’a.*’SELECT
* FROM
Persons WHERE
FirstName REGEXP
’a*’SELECT
* FROM
Persons WHERE
FirstName REGEXP
’(?i)a.*’CREATE DATABASE TAB
CustomersCREATE DATABASE
CustomersCREATE DATABASE TABLE
CustomersCREATE TABLE
CustomersCREATE DB
CustomersSAVE AS
MODIFY
SAVE
UPDATE
REMOVE
DELETE
COLLAPSE
NOT NULL
constraint enforces a column to not accept NULL
values.45
ADD RECORD
INSERT INTO
ADD NEW
INSERT NEW
INSERT
INTO
Persons VALUES (‘Jimmy’, ‘Jackson’)INSERT
(‘Jimmy’, ‘Jacskon’) INTO
PersonsINSERT
VALUES (‘Jimmy’, ‘Jackson’) INTO
PersonsINSERT
INTO
Persons (LastName) VALUES (‘Olsen’)INSERT
INTO
Persons (’Olsen) INTO
LastNameINSERT
(‘Olsen’) INTO
Persons (LastName)MODIFY
Persons SET
LastName=‘Nilsen’ WHERE
LastName=‘Hansen’UPDATE
Persons SET
LastName=‘Hansen’ INTO
LastName=‘Nilsen’MODIFY
Persons SET
LastName=‘Hansen’ INTO
LastName=‘Nilsen’UPDATE
Persons SET
LastName=‘Nilsen’ WHERE
LastName=‘Hansen’DELETE
FROM
Persons WHERE
FirstName=‘Peter’DELETE
FirstName=‘Peter’ FROM
PersonsDELETE ROW
FirstName=‘Peter’ FROM
Personsflights
table, the following INDEX
es exist: Tailnum
, Year
, and Date
. How many rows would be looked through if the WHERE
filter was on month
only?51
Tailnum
or Year
?52
Tailnum
Year
Tailnum
or the one on Year
?53
Tailnum
Year
Tailnum
or the one on Year
?54
Tailnum
Year
ifelse(a, b, c)
do?55
case_when()
do?56
cut()
do?57
tbl
in storage and R tibble
in memorySELECT
FirstName FROM
PersonsSELECT
* FROM
PersonsSELECT
COUNT(*)
FROM
PersonsSELECT
* FROM
Persons WHERE
FirstName = ‘Peter’ (d. would also work.)SELECT
* FROM
Persons WHERE
FirstName = ‘Peter’ AND LastName = ‘Jackson’BEWTEEN
SELECT
* FROM
Persons WHERE
LastName BETWEEN ‘Hansen’ AND ‘Pettersen’SELECT
DISTINCT
ORDER BY
SELECT
* FROM
Persons ORDER BY FirstName DESCWHERE
type = ‘fruit’ AND (color = ‘yellow’ OR color = ‘green’)SELECT
statements.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.
|
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”.\d
matches only a single digit).\d+
matches at least one digit)..
matches anything, and returns only a single character)..
matches anything, and with the +
it returns multiple characters).\.
matches the period, .).SELECT
* FROM
Persons WHERE
FirstName REGEXP
’(?i)a.*’ (n.b., the LIKE
function will give you a similar result, with %
as a wildcard: SELECT*
FROMPersons
WHERE` FirstName LIKE ‘a%’)CREATE TABLE
CustomersUPDATE
DELETE
INSERT INTO
INSERT
INTO
Persons VALUES (‘Jimmy’, ‘Jackson’)INSERT
INTO
Persons (LastName) VALUES (‘Olsen’)UPDATE
Persons SET
LastName=‘Nilsen’ WHERE
LastName=‘Hansen’DELETE
FROM
Persons WHERE
FirstName=‘Peter’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.