Mock Quiz Hub
Dark
Mock Quiz Hub
1
Recent Updates
Added: OS Mid 1 Quiz
Added: OS Mid 2 Quiz
Added: OS Lab 1 Quiz
Check back for more updates!
Time: 00:00
Quiz
Navigate through questions using the controls below
0%
Question 1 of 60
Quiz ID: 1
Which SQL standard was the first to be formally adopted by ANSI and ISO?
SQL-86
SQL-89
SQL-92
SQL:1999
Question 2 of 60
Quiz ID: 2
What is the key difference between CHAR(n) and VARCHAR(n) data types?
CHAR(n) has variable length while VARCHAR(n) has fixed length
CHAR(n) has fixed length while VARCHAR(n) has variable length
CHAR(n) supports Unicode while VARCHAR(n) does not
CHAR(n) is for numbers while VARCHAR(n) is for text
Question 3 of 60
Quiz ID: 3
What happens when you declare an attribute as PRIMARY KEY in a CREATE TABLE statement?
It automatically becomes NOT NULL and UNIQUE
It automatically becomes FOREIGN KEY
It allows NULL values by default
It creates an index but allows duplicates
Question 4 of 60
Quiz ID: 4
What is the difference between DROP TABLE and DELETE FROM statements?
DROP TABLE deletes content and structure, DELETE FROM only deletes content
DELETE FROM deletes content and structure, DROP TABLE only deletes content
Both statements perform identical operations
DROP TABLE is for temporary tables, DELETE FROM is for permanent tables
Question 5 of 60
Quiz ID: 5
In the basic SQL query structure SELECT A1, A2 FROM r1, r2 WHERE P, what does the WHERE clause correspond to in relational algebra?
Projection operation
Selection operation
Cartesian product operation
Join operation
Question 6 of 60
Quiz ID: 6
When would you use the DISTINCT keyword in a SELECT clause?
To select only unique column names
To eliminate duplicate tuples from the query result
To make the query case-sensitive
To select only distinct data types
Question 7 of 60
Quiz ID: 7
What does the asterisk (*) represent in a SELECT clause?
It selects only primary key columns
It selects all attributes from the specified relations
It performs multiplication operations
It indicates a required parameter
Question 8 of 60
Quiz ID: 8
In the FROM clause, what operation does listing multiple relations correspond to in relational algebra?
Selection
Projection
Cartesian product
Natural join
Question 9 of 60
Quiz ID: 9
What is the primary purpose of the WHERE clause in an SQL query?
To specify which tables to query
To define the output format
To specify conditions that result tuples must satisfy
To order the result set
Question 10 of 60
Quiz ID: 10
What is the main risk when using NATURAL JOIN?
It requires more memory than other joins
It can incorrectly equate unrelated attributes with the same name
It only works with numeric data types
It doesn't support foreign key relationships
Question 11 of 60
Quiz ID: 11
What is the purpose of the AS clause in SQL?
To create new tables
To rename relations or attributes in the query result
To specify aggregate functions
To define subqueries
Question 12 of 60
Quiz ID: 12
How does the ORDER BY clause sort results by default?
Descending order
Random order
Ascending order
By primary key order
Question 13 of 60
Quiz ID: 13
What does the LIKE operator with pattern '%dar%' match?
Exactly 'dar'
Any string starting with 'dar'
Any string containing 'dar' as a substring
Any string ending with 'dar'
Question 14 of 60
Quiz ID: 14
What is the purpose of the BETWEEN operator in SQL?
To compare two tables
To check if a value is within a specified range
To perform string pattern matching
To join tables based on range conditions
Question 15 of 60
Quiz ID: 15
Which aggregate function calculates the average value of a numeric column?
SUM()
AVG()
COUNT()
MAX()
Question 16 of 60
Quiz ID: 16
What does COUNT(*) aggregate function do?
Counts only distinct values
Counts all tuples, including those with NULL values
Counts only non-NULL values
Counts only primary key values
Question 17 of 60
Quiz ID: 17
When must attributes appear in the GROUP BY clause?
When they are used in aggregate functions
When they are mentioned in the SELECT clause outside of aggregate functions
When they are foreign keys
When they have NULL values
Question 18 of 60
Quiz ID: 18
What is the key difference between WHERE and HAVING clauses?
WHERE is for grouping, HAVING is for filtering
WHERE filters rows before grouping, HAVING filters groups after grouping
HAVING is used with aggregate functions, WHERE is not
WHERE is for joins, HAVING is for subqueries
Question 19 of 60
Quiz ID: 19
How do aggregate functions typically handle NULL values?
They treat NULL as zero
They include NULL in calculations
They ignore NULL values in the aggregated column
They convert NULL to empty strings
Question 20 of 60
Quiz ID: 20
What is a nested subquery in SQL?
A query that uses multiple FROM clauses
A select-from-where expression nested within another query
A query that references itself
A query with multiple SELECT statements
Question 21 of 60
Quiz ID: 21
Which SQL data type would be most appropriate for storing a product price with exactly 2 decimal places?
INT
REAL
NUMERIC(p,d)
VARCHAR(n)
Question 22 of 60
Quiz ID: 22
What is the practical difference between DROP TABLE and ALTER TABLE DROP?
DROP TABLE removes the entire table, ALTER TABLE DROP removes only a column
ALTER TABLE DROP removes the entire table, DROP TABLE removes only a column
Both perform identical operations but with different syntax
DROP TABLE is faster but less secure
Question 23 of 60
Quiz ID: 23
In a practical scenario, when would you use SELECT DISTINCT?
When you want to see all possible values including duplicates
When you need to eliminate duplicate rows from your result set
When you're selecting from multiple tables
When you're using aggregate functions
Question 24 of 60
Quiz ID: 24
Why might you use arithmetic expressions in the SELECT clause?
To perform calculations on retrieved data
To create new tables
To filter query results
To join multiple tables
Question 25 of 60
Quiz ID: 25
In a real-world database, why would you use table aliases with the AS clause?
To shorten long table names in queries involving multiple joins
To change the actual table names in the database
To improve database performance
To encrypt table names
Question 26 of 60
Quiz ID: 26
When would you use the ORDER BY clause in a practical application?
To alphabetize customer names in a report
To filter out unwanted records
To calculate totals and averages
To create new database tables
Question 27 of 60
Quiz ID: 27
In what practical situation would you use the LIKE operator with pattern matching?
To find customers with names containing 'smith'
To calculate average sales figures
To join customer and order tables
To create backup copies of tables
Question 28 of 60
Quiz ID: 28
Why would you use the BETWEEN operator instead of multiple AND conditions?
It makes range queries more readable and concise
It executes faster than equivalent AND conditions
It works with string data while AND doesn't
It automatically excludes NULL values
Question 29 of 60
Quiz ID: 29
In a sales database, which aggregate function would you use to find the total revenue?
AVG()
SUM()
COUNT()
MAX()
Question 30 of 60
Quiz ID: 30
When would you use GROUP BY in a practical business scenario?
To calculate total sales by product category
To alphabetize a customer list
To find a specific customer record
To update product prices
Question 31 of 60
Quiz ID: 31
In what scenario would you use HAVING instead of WHERE?
When filtering groups based on aggregate values
When filtering individual rows before grouping
When joining multiple tables
When creating new tables
Question 32 of 60
Quiz ID: 32
Why might you use nested subqueries in a real application?
To find customers who placed orders in the last month
To update all prices in a single operation
To create backup copies of tables
To improve database performance
Question 33 of 60
Quiz ID: 33
What is a practical use of foreign key constraints?
To prevent orphan records and maintain referential integrity
To improve query performance
To encrypt database relationships
To automatically backup related tables
Question 34 of 60
Quiz ID: 34
In a customer orders database, which query would find customers from 'Moratuwa'?
SELECT * FROM customers WHERE city = 'Moratuwa'
SELECT * FROM orders WHERE city = 'Moratuwa'
UPDATE customers SET city = 'Moratuwa'
DELETE FROM customers WHERE city != 'Moratuwa'
Question 35 of 60
Quiz ID: 35
How would you find employees who earn more than their department's average salary?
Using a subquery with AVG() in WHERE clause
Using ORDER BY with DESC
Using NATURAL JOIN without conditions
Using LIKE with pattern matching
Question 36 of 60
Quiz ID: 36
Which query would list projects with budgets over 1,000,000?
SELECT proj_name FROM project WHERE budget > 1000000
SELECT proj_name FROM project WHERE budget < 1000000
UPDATE project SET budget = 1000000
DELETE FROM project WHERE budget <= 1000000
Question 37 of 60
Quiz ID: 37
How would you find the number of employees in each city?
SELECT city, COUNT(*) FROM employee GROUP BY city
SELECT COUNT(*) FROM employee ORDER BY city
SELECT city FROM employee WHERE COUNT(*) > 0
UPDATE employee SET city = COUNT(*)
Question 38 of 60
Quiz ID: 38
What query would find the highest salary in each department?
SELECT dept, MAX(salary) FROM employee GROUP BY dept
SELECT dept, salary FROM employee ORDER BY salary DESC
SELECT MAX(salary) FROM employee WHERE dept IS NOT NULL
UPDATE employee SET salary = MAX(salary)
Question 39 of 60
Quiz ID: 39
How would you find employees who work on projects located in their home city?
Using a join between employee and project tables with city comparison
Using ORDER BY on city columns
Using AVG() aggregate function
Using LIKE with wildcard patterns
Question 40 of 60
Quiz ID: 40
Which query would update salaries by giving a 10% raise to all employees?
UPDATE employee SET salary = salary * 1.10
SELECT salary * 1.10 FROM employee
DELETE FROM employee WHERE salary = salary * 1.10
INSERT INTO employee VALUES (salary * 1.10)
Question 41 of 60
Quiz ID: 41
How would you find the total hours worked on each project?
SELECT proj_no, SUM(hours) FROM assignment GROUP BY proj_no
SELECT proj_no, hours FROM assignment ORDER BY hours
SELECT SUM(hours) FROM assignment WHERE proj_no IS NOT NULL
UPDATE assignment SET hours = SUM(hours)
Question 42 of 60
Quiz ID: 42
What is the practical purpose of the NOT NULL constraint?
To ensure critical data is always provided
To make queries run faster
To allow duplicate values
To create automatic backups
Question 43 of 60
Quiz ID: 43
In an e-commerce database, how would you find products that have never been ordered?
Using a subquery with NOT IN
Using ORDER BY with ASC
Using NATURAL JOIN without conditions
Using AVG() aggregate function
Question 44 of 60
Quiz ID: 44
Which SQL operation would you use to combine customer names with their order dates?
JOIN between customers and orders tables
UNION of customers and orders tables
GROUP BY on customer_id
UPDATE customers SET order_date
Question 45 of 60
Quiz ID: 45
How would you find the most expensive product in each category?
Using GROUP BY with MAX() and a subquery or window function
Using ORDER BY with LIMIT 1
Using LIKE with pattern matching
Using UPDATE with MAX()
Question 46 of 60
Quiz ID: 46
What is a practical use of the DISTINCT keyword with COUNT()?
To count unique values in a column
To make the count faster
To count all values including duplicates
To ignore NULL values automatically
Question 47 of 60
Quiz ID: 47
How would you find employees who have the same salary as their manager?
Using self-join with salary comparison
Using GROUP BY with AVG()
Using ORDER BY with DESC
Using LIKE with exact match
Question 48 of 60
Quiz ID: 48
Which query would delete all orders older than 5 years?
DELETE FROM orders WHERE order_date < CURRENT_DATE - INTERVAL '5 years'
SELECT * FROM orders WHERE order_date < 5
UPDATE orders SET order_date = NULL WHERE order_date IS OLD
DROP TABLE orders WHERE order_date < 5
Question 49 of 60
Quiz ID: 49
How would you find the average order value for each customer?
SELECT customer_id, AVG(order_total) FROM orders GROUP BY customer_id
SELECT AVG(order_total) FROM orders ORDER BY customer_id
SELECT customer_id FROM orders WHERE AVG(order_total) > 0
UPDATE orders SET order_total = AVG(order_total)
Question 50 of 60
Quiz ID: 50
What is the practical purpose of using transactions with SQL statements?
To ensure multiple operations succeed or fail together
To make individual queries run faster
To automatically create table backups
To simplify SQL syntax
Question 51 of 60
Quiz ID: 51
How would you find products that are priced above the average price of all products?
Using a subquery with AVG() in WHERE clause
Using GROUP BY with HAVING
Using NATURAL JOIN without conditions
Using ORDER BY with DESC LIMIT 1
Question 52 of 60
Quiz ID: 52
Which SQL feature would you use to ensure email addresses are unique across users?
UNIQUE constraint on email column
PRIMARY KEY on email column
FOREIGN KEY referencing another table
LIKE with pattern matching
Question 53 of 60
Quiz ID: 53
How would you find the top 3 highest-paid employees?
SELECT name, salary FROM employee ORDER BY salary DESC LIMIT 3
SELECT MAX(salary) FROM employee GROUP BY name LIMIT 3
SELECT name, salary FROM employee WHERE salary = TOP3
UPDATE employee SET salary = TOP3
Question 54 of 60
Quiz ID: 54
What is a practical use of the COALESCE function?
To replace NULL values with default values
To calculate averages ignoring zeros
To concatenate strings with spaces
To convert numbers to strings
Question 55 of 60
Quiz ID: 55
How would you update product prices by applying a 15% discount to discontinued items?
UPDATE products SET price = price * 0.85 WHERE discontinued = true
SELECT price * 0.85 FROM products WHERE discontinued
DELETE FROM products WHERE price = price * 0.85
INSERT INTO products VALUES (price * 0.85)
Question 56 of 60
Quiz ID: 56
Which query would find customers who have placed more than 5 orders?
SELECT customer_id FROM orders GROUP BY customer_id HAVING COUNT(*) > 5
SELECT customer_id FROM orders WHERE COUNT(*) > 5
SELECT customer_id FROM orders ORDER BY COUNT(*) DESC
UPDATE orders SET customer_id = 5 WHERE COUNT(*) > 5
Question 57 of 60
Quiz ID: 57
How would you calculate the total sales for the current month?
SELECT SUM(amount) FROM sales WHERE EXTRACT(MONTH FROM sale_date) = EXTRACT(MONTH FROM CURRENT_DATE)
SELECT SUM(amount) FROM sales WHERE sale_date = THIS_MONTH
SELECT amount FROM sales ORDER BY sale_date DESC
UPDATE sales SET amount = SUM(amount)
Question 58 of 60
Quiz ID: 58
What is the practical purpose of database indexes?
To speed up query performance on frequently searched columns
To store backup copies of table data
To encrypt sensitive column data
To automatically update related tables
Question 59 of 60
Quiz ID: 59
How would you find employees who were hired in the last 30 days?
SELECT name FROM employees WHERE hire_date >= CURRENT_DATE - INTERVAL '30 days'
SELECT name FROM employees WHERE hire_date < 30
SELECT name FROM employees ORDER BY hire_date DESC LIMIT 30
UPDATE employees SET hire_date = CURRENT_DATE - 30
Question 60 of 60
Quiz ID: 60
Why would you use SQL views in a practical application?
To simplify complex queries and provide a security layer
To make physical copies of tables for backup
To improve database storage efficiency
To automatically optimize query performance
Quiz Summary
Review your answers before submitting
60
Total Questions
0
Answered
60
Remaining
00:00
Time Spent
Submit Quiz
Back to Questions
Previous
Question 1 of 60
Next
!
Confirm Submission
Cancel
Submit Quiz