Unit 2 - Practice Quiz

INT306 50 Questions
0 Correct 0 Wrong 50 Left
0/50

1 Which of the following categories of SQL commands is used to define the database schema and structure?

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

2 Which of the following commands is a DML command?

A. TRUNCATE
B. ALTER
C. UPDATE
D. GRANT

3 Which SQL command is used to remove a table's definition and all of its data from the database?

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

4 The TRUNCATE command in SQL belongs to which category?

A. DML
B. DDL
C. DCL
D. TCL

5 Which command is used to grant access privileges to a user?

A. REVOKE
B. ACCESS
C. PERMIT
D. GRANT

6 Which of the following is a TCL (Transaction Control Language) command?

A. COMMIT
B. SELECT
C. INSERT
D. CREATE

7 What is the function of the ROLLBACK command?

A. It saves the transaction permanently.
B. It undoes transactions that have not yet been committed.
C. It deletes the table structure.
D. It grants permissions to users.

8 If is a set of attributes in relation , and uniquely identifies each tuple in , then is called a:

A. Foreign Key
B. Super Key
C. Domain Key
D. Referential Key

9 A Candidate Key is defined as:

A. Any key that is unique.
B. A minimal Super Key.
C. A key that references another table.
D. A combination of all attributes.

10 Which integrity constraint ensures that the Primary Key attributes cannot be NULL?

A. Referential Integrity
B. Domain Integrity
C. Entity Integrity
D. Key Integrity

11 Consider a relation with attributes . If is a candidate key, which of the following is true?

A. must be a super key.
B. is a super key.
C. is a candidate key.
D. and can be NULL.

12 A Foreign Key creates a link between two tables to establish which type of integrity?

A. Entity Integrity
B. Referential Integrity
C. Domain Integrity
D. User-defined Integrity

13 If a table has multiple candidate keys, the one chosen by the database designer to identify tuples is called the:

A. Primary Key
B. Alternate Key
C. Foreign Key
D. Composite Key

14 Candidate keys that are not chosen as the primary key are known as:

A. Super Keys
B. Foreign Keys
C. Alternate Keys
D. Secondary Keys

15 Which of the following statements regarding the Primary Key is FALSE?

A. It must be unique.
B. It can contain NULL values.
C. It creates a clustered index by default in many systems.
D. A table can have only one Primary Key constraint.

16 A key consisting of more than one attribute is called a:

A. Foreign Key
B. Composite Key
C. Domain Key
D. Simple Key

17 Which SQL constraint restricts the values of a column to a specific set or range?

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

18 In the context of Referential Integrity, what does ON DELETE CASCADE do?

A. It prevents the deletion of the referenced row.
B. It sets the foreign key value to NULL.
C. It deletes the rows in the child table that reference the deleted row in the parent table.
D. It sets the foreign key value to a default value.

19 Which SQL clause is used to retrieve unique records only?

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

20 In SQL, the wildcard character % corresponds to:

A. Exactly one character.
B. Zero or more characters.
C. Exactly zero characters.
D. One or more characters.

21 In SQL, the wildcard character _ (underscore) corresponds to:

A. Zero or more characters.
B. Exactly one character.
C. A numeric digit only.
D. A whitespace character.

22 What is the result of the following SQL operation: SELECT * FROM R, S; where has tuples and has tuples?

A. tuples
B. tuples
C. tuples
D. The intersection of and

23 Which clause is used to filter records after grouping has occurred?

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

24 Which SQL keyword is used to sort the result-set?

A. SORT BY
B. ORDER BY
C. ALIGN
D. GROUP BY

25 Which of the following is an aggregate function in SQL?

A. AVG()
B. LIKE
C. ROUND()
D. UPPER()

26 The BETWEEN operator selects values within a given range. This range is:

A. Inclusive
B. Exclusive
C. Inclusive for start, Exclusive for end
D. Exclusive for start, Inclusive for end

27 Which constraint allows a column to remain empty but ensures that if a value is entered, it must be unique?

A. PRIMARY KEY
B. UNIQUE
C. NOT NULL
D. FOREIGN KEY

28 The command ALTER TABLE table_name ADD column_name datatype; is used to:

A. Insert data into a column.
B. Modify the data type of a column.
C. Add a new column to an existing table.
D. Add a new table to the database.

29 What is the purpose of the AS alias keyword in SQL?

A. To rename a table or column temporarily for a query.
B. To create a permanent new table.
C. To assign a data type.
D. To filter results.

30 Which set operation returns only the rows that appear in both result sets?

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

31 Which set operation combines the result of two SELECT statements and removes duplicate rows?

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

32 To test for a NULL value in a WHERE clause, you must use:

A. = NULL
B. != NULL
C. IS NULL
D. IS NOT

33 What distinguishes the CHAR and VARCHAR data types?

A. CHAR is variable length, VARCHAR is fixed length.
B. CHAR holds numbers, VARCHAR holds strings.
C. CHAR is fixed length, VARCHAR is variable length.
D. There is no difference.

34 A specific value for a particular attribute in a tuple is called a:

A. Domain
B. Degree
C. Datum
D. Schema

35 The SAVEPOINT command is used to:

A. Save the file to the disk.
B. Identify a point in a transaction to which you can later roll back.
C. Commit the transaction.
D. Create a backup of the database.

36 In the relational model, the number of attributes in a relation is called its:

A. Cardinality
B. Degree
C. Domain
D. Extension

37 In the relational model, the number of tuples (rows) in a relation is called its:

A. Cardinality
B. Degree
C. Schema
D. Relation

38 Which SQL operator is used to specify a pattern for the column to match using wildcards?

A. MATCH
B. LIKE
C. REGEXP
D. SIMILAR

39 Which of the following creates a virtual table based on the result-set of an SQL statement?

A. TRIGGER
B. PROCEDURE
C. VIEW
D. INDEX

40 If we want to remove the privilege to update a table from a user, we use:

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

41 Which constraint ensures that a column cannot have a NULL value?

A. CHECK
B. NOT NULL
C. UNIQUE
D. DISTINCT

42 In the statement SELECT count(*) FROM Student, what does the query return?

A. The number of distinct names in Student.
B. The number of columns in Student.
C. The total number of rows (tuples) in the Student table.
D. The values of the primary key.

43 What is the correct order of execution for the following clauses in a SELECT query?

A. SELECT, FROM, WHERE, GROUP BY
B. FROM, WHERE, GROUP BY, HAVING, SELECT
C. SELECT, WHERE, FROM, HAVING
D. WHERE, FROM, SELECT, GROUP BY

44 A Domain Constraint defines:

A. Relationships between tables.
B. Valid set of values for an attribute.
C. Uniqueness of rows.
D. Access control for users.

45 Which DML statement is used to delete specific rows from a table based on a condition?

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

46 Using the IN operator is shorthand for:

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

47 If you want to rename a table column in the output of a query (not in the database schema), you use:

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

48 The default sort order for the ORDER BY clause is:

A. Descending (DESC)
B. Ascending (ASC)
C. Random
D. Creation order

49 Which of the following is NOT a type of integrity constraint?

A. Entity Integrity
B. Referential Integrity
C. Transaction Integrity
D. Domain Integrity

50 What is the output of SELECT 10 + NULL; in standard SQL?

A. 10
B. 0
C. NULL
D. Error