Database Security and Authorization - integrity constraints, check constraints, referential constraints, views and updates on views - One Line Questions

1. A view in a database is best described as: A stored query that presents data from one or more tables
2. What is the main difference between a PRIMARY KEY constraint and a UNIQUE constraint? A UNIQUE constraint allows NULL values, while a PRIMARY KEY does not.
3. Which type of view is generally updatable? A simple view based on a single table
4. If a user has `UPDATE` privilege on a table but not `INSERT` privilege, they can: Change existing records but not add new ones.
5. Which of the following is an example of a check constraint condition? AGE > 18
6. Which of the following statements about updating views is TRUE? Updatability of a view depends on its definition and the underlying tables.
7. Which SQL clause is used to define a check constraint? ALTER TABLE ... ADD CONSTRAINT ... CHECK
8. Consider a view `ProductSummary` created from `Products` and `Categories` tables. If `ProductSummary` includes columns from both tables, and an update is attempted on a column that exists only in the `Products` table, the update is: Successful if the update affects only one row in the `Products` table and all required columns are present.
9. Consider a table `Employees` with columns `EmployeeID` (PK), `Name`, `DepartmentID` (FK referencing `Departments.DepartmentID`), and `Salary`. Which of the following is a valid CHECK constraint for the `Salary` column? CHECK (Salary > 0)
10. The table containing the referenced column in a referential constraint is called the: Parent table
11. Which of the following SQL statements would create a view named `ActiveCustomers` showing customers from the `Customers` table whose `status` is 'Active'? CREATE VIEW ActiveCustomers AS SELECT * FROM Customers WHERE status = 'Active';
12. Which of the following actions is typically restricted by a referential constraint when attempting to delete a record from the parent table? Deleting the parent record if child records exist.
13. Which integrity constraint enforces entity integrity? Primary Key constraint
14. Which SQL command is used to remove privileges from a user? REVOKE
15. If a view is created using a JOIN operation, under what condition might it be updatable? If the update affects only one of the underlying tables and all necessary columns are included
16. A user having `SELECT` privilege on a table can: Read data from the table.
17. Can you perform an INSERT operation directly on a view? Only if the view is based on a single table and includes all NOT NULL columns
18. Which type of constraint ensures that all values in a column are unique? UNIQUE constraint
19. In a referential constraint, the table containing the referencing column is known as the: Child table
20. What does the `ON DELETE CASCADE` option in a foreign key constraint do? Deletes corresponding rows in the child table when a row in the parent table is deleted
21. Which of the following is NOT a type of integrity constraint? Trigger
22. A constraint that restricts the values that can be entered into a column based on a specific condition is called a: Check constraint
23. A constraint that ensures that no two rows in a table have the same value in a specified column (or set of columns) is a: Unique constraint
24. A user having `INSERT` privilege on a table can: Add new rows to the table.
25. Which SQL command is used to grant specific privileges to a user? GRANT
26. Which privilege allows a user to modify existing data in a table? UPDATE
27. Which privilege allows a user to remove rows from a table? DELETE
28. What does a referential constraint ensure between two tables? That a value in the referencing column must exist in the referenced column of the other table
29. The `ON UPDATE SET NULL` option for a foreign key constraint means: The foreign key column is set to NULL when the referenced primary key is updated
30. When a view is based on a single table, and the update operation modifies a column that is part of the view's selection, what is the most likely outcome? The underlying table will be updated
31. If a `FOREIGN KEY` constraint is defined with `ON DELETE RESTRICT`, what happens if you try to delete a row from the parent table that has related rows in the child table? The deletion of the row in the parent table is prevented and an error is raised.
32. What is a potential issue when updating data through a view? The integrity constraints on the underlying table might be violated
33. What does it mean to grant `ALL PRIVILEGES` on a table to a user? The user can perform all allowed operations (SELECT, INSERT, UPDATE, DELETE, etc.) on the table.
34. When updating data through a view that involves a join, if the update affects columns from multiple base tables, what is a common requirement for the view to be updatable? Each row in the view must correspond to exactly one row in each base table.
35. Which of the following scenarios would typically prevent a view from being updatable? The view uses the `DISTINCT` keyword.
36. What is the fundamental role of authorization in database security? To control who can access what data and perform which operations.
37. What is the purpose of the `NOT NULL` constraint? To ensure that a column cannot have a NULL value.
38. What is the primary benefit of using CHECK constraints? To enforce domain integrity by limiting the range or set of values allowed
39. What is the primary purpose of an integrity constraint in a database? To enforce data accuracy and consistency
40. What is the purpose of defining `ON DELETE SET NULL` for a foreign key? To set the foreign key column in the child record to NULL when the parent record is deleted.
41. What is a primary advantage of using views? To simplify complex queries and restrict data access
42. A referential constraint is typically implemented using which database object? Foreign Key
43. A database constraint that prevents inserting a value into a column if that value is not present in a specified list of allowed values is a type of: Check Constraint
44. A database designer wants to ensure that every `order_id` entered into the `Orders` table must correspond to an existing `customer_id` in the `Customers` table. Which constraint should be used? FOREIGN KEY constraint on `Orders.customer_id` referencing `Customers.customer_id`
45. A `CHECK` constraint can be used to enforce: A condition on the values allowed in a column.
46. What operation is typically forbidden on a referenced primary key if there are referencing foreign keys? DELETE
47. Which of the following is a common way to implement authorization in a database system? Implementing a role-based access control (RBAC) system.
48. If a view is defined as `CREATE VIEW HighSalaryEmployees AS SELECT EmployeeID, Name FROM Employees WHERE Salary > 100000;`, can `EmployeeID` be updated through this view? Yes, if `EmployeeID` is not part of the WHERE clause.
49. If a view is defined using an aggregate function like `COUNT(*)`, can it be updated? No, views with aggregate functions are generally not updatable.