Ch 3 Quiz
At a local hackathon, you and your classmates are invited to play a "Deal or No Deal" type of game about databases. To win the first round, you must state whether the following statement is true or false: For primary key deletions and updates, most databases support only the corrective action Restrict.
False Databases can automatically correct referential integrity violations with any of four corrective actions: Restrict, Set Null, Set Default, and Cascade. For primary key deletions and updates, most databases support all four corrective actions. For foreign key insertions and updates, most databases support only the action Restrict.
Match the join type with the correct definition. Instructions: Choose your responses from the drop-down menus below. Response options cannot be used more than once.
1 4 2 3 To allow for even cases wherein users may want to see both matched and unmatched rows from left, right, or both tables, relational databases can perform four types of joins or SELECT statements. An inner join selects only matching left and right table rows, whereas a full join selects all left and right table rows, regardless of whether they matched. A left join produces only matching right table rows but all left table rows. A right join produces only matching left table rows but all right table rows.
Your cousin, a senior in high school, asks you to play a Jeopardy-style game with her to help prepare for her computer science exam next week. She gives you these two clues about a type of relational database key: No column values may be NULL, and columns may be combined to create a unique primary key. Which type of key is she referring to? Select one.
A primary key is a column, or group of columns, used to identify a row. A composite primary key comprises multiple columns. When all columns are necessary for uniqueness, it is known as a minimal primary key. In a composite primary key, no column value can be NULL, and when grouped together, the values must be unique.
Four actions that can be implemented on a database to autocorrect violations of referential integrity, and the outcomes of the actions are listed below. Match the violation with the corrective action.
Because manual corrections of referential integrity are time consuming and error prone, databases can be programmed to autocorrect violations using four actions. The action Restrict results in rejection of an insert, update, or delete. Set Null sets invalid foreign keys to NULL, whereas Set Default sets invalid foreign keys to a default primary key value, which is specified in SQL. The action Cascade propagates primary key changes to foreign keys.
Three actions that databases can take when autocorrecting foreign key insertions and updates are listed below, as are the additional limitations on databases for each action. Match each action to its associated limitation. Instructions: Choose your responses from the drop-down menus below. Response options cannot be used more than once.
Databases can automatically correct referential integrity violations with any of four corrective actions: Restrict, Set Null, Set Default, and Cascade. But for foreign key insertions and updates, most databases support only the action Restrict. In addition, there are three limitations. Restrict is applied by default when no action is specified. Set Null cannot be used when a foreign key is NOT NULL. Finally, the value specified when applying Set Default must be a valid primary key.
During a water cooler chat, your colleague claims that both data types and names of foreign and primary keys must be the same. Is this true or false?
False A foreign key is a column, or group of columns, that refer to a primary key. Foreign key values that are not NULL must match some value of the primary key. The data types of the primary key and the foreign key must be the same, but it is not necessary that they have the same name. For example, suppose that the names of cities are listed in two tables under different column names, such as State Capital and Largest City. Assume that Largest City refers to State Capital—then Largest City is a foreign key referring to the primary key, State Capital.
Your coworker has decided to take an online course about the basics of databases so that he can improve his job performance. As you study with him at lunch, he says that he thinks attributes are essential in an ER diagram. Is this true or false?
False In an ER diagram, attributes, which describe an entity, are optional and are only shown when additional detail about the entity is needed. They are usually shown as additional text within the entity rectangle, under the entity name.
When the action Cascade propagates the changes made to a primary key to the associated foreign key, which of the following are the outcomes? Select all that apply.
Of the four actions that databases can auto-implement to autocorrect referential integrity violations, Cascade propagates all primary key changes to foreign keys. However, the outcomes are different for deletions or updates of the primary key. When the primary key is deleted, rows containing invalid foreign keys are deleted. However, when the primary key is updated, the invalid foreign keys are set to the new primary key value.
Which of these are ways in which referential integrity can be violated? Select all that apply.
Referential integrity requires that all foreign key values must either be fully NULL or match some primary key value. But sometimes violations occur due to data entry errors or incomplete data. However, these violations can occur in any of four ways: a primary key is updated, a foreign key is updated, a row containing a foreign key is inserted, or a row containing a primary key is deleted.
If you needed the database to select values in a specific order but order them in ascending order, which of the following clauses should you use along with the SELECT command? Select one.
A SELECT statement selects rows from a table but with no guarantee the data will display in a certain order. The ORDER BY clause orders the selected rows in ascending order. The DESC keyword with the ORDER BY clause orders the rows in descending order.