Showing 41–50 of 100 questions
in Database/SQL
Which of the following is a ACID property that ensures all or nothing transaction execution?
A
Atomicity
B
Consistency
C
Isolation
D
Durability
Correct Answer:
A. Atomicity
Explanation:
Atomicity ensures that a transaction is treated as a single unit - either all operations complete or none do.
What is the primary advantage of using INNER JOIN over OUTER JOIN in SQL?
A
It processes faster for small datasets
B
It returns only matching records from both tables
C
It uses less memory than OUTER JOIN
D
It can handle NULL values better
Correct Answer:
B. It returns only matching records from both tables
Explanation:
INNER JOIN returns only rows that have matching values in both tables, making queries more efficient for specific requirements.
In a relational database, what does normalization primarily aim to eliminate?
A
NULL values
B
Data redundancy and anomalies
C
Foreign key constraints
D
Index creation
Correct Answer:
B. Data redundancy and anomalies
Explanation:
Normalization removes data redundancy and prevents update, insertion, and deletion anomalies through organized table structures.
Which algorithm has O(n log n) time complexity and is preferred for large datasets in modern databases?
A
Bubble Sort
B
Merge Sort
C
Selection Sort
D
Insertion Sort
Correct Answer:
B. Merge Sort
Explanation:
Merge Sort maintains O(n log n) complexity in all cases and is stable, making it ideal for sorting large datasets.
What is the primary purpose of indexing in databases?
A
To reduce storage space
B
To speed up data retrieval operations
C
To enforce data integrity
D
To manage concurrent access
Correct Answer:
B. To speed up data retrieval operations
Explanation:
Indexes create a faster lookup structure similar to a book's index, enabling rapid data retrieval without full table scans.
In the OSI model, which layer is responsible for routing and logical addressing?
A
Physical Layer
B
Data Link Layer
C
Network Layer
D
Transport Layer
Correct Answer:
C. Network Layer
Explanation:
The Network Layer (Layer 3) handles routing, IP addressing, and logical path determination for data packets.
Which of the following is NOT a characteristic of relational databases?
A
ACID compliance
B
Flexible schema
C
Structured data storage
D
Data integrity constraints
Correct Answer:
B. Flexible schema
Explanation:
Relational databases have fixed schemas. Flexible schemas are a characteristic of NoSQL databases like MongoDB.
What does CAP theorem state about distributed database systems?
A
All three properties can be achieved simultaneously
B
Only two of Consistency, Availability, and Partition tolerance can be guaranteed
C
Consistency is always sacrificed first
D
Partition tolerance is optional in modern systems
Correct Answer:
B. Only two of Consistency, Availability, and Partition tolerance can be guaranteed
Explanation:
CAP theorem proves that distributed systems can guarantee at most 2 of 3 properties: Consistency, Availability, and Partition tolerance.
In SQL, what is the difference between HAVING and WHERE clauses?
A
Both serve identical purposes
B
WHERE filters rows before grouping; HAVING filters groups after aggregation
C
HAVING is used for individual row filtering
D
WHERE can only be used with JOIN operations
Correct Answer:
B. WHERE filters rows before grouping; HAVING filters groups after aggregation
Explanation:
WHERE clause filters individual rows before GROUP BY, while HAVING filters aggregated groups after GROUP BY.
Which data structure is most efficient for implementing a LRU (Least Recently Used) cache?
A
Array
B
Hash Map + Doubly Linked List
C
Binary Search Tree
D
Queue only
Correct Answer:
B. Hash Map + Doubly Linked List
Explanation:
Hash Map provides O(1) lookup while Doubly Linked List maintains insertion order and allows O(1) removal/reordering.