Unit 2 - Practice Quiz

INT306

1 Which of the following categories of SQL commands is used to define the structure of the database, including creating, altering, and deleting tables?

A. DML (Data Manipulation Language)
B. DCL (Data Control Language)
C. TCL (Transaction Control Language)
D. DDL (Data Definition Language)

2 Which SQL command is used to remove all records from a table, including all spaces allocated for the records are removed, but the table structure remains?

A. DELETE
B. DROP
C. TRUNCATE
D. REMOVE

3 Which of the following is not a DML (Data Manipulation Language) command?

A. INSERT
B. UPDATE
C. GRANT
D. DELETE

4 The command to undo the changes made by the current transaction is:

A. COMMIT
B. ROLLBACK
C. SAVEPOINT
D. REVOKE

5 Which command is used to modify the structure of an existing table, such as adding a new column?

A. UPDATE
B. MODIFY
C. ALTER
D. CHANGE

6 In the context of database keys, a Super Key is defined as:

A. A set of attributes that uniquely identifies a tuple within a relation
B. A minimal set of attributes that uniquely identifies a tuple
C. A key that links two tables together
D. A key that allows NULL values

7 If is a Candidate Key of relation , which of the following statements is true?

A. must be a Super Key and no proper subset of is a Super Key
B. can contain NULL values
C. must be a composite key
D. is a subset of the Foreign Key

8 Which integrity constraint ensures that no two rows of a table have duplicate values in a specified column or set of columns, but allows NULL values (usually one)?

A. PRIMARY KEY
B. CHECK
C. UNIQUE
D. FOREIGN KEY

9 The Entity Integrity Rule states that:

A. Foreign key values must match a primary key in another table
B. Primary key attributes cannot be NULL
C. All attributes must have a domain
D. A transaction must be atomic

10 Which SQL clause is used to filter the results of a query based on a specified condition?

A. ORDER BY
B. GROUP BY
C. WHERE
D. HAVING

11 What is the purpose of the FOREIGN KEY constraint?

A. To ensure unique identification of a record
B. To speed up data retrieval
C. To enforce referential integrity between two tables
D. To ensure a column cannot be left empty

12 Which operator is used to search for a specified pattern in a column?

A. IN
B. BETWEEN
C. LIKE
D. EXISTS

13 In SQL, what does the wildcard character % represent?

A. Zero or more characters
B. Exactly one character
C. A numeric value only
D. A NULL value

14 Which of the following is a TCL (Transaction Control Language) command used to define a point within a transaction to which you can roll back?

A. COMMIT
B. ROLLBACK
C. SAVEPOINT
D. SET TRANSACTION

15 Which SQL keyword is used to retrieve unique values only?

A. DIFFERENT
B. UNIQUE
C. DISTINCT
D. SINGLE

16 Given the relation , if the attribute set is a candidate key, then is:

A. A Primary Key
B. A Super Key
C. A Foreign Key
D. Not a key

17 Which constraint ensures that the value in a column falls within a specific range or satisfies a logical expression?

A. DEFAULT
B. CHECK
C. UNIQUE
D. INDEX

18 When using the ORDER BY clause, what is the default sorting order?

A. Descending (DESC)
B. Ascending (ASC)
C. Random
D. Insertion Order

19 Which of the following statements regarding DELETE and DROP is true?

A. DELETE removes the table structure; DROP removes only rows.
B. DELETE is DDL; DROP is DML.
C. DELETE removes specific rows and can be rolled back; DROP removes the entire table and structure.
D. There is no difference.

20 Referential Integrity constraint violation occurs when:

A. A Primary Key is left NULL
B. A Foreign Key value is inserted that does not exist in the referenced Primary Key column
C. Two rows have the same Primary Key
D. A column with a UNIQUE constraint receives a duplicate value

21 Which SQL function is used to count the number of rows that contain numbers or non-NULL values in a specific column?

A. SUM()
B. TOTAL()
C. COUNT()
D. NUMBER()

22 The HAVING clause is used in combination with which other clause?

A. ORDER BY
B. GROUP BY
C. SELECT
D. UPDATE

23 Which set operator returns only the rows that appear in both result sets of two SELECT statements?

A. UNION
B. UNION ALL
C. INTERSECT
D. MINUS

24 What is an Alternate Key?

A. A key used for encryption
B. A Candidate Key that is not selected as the Primary Key
C. A Foreign Key in a third normal form
D. A Primary Key consisting of two columns

25 Which data type is used to store variable-length character strings?

