CS50 Week 7: Data Tools
- 125Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
125 questions
- 1The database-centric language introduced for working with relational data is_____.
Hint
Its name stands for Structured Query Language.
Answer
SQL
- 2A text file containing rows of data separated by delimiters is called a_____database.
Hint
It is a simple alternative to a full database program.
Answer
flat file
- 3The file format whose name means comma-separated values is abbreviated_____.
Hint
It is commonly used to exchange spreadsheet data in a portable format.
Answer
CSV
- 4In a CSV file, newline characters such as_____
\nare used to represent separate.Hint
They move the cursor to the next line.
Answer
rows
- 5In a CSV file, commas are used to separate values that represent different_____.
Hint
They separate fields within a row.
Answer
columns
- 6A CSV file's first row often describes the names or meanings of the columns and is called the_____row.
Hint
It contains metadata rather than an ordinary data record.
Answer
header
- 7When a CSV field contains a comma, the conventional way to prevent confusion is to_____the string.
Hint
The field is enclosed using quotation marks.
Answer
quote
- 8A globally portable format that can be exported from spreadsheet software is_____.
Hint
It is not a proprietary Apple, Microsoft, or Google format.
Answer
.csv
- 9A tab-separated version of a delimited text file is abbreviated_____.
Hint
The separator is a tab rather than a comma.
Answer
TSV
- 10In the survey data, the three columns were timestamp, language, and_____.
Hint
This column recorded a favorite CS50 assignment.
Answer
problem
- 11The Python module that provides functionality for reading CSV files is imported with_____.
Hint
The module name is the same as the file format abbreviation.
Answer
import csv
- 12The Python function that opens a file is_____.
Hint
It corresponds conceptually to
fopenin C.Answer
open
- 13The optional mode argument_____
rpassed to Python'sopenfunction means to open a file for.Hint
This mode is implied if the second argument is omitted.
Answer
reading
- 14The Python function corresponding to C's_____
fcloseis.Hint
It releases the file after processing.
Answer
close
- 15The Python keyword that automatically closes a file after leaving its indented block is_____.
Hint
It begins a context-management statement.
Answer
with
- 16The Python CSV function that returns rows as lists is_____.
Hint
It is called from the
csvmodule.Answer
reader
- 17Calling_____on a CSV reader skips the header row by retrieving the next row before the loop begins.
Hint
It advances an iterator.
Answer
next
- 18Because Python lists use zero-based indexing,_____
row[1]refers to thecolumn of a three-column row.Hint
Index
0refers to the first column.Answer
second
- 19The CSV reader returns each row as a list whose elements correspond to the row's_____.
Hint
The survey rows contain timestamp, language, and problem.
Answer
columns
- 20The Python CSV tool that uses the header names as dictionary keys is_____.
Hint
Its name combines dictionary functionality with the ordinary reader.
Answer
DictReader
- 21With_____
DictReader, a row's language value can be accessed using the key.Hint
The key comes directly from the header row.
Answer
"language"
- 22Using named dictionary keys is more robust than numeric indices because moving columns does not break the code unless the_____is renamed.
Hint
The code still depends on the field's name.
Answer
column
- 23A spreadsheet interface is considered fragile because users can easily move, delete, or add_____.
Hint
Position-based code can then refer to the wrong data.
Answer
columns
- 24The Python syntax that increments a counter by one without using_____
++is.Hint
Python supports augmented assignment but not C's increment operator.
Answer
+= 1
- 25A dictionary associates_____with values, making it useful for counting categories.
Hint
Scratch, C, and Python can serve as these labels.
Answer
keys
- 26An empty Python dictionary can conventionally be created with_____.
Hint
It uses two empty curly braces.
Answer
{}
- 27The Python expression_____
favorite in countschecks whetherfavoriteis already ain the dictionary.Hint
It does not search the dictionary's values in this context.
Answer
key
- 28When a language is encountered for the first time, its count should be initialized to_____.
Hint
The current row is already the first observation.
Answer
one
- 29When a previously observed language appears again, its dictionary value is incremented by_____.
Hint
Each row represents one additional response.
Answer
one
- 30The Python function that sorts dictionary keys alphabetically by default is_____.
Hint
It can be used directly in a
forloop.Answer
sorted
- 31A Python dictionary can be iterated over with_____
for favorite in countsto process its.Hint
These are the entries on the left-hand side of the mapping.
Answer
keys
- 32The_____
counts.getmethod can be supplied tosortedto sort dictionary entries by their.Hint
For a counting dictionary, these are the frequencies.
Answer
values
- 33Passing_____
reverse=Truetosortedchanges the order from ascending to.Hint
This produces the most popular item first.
Answer
descending
- 34Arguments supplied according to their left-to-right position are called_____arguments.
Hint
Their meaning depends on where they appear in the call.
Answer
positional
- 35Arguments supplied using explicit parameter names are called_____parameters.
Hint
They make clear which option is being selected.
Answer
named
- 36The Python class designed to provide built-in counting capabilities is_____.
Hint
It comes from the
collectionsmodule.Answer
Counter
- 37A_____
Counterautomatically initializes an unseen item towhen it is incremented.Hint
This removes the need for a separate first-observation case.
Answer
zero
- 38The_____
Countermethod that returns items ordered from most common to least common is.Hint
Its name describes the ranking it produces.
Answer
most_common
- 39Python permits a loop to assign two values per iteration by separating the loop variables with a_____.
Hint
This is useful when iterating over key-value pairs.
Answer
comma
- 40SQL stands for_____Query Language.
Hint
It is the first word in the language's full name.
Answer
Structured
- 41SQL is described as a_____language because it specifies the desired data rather than usually specifying loops and conditionals.
Hint
It describes what answer is wanted instead of every step for obtaining it.
Answer
declarative
- 42The four-part database operation paradigm abbreviated CRUD consists of create, read, update, and_____.
Hint
It is the most destructive of the four basic operations.
Answer
delete
- 43In SQL terminology, adding new rows is performed with the_____keyword.
Hint
It corresponds to creating or adding data.
Answer
INSERT
- 44In SQL terminology, reading or retrieving data is performed with the_____keyword.
Hint
It asks the database to return specified data.
Answer
SELECT
- 45The SQL keyword that changes existing data is_____.
Hint
It modifies values that are already stored.
Answer
UPDATE
- 46The SQL keyword that removes rows from a table is_____.
Hint
It is part of the CRUD acronym's final operation.
Answer
DELETE
- 47The SQL command that can destructively remove an entire table is_____.
Hint
It is more destructive than deleting selected rows.
Answer
DROP
- 48In a relational database, a spreadsheet-like collection of rows and columns is called a_____.
Hint
A database can contain multiple related structures of this type.
Answer
table
- 49SQLite is described in the lecture as a_____implementation of SQL.
Hint
It focuses on core functionality and is commonly used on phones and computers.
Answer
lightweight
- 50SQLite databases are stored in a binary file containing_____and ones.
Hint
Binary data uses two possible digits.
Answer
zeros
- 51The SQLite command that displays a table's design or creation statement is_____.
Hint
It is a SQLite-specific command beginning with a dot.
Answer
.schema
- 52The SQL query pattern used to retrieve columns from a table begins with_____and specifies the source using
FROM.Hint
It is the primary SQL command for reading data.
Answer
SELECT
- 53In_____
SELECT * FROM favorites, the asterisk is athat requests every column.Hint
It means “everything” in this context.
Answer
wildcard
- 54SQL statements in the SQLite command-line interface are conventionally terminated with a_____.
Hint
It marks the end of the query.
Answer
semicolon
- 55The SQL keyword that restricts the number of returned rows is_____.
Hint
It is useful when a table contains thousands of records.
Answer
LIMIT
- 56The SQL aggregate function that counts rows is_____.
Hint
It can be used with an asterisk to count all rows.
Answer
COUNT
- 57Using_____
COUNT(*)is conventional when the goal is to count the number ofrather than a particular field.Hint
Every row has the same number of columns.
Answer
rows
- 58The SQL keyword that removes duplicate values from a result is_____.
Hint
It can reveal the unique languages in the survey.
Answer
DISTINCT
- 59SQL functions can be_____so that the output of one function becomes the input of another.
Hint
For example, a count can be applied to distinct values.
Answer
nested
- 60The SQL keyword used to filter rows according to a condition is_____.
Hint
It replaces many explicit conditional branches in this example.
Answer
WHERE
- 61To find responses where the language is C, SQL compares the language column with C using a_____clause.
Hint
This clause filters the table before returning results.
Answer
WHERE
- 62SQL combines conditions with the word_____rather than C's
&&operator.Hint
It requires both conditions to be true.
Answer
AND
- 63In SQL, equality comparisons use a_____equal sign rather than the double equal sign used in C and Python.
Hint
SQL follows the comparison style used in Scratch in this respect.
Answer
single
- 64The SQL clause that combines rows with the same value for a column is_____.
Hint
It can group all Python rows, all C rows, and all Scratch rows.
Answer
GROUP BY
- 65To rank grouped results by a count, SQL uses the clause_____.
Hint
It controls the ordering of the result set.
Answer
ORDER BY
- 66The default ordering direction for_____
ORDER BYis abbreviated.Hint
It places smaller values before larger values.
Answer
ASC
- 67To display the largest counts first, SQL uses the ordering direction_____.
Hint
It reverses the default ascending order.
Answer
DESC
- 68The SQL keyword used to give a calculated column a simpler name is_____.
Hint
It can rename
COUNT(*)ton.Answer
AS
- 69A query that asks for the most popular single language can combine_____
ORDER BYwith.Hint
Only one result row is needed.
Answer
LIMIT 1
- 70The SQL command for adding a row specifies the destination table with the phrase_____.
Hint
It is followed by the table name.
Answer
INSERT INTO
- 71In an_____
INSERT INTOstatement, the first parenthesized list contains the names of thebeing populated.Hint
The second parenthesized list contains their values.
Answer
columns
- 72In an_____
INSERT INTOstatement, the second parenthesized list contains theto store.Hint
They correspond positionally to the listed columns.
Answer
values
- 73In SQL, the special value representing the absence of data is_____.
Hint
It does not represent a memory address in SQL.
Answer
NULL
- 74An_____
UPDATEstatement changes existing rows by assigning new values after the keyword.Hint
It is followed by column-value assignments.
Answer
SET
- 75An_____
UPDATEorDELETEstatement without aclause can affect every row in the table.Hint
This clause limits the operation to matching records.
Answer
WHERE
- 76The process of separating duplicated data into related tables is called_____the data.
Hint
It creates a canonical source of truth and reduces redundancy.
Answer
normalizing
- 77Giving each show a unique numeric identifier creates a_____key for the shows table.
Hint
It uniquely identifies each row in its own table.
Answer
primary
- 78A column that refers to a primary key in another table is called a_____key.
Hint
Its meaning is relative to another table.
Answer
foreign
- 79A table containing one row for each show and its rating represents a_____relationship.
Hint
Each show has one corresponding rating.
Answer
one-to-one
- 80A relationship in which one show can have several genres is called_____.
Hint
One record on one side can correspond to multiple records on the other.
Answer
one-to-many
- 81A relationship in which a show can have many stars and a person can star in many shows is called_____.
Hint
Both sides can have multiple related records.
Answer
many-to-many
- 82The intermediary table connecting shows and people contains show ID and_____ID.
Hint
This field identifies the individual associated with a show.
Answer
person
- 83The table whose purpose is to connect shows to people in a many-to-many relationship is called_____.
Hint
It records which people star in which shows.
Answer
stars
- 84A table that connects two other tables in a many-to-many relationship is an_____table.
Hint
It sits between the two related entity tables.
Answer
intermediary
- 85Using separate columns named star, star, and star for different numbers of actors creates a sparse or_____table design.
Hint
Different rows would require different numbers of columns.
Answer
jagged
- 86Repeating a show's title for every actor wastes space because duplicated_____are less efficient than duplicated numeric IDs.
Hint
The alternative is to repeat a compact integer identifier.
Answer
strings
- 87The database design principle of storing each show's name and each person's name only once creates a canonical source of_____.
Hint
It avoids conflicting duplicate copies of the same information.
Answer
truth
- 88The SQL operation that combines related tables into a wider temporary result is_____.
Hint
It connects tables using common values.
Answer
JOIN
- 89In a join, the condition introduced by the keyword_____specifies which columns must match.
Hint
It is followed by an equality such as
shows.id = ratings.show_id.Answer
ON
- 90When joining a one-to-many relationship, duplicate rows may appear in the temporary_____even though the original tables are not duplicated.
Hint
It is the output produced by the query.
Answer
result set
- 91A query placed inside another SQL query is called a_____query.
Hint
Parentheses help determine which query runs first.
Answer
nested
- 92In a nested query, parentheses indicate that the inner query should be evaluated_____.
Hint
This follows the same general idea as parentheses in arithmetic.
Answer
first
- 93A database structure that speeds up searches on selected columns is called an_____.
Hint
It avoids repeatedly scanning an entire column linearly.
Answer
index
- 94The SQL command used to create a search index is_____.
Hint
It is followed by the index name, table, and column.
Answer
CREATE INDEX
- 95In SQLite, a primary key is automatically_____.
Hint
Searching by a primary key does not require a full linear scan.
Answer
indexed
- 96Foreign keys in SQLite are not_____by default.
Hint
Additional indexes may be needed when they are frequently used in searches or joins.
Answer
indexed
- 97The tree structure commonly used by database indexes is called a_____.
Hint
It is a short, wide tree rather than a binary tree.
Answer
B-tree
- 98A B-tree is described as short and_____because each node can have many children.
Hint
The large branching factor reduces the tree's height.
Answer
wide
- 99Indexes improve query speed by trading additional storage_____for reduced execution time.
Hint
This is a classic space-time trade-off.
Answer
space
- 100Indexes can slow down inserts, updates, and deletes because the index structure must be_____.
Hint
Changes to table data may require changes to the tree.
Answer
maintained
- 101The SQLite command used to measure query execution time is_____.
Hint
It can be turned on at the SQLite prompt.
Answer
.timer
- 102Searching an unindexed column generally requires a_____search through the values.
Hint
The database may inspect entries from top to bottom.
Answer
linear
- 103A Python program can access a SQLite database through the CS50 library's_____function.
Hint
The library provides a simplified interface for executing database commands.
Answer
SQL
- 104The database connection string used in the example begins with_____
sqlite:///followed by the database.Hint
The example connected to
favorites.db.Answer
filename
- 105The CS50 database method used to run a SQL query from Python is_____.
Hint
It sends a command to the database.
Answer
execute
- 106In the Python database query, a question mark serves as a_____for a value supplied separately.
Hint
It is analogous in purpose to a format-string substitution marker.
Answer
placeholder
- 107The result returned by a database query is stored in a temporary collection of_____.
Hint
The first result can be accessed with index zero.
Answer
rows
- 108The first row of a Python query result can be accessed with index_____.
Hint
Python sequences use zero-based indexing.
Answer
zero
- 109A database query can be used to provide a value for a Python program's_____interface.
Hint
Python can collect input and SQL can retrieve the corresponding data.
Answer
user
- 110Using Python for the interface and SQL for database retrieval demonstrates that different tools are suited to different_____.
Hint
The lecture emphasizes choosing the right tool for the task.
Answer
jobs
- 111A SQL query that retrieves a count can be embedded in Python to build a web or_____application.
Hint
The lecture mentions applications that run on phones.
Answer
mobile
- 112Using placeholders rather than formatting user input directly into SQL helps prevent_____injection attacks.
Hint
The attack causes user input to be interpreted as database commands.
Answer
SQL
- 113A condition in which simultaneous operations produce an incorrect result because they interleave unpredictably is a_____condition.
Hint
Multiple servers are effectively racing to update shared data.
Answer
race
- 114If three users read one million likes before updating the value, all three might write_____likes instead of one million three.
Hint
Each update is based on the same stale value.
Answer
one million one
- 115The refrigerator-and-milk example illustrates that two people can make decisions based on the same outdated_____of a shared variable.
Hint
Both roommates see that the refrigerator is empty before either purchase is recorded.
Answer
state
- 116A group of database operations that either all happen or none happen is called a_____.
Hint
It groups related operations into one unit.
Answer
transaction
- 117A transaction is described as_____when its operations occur without interruption or do not occur at all.
Hint
This property prevents partial execution.
Answer
atomic
- 118In the CS50 Python library, a transaction can be started with_____transaction.
Hint
This keyword marks the start of a grouped database operation.
Answer
BEGIN
- 119The SQL command that permanently applies a transaction's changes is_____.
Hint
It confirms the completed operation.
Answer
COMMIT
- 120In SQLite, the comment marker that causes the rest of a line to be ignored is two_____.
Hint
It is written as
--.Answer
hyphens
- 121An SQL injection vulnerability can occur when an application directly_____user input into a query string.
Hint
Formatting user input into an f-string is an unsafe example.
Answer
interpolates
- 122Entering a username followed by a quote and SQL's comment marker can cause the password check to be_____.
Hint
The remainder of the query becomes a comment.
Answer
ignored
- 123The safest general solution to SQL injection is to use parameterized queries with_____.
Hint
The example uses question marks instead of interpolated values.
Answer
placeholders
- 124In SQL string escaping, a pair of adjacent single quotes represents a literal_____.
Hint
This is SQL's way of escaping the delimiter itself.
Answer
quote
- 125SQL keywords are generally not case sensitive, but user-created table and column names must be used_____.
Hint
Naming conventions such as lowercase or camel case do not change the underlying requirement.
Answer
consistently

Ask anything
We've read this whole study set, so questions about it get the best answers.