Verified Test Bank Database Programming Chapter 14 5e - Test Bank | Python 5e by Gaddis by Tony Gaddis. DOCX document preview.
Starting Out with Python 5e (Gaddis)
Chapter 14 Database Programming
TRUE/FALSE
1. Although SQL is a language, you don't use it to write applications.
2. The columns in a table are assigned SQL data types.
3. The column that is designated as the primary key must hold a unique value for each row.
4. All identity columns in a table must contain the same value.
5. In SQLite, when you designate a column as INTEGER PRIMARY KEY, that column
becomes an alias for the RowID column.
6. The SQL INSERT statement only inserts one row.
7. In SQLite, the Cursor object's fetchone method returns a list containing all the rows that result from a SELECT statement.
8. An SQL aggregate function performs a calculation on a set of values from a database table and returns a single value.
9. The Connection object's commit method saves any changes that have been made to the database.
10. When you create a table in an SQLite database, the RowID column is not automatically created.
MULTIPLE CHOICE
1. Which of the following do most developers prefer to use when developing applications that work with an intensive amount of data?
a. text files
b. binary files
c. a database management system
d. pickled objects
2. The standard language for working with database management systems is __________.
a. SQL
b. BASIC
c. ADA
d. COBOL
3. SQL stands for __________.
a. structured query language
b. standard equivalent language
c. semiconductor qualified language
d. simple equation library
4. The data that is stored in a row of a database is divided into __________.
a. sections
b. tables
c. bytes
d. columns
5. This is a column that holds a unique value for each row and can be used to identify specific rows.
a. ID column
b. public key
c. designator column
d. primary key
6. What will happen if you try to store duplicate data in a primary key column?
a. The column will be duplicated.
b. An error will occur.
c. The duplicate data will have concurrency issues.
d. The primary key column will not display the duplicate data.
7. What type of object does the sqlite3.connect function return?
a. Cursor
b. Database
c. File
d. Connection
8. In SQLite, you use the Cursor object’s ______________ method to pass an SQL statement to the DBMS.
a. commit
b. execute
c. dbms_pass
d. run_sql
9. The __________ type of SQL statement is used to retrieve the rows from a table.
a. GET
b. SELECT
c. READ
d. RETRIEVE
10. This clause allows you to specify search criteria with the SELECT statement.
a. SEARCH
b. CRITERIA
c. AS
d. WHERE
11. The __________ SQL operator can be used to perform a search for a substring.
a. STR
b. LIKE
c. WHERE
d. SUB
12. To sort the results of a SQL query, you can use the __________ clause.
a. SORT BY
b. ALIGN ROW
c. ORDER BY
d. ASCEND
13. The __________ statement is used in SQL to insert a new row into a table,
a. UPDATE
b. ADD
c. NEW
d. INSERT
14. In SQL, the __________ statement is used to change the contents of an existing row in a table.
a. SET ROW
b. CHANGE
c. UPDATE
d. REFRESH
15. In SQL, the __________ statement is used to delete one or more rows from a table.
a. DELETE
b. DROP ROW
c. REMOVE
d. PURGE
16. In SQL, the __________ statement can be used to create a database table.
a. NEW TABLE
b. MAKE TABLE
c. BUILD TABLE
d. CREATE TABLE
17. In SQL, the __________ statement is used to delete a table from a database.
a. REMOVE TABLE
b. DEL TABLE
c. DROP TABLE
d. ERASE TABLE
18. This Cursor method returns the entire results of the previously executed SELECT statement, as a list of tuples.
a. get_results
b. getall
c. fetchone
d. fetchall
19. This Cursor method returns only one row of the results of the previously executed SELECT statement, as a tuple.
a. get_results
b. getall
c. fetchone
d. fetchall
20. Suppose an SQLite database has a table named Users. The Users table has an INTEGER column named Logins. Which SQL statement returns the average of the Logins column?
a. SELECT AVG(Users) FROM Logins
b. SELECT AVG(Logins) FROM Users
c. SELECT AVERAGE(Logins) FROM Users
d. SELECT Users.AVG(Logins)
21. Suppose an SQLite database has a table named Customers. The Customers table has a REAL column named Purchases. Which SQL statement returns the sum of the Purchases column?
a. SELECT TOTAL(Customers) FROM Purchases
b. SELECT Customers.SUM(Purchases)
c. SELECT COUNT(Purchases) FROM Customers
d. SELECT SUM(Purchases) FROM Customers
22. If you want to know the number of rows in a table, or the number of rows that match a search criterion, you would use this SQL function.
a. COUNT
b. NUM_ROWS
c. QUANTITY
d. TOTAL
23. A column in one table that references a primary key in another table is known as a __________.
a. secondary key
b. foreign key
c. referential key
d. meta key
24. A qualified column name takes the form __________.
a. ColumnName.TableName
b. TableName.ColumnName
c. RowName.TableName
d. DatabaseURL.ColumnName
25. In SQLite, this type of exception is thrown any time a database error occurs.
a. DBException
b. DataError
c. SQLException
d. Error