wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

DBMS_II_CSE_C

Total questions: 15

Worksheet time: 11mins

Name
Class
Date
1.

A super key?

a)


A single attribute that is guaranteed to be unique and not null

b)

Any minimal set of attributes that uniquely identifies each tuple

c)


Any set of attributes that functionally determines all attributes in the relation

d)


A set of attributes chosen by the database designer as the main identifier

2.

Why is a primary key often required to be NOT NULL and unique in a DBMS?

a)

primary keys are automatically indexed and cannot contain nulls by definition

b)

every attribute in a table must be unique and not null

c)

SQL syntax does not allow nulls in any attribute

d)

the primary key must uniquely and reliably identify each row

3.

In a table Employee(EmpID, Name, DeptID, Email), where EmpID is the primary key, which of the following could reasonably be a candidate key.

a)

(DeptID, Name)

b)


Name

c)


DeptID

d)


Email

4.

A foreign key primarily used for in a relational database

a)

Automatically create indexes for faster queries

b)

Enforce referential integrity between related tables

c)

Uniquely identify rows within its own table

d)

Minimize redundancy by decomposing relations

5.

Consider a table Order(OrderID, OrderDate, CustomerID) where CustomerID is a foreign key referencing Customer(CustomerID). What must hold for any value stored in Order.CustomerID?

a)

It must be the primary key of the Order table

b)


It must be unique within the Order table

c)


It must be null whenever the order has no products

d)

It must exist as a CustomerID value in the Customer table

6.

A composite key

a)


A key that combines multiple attributes to uniquely identify a row

b)


A primary key that is also a foreign key

c)

A key defined on a derived or computed column

d)

A key that changes automatically whenever a row is updated

7.

In a relation with attributes (A, B, C, D), suppose (A, B) is a candidate key. Which of the following is always true?

a)

(C, D) is a candidate key

b)

A alone is a super key

c)


(A, B, C) is a super key

d)

B alone is a super key

8.

Property of a candidate key in a relation

a)

It is an attribute that allows null values but must be unique

b)


It is a super key with no proper subset that is also a super key

c)

It is a super key that is not chosen as primary key

d)

It is any attribute set that participates in a foreign key relationship

9.

Find the total sales amount per customer in a table named Orders with columns CustomerID, OrderDate, and Amount. Which query best uses aggregate functions with GROUP BY?

a)


SELECT CustomerID, Amount FROM Orders GROUP BY CustomerID;

b)


SELECT CustomerID, SUM(Amount) FROM Orders;

c)

SELECT SUM(Amount) FROM Orders GROUP BY OrderDate;

d)


SELECT CustomerID, SUM(Amount) FROM Orders GROUP BY CustomerID;

10.

Given a table Orders(CustomerID, OrderDate, Amount), you want to display only customers whose total Amount is greater than 1000. Which clause should you use to filter based on the aggregate SUM(Amount) per customer?

a)

WHERE SUM(Amount) > 1000

b)

WHERE Amount > 1000

c)


HAVING SUM(Amount) > 1000

d)

ORDER BY SUM(Amount) > 1000

11.

SELECT Country, COUNT(*) AS NumCustomers FROM Customers GROUP BY Country ORDER BY NumCustomers DESC;. What is the main purpose of the ORDER BY NumCustomers DESC part?

a)

To group rows by NumCustomers before counting them

b)

To sort the grouped result so that countries with more customers appear first

c)

To filter out countries that have zero customers

d)


To rename the NumCustomers column after grouping

12.

SELECT Department, AVG(Salary) AS AvgSalary FROM Employees GROUP BY Department HAVING AVG(Salary) > 60000;. What does the HAVING clause do here?

a)


It sorts departments by average salary

b)


It filters individual rows where Salary > 60000 before grouping

c)

It prevents NULL salaries from being included in the average

d)


It filters departments whose average salary is greater than 60000 after grouping

13.

List the top 3 products by total sales amount from a Sales(ProductID, Amount) table. Which combination of clauses is most appropriate?

a)


WHERE, ORDER BY, HAVING

b)


GROUP BY, ORDER BY, LIMIT

c)


GROUP BY, HAVING, ORDER BY

d)


ORDER BY, GROUP BY, HAVING

14.

In which situation would you most likely use COUNT(DISTINCT CustomerID) instead of COUNT(*) in a query with GROUP BY?

a)


When you want to speed up the query by avoiding duplicates

b)

When you want to count all rows in each group, including duplicates

c)

When you want to count only rows where CustomerID is NULL

d)

When you want to count the number of unique customers per group

15.

Difference between WHERE and HAVING in a query that uses GROUP BY

a)


WHERE filters groups after aggregation; HAVING filters individual rows before grouping

b)

WHERE and HAVING are interchangeable once GROUP BY is used

c)


WHERE filters individual rows before grouping; HAVING filters groups after aggregation

d)


WHERE can use aggregate functions, but HAVING cannot