0% found this document useful (0 votes)
3 views6 pages

Sequel Set A

The document contains a series of SQL-related questions categorized into easy, medium, and hard difficulty levels. Each question presents a scenario followed by multiple-choice options, testing knowledge on SQL commands, database design, ACID properties, and optimization strategies. It aims to assess understanding of SQL concepts and best practices in various contexts.

Uploaded by

riduvarshinias
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views6 pages

Sequel Set A

The document contains a series of SQL-related questions categorized into easy, medium, and hard difficulty levels. Each question presents a scenario followed by multiple-choice options, testing knowledge on SQL commands, database design, ACID properties, and optimization strategies. It aims to assess understanding of SQL concepts and best practices in various contexts.

Uploaded by

riduvarshinias
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Sequel - Set A

Easy (10 Questions)


1. Scenario: Alex, a new developer, is asked to fetch all employee names and salaries
from the employees table. He’s unsure which SQL command to use.

Question: Which query should Alex write to retrieve this data?

a) SELECT names, salaries FROM employees;


b) SELECT employee_name, salary FROM employees;
c) GET employee_name, salary FROM employees;
d) FETCH * FROM employees;

2. Scenario: A database designer is creating a students table and needs a column to


uniquely identify each student.
Question: Which key should they use to enforce uniqueness?
a) Foreign Key
b) Composite Key
c) Primary Key

d) Alternate Key

3. Scenario: During a transaction, a power outage occurs. The database must ensure
no partial updates are saved.
Question: Which ACID property guarantees this behavior?
a) Atomicity
b) Consistency
c) Isolation
d) Durability

4. Scenario: A user wants to count how many orders were placed in March 2023 using
the orders table.
Question: Which query achieves this?

a) SELECT TOTAL(orders) WHERE order_date = '2023-03';


b) SELECT COUNT(*) FROM orders WHERE order_date BETWEEN '2023-03-01'

Sequel - Set A 1
AND '2023-03-31';
c) SELECT SUM(*) FROM orders FOR MONTH(order_date) = 3;
d) COUNT ALL orders IN March 2023;

5. Scenario: A team is building a social media app and needs a NoSQL database for
flexible, nested user profiles.
Question: Which NoSQL type is best suited?
a) Key-Value
b) Document
c) Graph
d) Column-family

6. Scenario: A query uses WHERE age >= 18 AND country = 'Canada' .


Question: What does this filter do?
a) It filters columns
b) It filters rows
c) It groups data

d) It sorts data

7. Scenario: A developer writes SELECT DISTINCT department FROM employees; .

Question: What does this query return?


a) All departments, including duplicates

b) Unique department names


c) The first department alphabetically

d) Departments with the most employees

8. Scenario: A company wants to store email addresses but prevent storing duplicate
values.

Question: Which SQL constraint ensures this?

a) PRIMARY KEY
b) FOREIGN KEY

c) UNIQUE
d) NOT NULL

Sequel - Set A 2
9. Scenario: A query needs to return all users, even if they haven't placed orders.
Question: Which SQL JOIN type achieves this?

a) INNER JOIN
b) LEFT JOIN

c) RIGHT JOIN
d) CROSS JOIN

10. Scenario: The salary column has NULL values. A query calculates the total salary of
employees.
Question: How can you ensure NULL values don’t affect the sum?

a) Use SUM(salary) without modification

b) Use SUM(COALESCE(salary, 0))

c) Use COUNT(salary) instead

d) Replace NULL values manually

Medium (6 Questions)
11. Scenario: A retail company’s orders table has order_id , customer_id , and order_total . They
want to find customers who spent over $1,000 in total.Question: Which query
should they use?

a) SELECT customer_id FROM orders WHERE order_total > 1000;


b) SELECT customer_id, SUM(order_total) FROM orders GROUP BY customer_id HA
VING order_total > 1000;
c) SELECT customer_id FROM orders GROUP BY customer_id HAVING SUM(order_t
otal) > 1000;
d) SELECT customer_id FROM orders HAVING SUM(order_total) > 1000;

12. Scenario: A hospital database uses a patients table and a visits table linked by
. A report needs patient names and their visit dates.Question: Which JOIN is
patient_id

appropriate?

a) LEFT JOIN patients ON visits.patient_id = patients.patient_id

b) INNER JOIN visits ON patients.patient_id = visits.patient_id

c) CROSS JOIN patients, visits

d) FULL OUTER JOIN patients WITH visits

Sequel - Set A 3
13. Scenario: An e-commerce app experiences slow searches for products by name.
The team wants to optimize the products table.Question: Which indexing strategy is
best?

a) Create a clustered index on product_id

b) Create a non-clustered index on product_name

c) Use a composite index on (price, product_name)

d) Partition the table by category

14. Scenario: A distributed database splits data across regions: US users on Node 1 and
EU users on Node 2.Question: What type of fragmentation is this?

a) Horizontal (row-based)
b) Vertical (column-based)
c) Hybrid
d) Round-robin

15. Scenario: A query uses GROUP BY category HAVING COUNT(*) > 10 .Question: What does the
HAVING clause do?

a) Filters rows before grouping

b) Filters groups after aggregation


c) Orders results
d) Joins another table

16. Scenario: A company uses PostgreSQL with millions of rows in a logs table. They
want to improve performance when retrieving logs for a specific date.Question:
What should they do?

a) Create an index on log_date

b) Use ORDER BY log_date

c) Create a stored procedure


d) Increase database memory

Hard (4 Questions)
17. Scenario: A banking app processes two simultaneous transactions:

Sequel - Set A 4
T1: Transfers $100 from Account A to B.

T2: Transfers $50 from B to A.


Both transactions read initial balances before any writes.
Question: What concurrency issue occurs if they commit?

a) Dirty Read
b) Lost Update
c) Phantom Read
d) Deadlock

18. Scenario: A global database uses eventual consistency. A user updates their profile
in Sydney, then immediately queries it in London and sees old data.Question: Which
CAP theorem trade-off does this reflect?

a) Consistency sacrificed for Availability


b) Availability sacrificed for Consistency
c) Partition Tolerance prioritized

d) All three are maintained

19. Scenario: A query runs slowly:

SELECT * FROM sales


WHERE year = 2023
ORDER BY revenue DESC
LIMIT 10;

Question: How would you optimize this?

a) Add an index on year

b) Add a composite index on (year, revenue)

c) Use WHERE year >= 2023

d) Remove the LIMIT clause

20. Scenario: A large dataset has millions of sales records. The company wants to
generate real-time reports while minimizing query load.

Question: Which optimization approach is best?

a) Use database replication


b) Use stored procedures for every query

Sequel - Set A 5
c) Store precomputed aggregates in a separate table
d) Drop old records to reduce table size

Sequel - Set A 6

You might also like