Showing 1–10 of 50 questions
in Database/SQL
In the context of distributed databases, which consistency model is used by most cloud-native databases like DynamoDB and offers eventual consistency?
A
Strong Consistency
B
Causal Consistency
C
Eventual Consistency
D
Linearizability
Correct Answer:
C. Eventual Consistency
EXPLANATION
Cloud-native NoSQL databases prioritize availability and partition tolerance (CAP theorem), implementing eventual consistency to handle distributed system challenges while maintaining horizontal scalability.
Which of the following SQL query optimization techniques is most effective when dealing with large fact tables in a data warehouse environment?
A
Using UNION instead of UNION ALL
B
Materialized views and denormalization
C
Increasing the number of JOINs in queries
D
Using correlated subqueries for filtering
Correct Answer:
B. Materialized views and denormalization
EXPLANATION
Data warehouses use materialized views to pre-aggregate data and strategic denormalization for faster analytical queries. These techniques significantly improve performance on large fact tables.
In database indexing, which type of index structure provides the best average-case performance for range queries in modern database systems?
A
Hash Index
B
B+ Tree Index
C
Bitmap Index
D
Full-text Index
Correct Answer:
B. B+ Tree Index
EXPLANATION
B+ Tree indexes maintain sorted order and support efficient range queries, point queries, and prefix searches. Hash indexes are faster for exact matches but cannot handle range queries efficiently.
What is the primary difference between supervised and unsupervised machine learning?
A
Supervised uses labeled data; unsupervised uses unlabeled data
B
Unsupervised is faster than supervised
C
Supervised cannot predict outcomes
D
Unsupervised requires human supervision
Correct Answer:
A. Supervised uses labeled data; unsupervised uses unlabeled data
EXPLANATION
Supervised learning trains on labeled data (features + targets); unsupervised finds patterns in unlabeled data without predefined outputs.
In cybersecurity, what is SQL injection attack?
A
Inserting legitimate SQL into database
B
Malicious SQL code injected into input fields to manipulate database queries
C
A method to optimize SQL performance
D
Splitting SQL statements across multiple lines
Correct Answer:
B. Malicious SQL code injected into input fields to manipulate database queries
EXPLANATION
SQL injection exploits vulnerable input handling to execute unintended SQL commands, potentially exposing or modifying data.
What does normalization in machine learning context primarily aim to achieve?
A
Reduce features to 2D
B
Scale features to similar ranges to improve model performance
C
Remove all outliers
D
Increase dataset size
Correct Answer:
B. Scale features to similar ranges to improve model performance
EXPLANATION
Normalization scales features (e.g., 0-1 range) preventing features with larger scales from dominating model training.
In graph algorithms, which algorithm finds the shortest path in weighted graphs?
A
DFS
B
BFS
C
Dijkstra's algorithm
D
Topological sort
Correct Answer:
C. Dijkstra's algorithm
EXPLANATION
Dijkstra's algorithm efficiently finds shortest paths from a source node to all other nodes in weighted graphs with non-negative weights.
What is the difference between DELETE and TRUNCATE in SQL?
A
DELETE is faster than TRUNCATE
B
TRUNCATE is DDL; DELETE is DML and is slower but can be rolled back
C
TRUNCATE cannot be rolled back while DELETE can
D
Both have identical functionality
Correct Answer:
B. TRUNCATE is DDL; DELETE is DML and is slower but can be rolled back
EXPLANATION
TRUNCATE is DDL (immediate, cannot be rolled back in most databases), DELETE is DML (slower, can be rolled back).
In cloud computing, which service model allows customers to run their own applications but not manage infrastructure?
A
IaaS
B
PaaS
C
SaaS
D
DBaaS
EXPLANATION
PaaS (Platform as a Service) provides a platform to develop and deploy applications without managing underlying infrastructure.
What is the time complexity of quicksort algorithm in the worst case?
A
O(n log n)
B
O(n²)
C
O(n)
D
O(log n)
EXPLANATION
Quicksort's worst-case complexity is O(n²) when pivot selection is poor, though average case is O(n log n).