1Which 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)
Correct Answer: DDL (Data Definition Language)
Explanation:DDL (Data Definition Language) includes commands like CREATE, ALTER, and DROP that are used to define and modify the structure (schema) of the database.
Incorrect! Try again.
2Which of the following commands is a DML command?
A.TRUNCATE
B.ALTER
C.UPDATE
D.GRANT
Correct Answer: UPDATE
Explanation:UPDATE is a Data Manipulation Language (DML) command used to modify existing data within a table. TRUNCATE and ALTER are DDL, and GRANT is DCL.
Incorrect! Try again.
3Which 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
Correct Answer: DROP
Explanation:The DROP TABLE command removes the table structure, its definition, and all its data permanently. DELETE only removes rows but keeps the structure.
Incorrect! Try again.
4The TRUNCATE command in SQL belongs to which category?
A.DML
B.DDL
C.DCL
D.TCL
Correct Answer: DDL
Explanation:Although TRUNCATE removes data, it is considered a DDL command because it resets the table structure (effectively dropping and recreating the table) and cannot be rolled back in many implementations without transaction contexts.
Incorrect! Try again.
5Which command is used to grant access privileges to a user?
A.REVOKE
B.ACCESS
C.PERMIT
D.GRANT
Correct Answer: GRANT
Explanation:GRANT is a Data Control Language (DCL) command used to provide specific privileges to users.
Incorrect! Try again.
6Which of the following is a TCL (Transaction Control Language) command?
A.COMMIT
B.SELECT
C.INSERT
D.CREATE
Correct Answer: COMMIT
Explanation:COMMIT is a TCL command used to save all changes made during the current transaction permanently.
Incorrect! Try again.
7What 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.
Correct Answer: It undoes transactions that have not yet been committed.
Explanation:ROLLBACK restores the database to the state it was in at the start of the transaction or at the last SAVEPOINT.
Incorrect! Try again.
8If 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
Correct Answer: Super Key
Explanation:A Super Key is a set of one or more attributes that, taken collectively, allow us to identify uniquely a tuple in the relation.
Incorrect! Try again.
9A 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.
Correct Answer: A minimal Super Key.
Explanation:A Candidate Key is a super key for which no proper subset is a super key (it implies minimality).
Incorrect! Try again.
10Which integrity constraint ensures that the Primary Key attributes cannot be NULL?
A.Referential Integrity
B.Domain Integrity
C.Entity Integrity
D.Key Integrity
Correct Answer: Entity Integrity
Explanation:The Entity Integrity rule states that no primary key attribute may be NULL, as the primary key identifies a specific entity.
Incorrect! Try again.
11Consider 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.
Correct Answer: is a super key.
Explanation:If is a candidate key (and thus a super key), any superset of it (like ) is automatically a super key.
Incorrect! Try again.
12A 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
Correct Answer: Referential Integrity
Explanation:Referential Integrity ensures that a value that appears in one relation for a given set of attributes also appears for a certain set of attributes in another relation.
Incorrect! Try again.
13If 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
Correct Answer: Primary Key
Explanation:The Primary Key is the specific candidate key selected to be the main identifier for tuples in a relation.
Incorrect! Try again.
14Candidate keys that are not chosen as the primary key are known as:
A.Super Keys
B.Foreign Keys
C.Alternate Keys
D.Secondary Keys
Correct Answer: Alternate Keys
Explanation:An Alternate Key is a candidate key that was not selected to be the primary key.
Incorrect! Try again.
15Which 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.
Correct Answer: It can contain NULL values.
Explanation:Primary keys must contain unique values and cannot contain NULL values (Entity Integrity).
Incorrect! Try again.
16A key consisting of more than one attribute is called a:
A.Foreign Key
B.Composite Key
C.Domain Key
D.Simple Key
Correct Answer: Composite Key
Explanation:A Composite Key is a primary or candidate key that consists of two or more attributes.
Incorrect! Try again.
17Which SQL constraint restricts the values of a column to a specific set or range?
A.UNIQUE
B.DEFAULT
C.CHECK
D.INDEX
Correct Answer: CHECK
Explanation:The CHECK constraint ensures that all values in a column satisfy a specific condition (Boolean expression).
Incorrect! Try again.
18In 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.
Correct Answer: It deletes the rows in the child table that reference the deleted row in the parent table.
Explanation:ON DELETE CASCADE automatically deletes the dependent rows in the child table when the corresponding referenced row in the parent table is deleted.
Incorrect! Try again.
19Which SQL clause is used to retrieve unique records only?
A.UNIQUE
B.DIFFERENT
C.DISTINCT
D.SEPARATE
Correct Answer: DISTINCT
Explanation:The SELECT DISTINCT statement is used to return only distinct (different) values.
Incorrect! Try again.
20In SQL, the wildcard character % corresponds to:
A.Exactly one character.
B.Zero or more characters.
C.Exactly zero characters.
D.One or more characters.
Correct Answer: Zero or more characters.
Explanation:In the LIKE operator, % represents zero, one, or multiple characters.
Incorrect! Try again.
21In 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.
Correct Answer: Exactly one character.
Explanation:The underscore _ represents exactly one character in pattern matching.
Incorrect! Try again.
22What 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
Correct Answer: tuples
Explanation:This performs a Cartesian Product (Cross Join), resulting in every tuple of being combined with every tuple of .
Incorrect! Try again.
23Which clause is used to filter records after grouping has occurred?
A.WHERE
B.HAVING
C.ORDER BY
D.GROUP BY
Correct Answer: HAVING
Explanation:The HAVING clause was added to SQL because the WHERE keyword could not be used with aggregate functions. HAVING filters groups.
Incorrect! Try again.
24Which SQL keyword is used to sort the result-set?
A.SORT BY
B.ORDER BY
C.ALIGN
D.GROUP BY
Correct Answer: ORDER BY
Explanation:ORDER BY is used to sort the result-set in ascending or descending order.
Incorrect! Try again.
25Which of the following is an aggregate function in SQL?
A.AVG()
B.LIKE
C.ROUND()
D.UPPER()
Correct Answer: AVG()
Explanation:AVG() is an aggregate function that returns the average value of a numeric column. ROUND and UPPER are scalar functions.
Incorrect! Try again.
26The 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
Correct Answer: Inclusive
Explanation:The BETWEEN operator is inclusive: begin and end values are included.
Incorrect! Try again.
27Which 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
Correct Answer: UNIQUE
Explanation:A UNIQUE constraint ensures all values in a column are different. Unlike Primary Key, it usually allows (multiple) NULL values, though this depends on the specific RDBMS implementation.
Incorrect! Try again.
28The 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.
Correct Answer: Add a new column to an existing table.
Explanation:This is a DDL command used to add a new attribute (column) to an existing relation.
Incorrect! Try again.
29What 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.
Correct Answer: To rename a table or column temporarily for a query.
Explanation:Aliases are used to give a table, or a column in a table, a temporary name to make query results more readable.
Incorrect! Try again.
30Which set operation returns only the rows that appear in both result sets?
A.UNION
B.UNION ALL
C.INTERSECT
D.EXCEPT
Correct Answer: INTERSECT
Explanation:INTERSECT returns the common records from two select statements.
Incorrect! Try again.
31Which set operation combines the result of two SELECT statements and removes duplicate rows?
A.UNION
B.UNION ALL
C.JOIN
D.MINUS
Correct Answer: UNION
Explanation:UNION combines the result-set of two or more SELECT statements and removes duplicates by default. UNION ALL allows duplicates.
Incorrect! Try again.
32To test for a NULL value in a WHERE clause, you must use:
A.= NULL
B.!= NULL
C.IS NULL
D.IS NOT
Correct Answer: IS NULL
Explanation:You cannot use comparison operators like = or != with NULL. You must use IS NULL or IS NOT NULL.
Incorrect! Try again.
33What 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.
Correct Answer: CHAR is fixed length, VARCHAR is variable length.
Explanation:CHAR stores fixed-length strings (padded with spaces), while VARCHAR stores variable-length strings (only using necessary storage plus a length byte).
Incorrect! Try again.
34A specific value for a particular attribute in a tuple is called a:
A.Domain
B.Degree
C.Datum
D.Schema
Correct Answer: Datum
Explanation:While often just called a value, technically it's a datum. In the context of the options, it represents the intersection of a row and column.
Incorrect! Try again.
35The 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.
Correct Answer: Identify a point in a transaction to which you can later roll back.
Explanation:SAVEPOINT creates points within a transaction. ROLLBACK TO savepoint_name allows undoing part of a transaction without rolling back the whole thing.
Incorrect! Try again.
36In the relational model, the number of attributes in a relation is called its:
A.Cardinality
B.Degree
C.Domain
D.Extension
Correct Answer: Degree
Explanation:The degree (or arity) of a relation is the number of attributes (columns) it contains.
Incorrect! Try again.
37In the relational model, the number of tuples (rows) in a relation is called its:
A.Cardinality
B.Degree
C.Schema
D.Relation
Correct Answer: Cardinality
Explanation:Cardinality refers to the number of tuples or rows in the relation.
Incorrect! Try again.
38Which SQL operator is used to specify a pattern for the column to match using wildcards?
A.MATCH
B.LIKE
C.REGEXP
D.SIMILAR
Correct Answer: LIKE
Explanation:The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.
Incorrect! Try again.
39Which of the following creates a virtual table based on the result-set of an SQL statement?
A.TRIGGER
B.PROCEDURE
C.VIEW
D.INDEX
Correct Answer: VIEW
Explanation:A VIEW is a virtual table whose contents are defined by a query. It does not store data itself but displays data stored in other tables.
Incorrect! Try again.
40If 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
Correct Answer: REVOKE UPDATE
Explanation:REVOKE is the DCL command used to remove previously granted permissions.
Incorrect! Try again.
41Which constraint ensures that a column cannot have a NULL value?
A.CHECK
B.NOT NULL
C.UNIQUE
D.DISTINCT
Correct Answer: NOT NULL
Explanation:The NOT NULL constraint enforces a column to accept a value for every row.
Incorrect! Try again.
42In 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.
Correct Answer: The total number of rows (tuples) in the Student table.
Explanation:COUNT(*) returns the number of rows in a specified table, including rows with NULL values.
Incorrect! Try again.
43What 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
Correct Answer: FROM, WHERE, GROUP BY, HAVING, SELECT
Explanation:The logical processing order is: 1. FROM (identify table), 2. WHERE (filter rows), 3. GROUP BY (aggregate), 4. HAVING (filter groups), 5. SELECT (return columns).
Incorrect! Try again.
44A Domain Constraint defines:
A.Relationships between tables.
B.Valid set of values for an attribute.
C.Uniqueness of rows.
D.Access control for users.
Correct Answer: Valid set of values for an attribute.
Explanation:Domain constraints specify that the value of each attribute must be an atomic value from the domain (e.g., integer, string, specific range).
Incorrect! Try again.
45Which DML statement is used to delete specific rows from a table based on a condition?
A.DROP
B.TRUNCATE
C.DELETE
D.REMOVE
Correct Answer: DELETE
Explanation:DELETE FROM table_name WHERE condition; removes specific rows. Without the WHERE clause, it removes all rows.
Incorrect! Try again.
46Using the IN operator is shorthand for:
A.Multiple AND conditions
B.Multiple OR conditions
C.A BETWEEN condition
D.A LIKE condition
Correct Answer: Multiple OR conditions
Explanation:WHERE column IN (A, B, C) is equivalent to WHERE column = A OR column = B OR column = C.
Incorrect! Try again.
47If 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
Correct Answer: AS
Explanation:The AS keyword is used to provide an alias for a column in the result set.
Incorrect! Try again.
48The default sort order for the ORDER BY clause is:
A.Descending (DESC)
B.Ascending (ASC)
C.Random
D.Creation order
Correct Answer: Ascending (ASC)
Explanation:If ASC or DESC is not specified, SQL defaults to Ascending order.
Incorrect! Try again.
49Which of the following is NOT a type of integrity constraint?
A.Entity Integrity
B.Referential Integrity
C.Transaction Integrity
D.Domain Integrity
Correct Answer: Transaction Integrity
Explanation:Transaction Integrity is a property of the system (ACID properties), not a standard structural integrity constraint defined in the schema like Entity, Referential, or Domain integrity.
Incorrect! Try again.
50What is the output of SELECT 10 + NULL; in standard SQL?
A.10
B.0
C.NULL
D.Error
Correct Answer: NULL
Explanation:In SQL, any arithmetic operation performed with NULL results in NULL (Null propagation).