A. CHAR
B. VARCHAR
C. INT
D. FLOAT

26 Which SQL statement is used to update data in a database?

A. SAVE
B. MODIFY
C. UPDATE
D. CHANGE

27 Which operator is used to select values within a given range?

A. WITHIN
B. RANGE
C. BETWEEN
D. LIMIT

28 What is the result of the following SQL operation: SELECT 5 + NULL;?

A. 5
B.
C. NULL
D. Error

29 Which command is used to take away a privilege granted to a user?

A. DELETE
B. REMOVE
C. REVOKE
D. DENY

30 A Composite Key is:

A. A key that contains alphanumeric characters
B. A Foreign Key that references two tables
C. A Primary Key that consists of two or more attributes
D. A key that is calculated from other columns

31 The IN operator in SQL is shorthand for:

A. Multiple AND conditions
B. Multiple OR conditions
C. A BETWEEN condition
D. A LIKE condition

32 Which of the following is an example of a Domain Constraint?

A. A student ID must be unique
B. A course ID in the enrollment table must exist in the course table
C. The 'Age' column must contain an integer greater than 0
D. The Primary Key cannot be NULL

33 Which DDL command is used to remove a table's definition and all its data, indexes, triggers, constraints, and permission specifications?

A. DELETE TABLE
B. TRUNCATE TABLE
C. DROP TABLE
D. ALTER TABLE

34 What does the following statement do? GRANT SELECT ON Employees TO User1;

A. Allows User1 to delete rows in Employees
B. Allows User1 to read data from the Employees table
C. Allows User1 to modify the Employees table structure
D. Allows User1 to update data in Employees

35 The wildcard _ (underscore) in SQL LIKE operator matches:

A. Zero or more characters
B. Exactly one character
C. Exactly two characters
D. Any numeric character

36 Which clause is used to give a temporary name to a table or a column in a query?

A. ALIAS
B. AS
C. NAME
D. RENAME

37 The Cross Join (Cartesian Product) of a table with 5 rows and a table with 3 rows will result in a table with how many rows?

A. 8
B. 15
C. 2
D. 5

38 Which aggregate function ignores NULL values by default?

A. SUM
B. AVG
C. MAX
D. All of the above

39 If you want to filter groups based on an aggregate property (e.g., departments with more than 5 employees), you must use:

A. WHERE clause
B. HAVING clause
C. ORDER BY clause
D. SELECT clause

40 Which of the following is correct syntax to insert a new row?

A. INSERT INTO table_name VALUES (value1, value2);
B. INSERT table_name (value1, value2);
C. ADD INTO table_name VALUES (value1, value2);
D. CREATE ROW table_name VALUES (value1, value2);

41 What is the effect of the ON DELETE CASCADE option in a Foreign Key constraint?

A. It prevents the deletion of a parent row if children exist.
B. It sets the foreign key to NULL if the parent is deleted.
C. It automatically deletes child rows when the corresponding parent row is deleted.
D. It throws an error when deleting the parent row.

42 Which keyword is used to combine the result-set of two or more SELECT statements, excluding duplicates?

A. UNION ALL
B. UNION
C. JOIN
D. MERGE

43 To change the default value of a column in an existing table, which command is generally used?

A. ALTER TABLE
B. UPDATE TABLE
C. MODIFY TABLE
D. CREATE DEFAULT

44 A Foreign Key in a table must refer to which key in the parent table?

A. Any attribute
B. Primary Key or Unique Key
C. Only the Primary Key
D. Only a Composite Key

45 Which logical operator has the highest precedence in SQL?

A. OR
B. AND
C. NOT
D. All have equal precedence

46 Which statement matches the definition: 'A query nested inside another query'?

A. Join
B. View
C. Subquery
D. Index

47 Which clause is strictly necessary in a SELECT statement to retrieve data from a table?

A. WHERE
B. FROM
C. ORDER BY
D. GROUP BY

48 If a transaction is committed using the COMMIT command:

A. The changes are temporary.
B. The changes are saved permanently in the database.
C. The changes can be rolled back using ROLLBACK immediately after.
D. The transaction is paused.

49 Which of the following is valid syntax to remove a column named age from table Student?

A. DELETE COLUMN age FROM Student;
B. ALTER TABLE Student DROP COLUMN age;
C. DROP COLUMN age FROM Student;
D. REMOVE age FROM Student;

50 The set of allowed values for each attribute is called the:

A. Tuple
B. Relation
C. Domain
D. Schema