Quick Revision

GK One-Line Question & Answer

15541+ short questions with short answers, covering every category and sub-category on the site — no long articles to scroll through. Good for a fast recap before an exam, or a few minutes of daily practice.

DBMS → Joins 2

Hash join should hash which table when R has 1000 rows and S has 100 rows?
S (smaller) into memory hash table then probe with R
click to copy
Which join algorithm is best when inner table has index on join attribute?
Index nested-loop join (uses index to find matching rows rapidly)
click to copy

DBMS → Transactions 2

Which 2PL variant holds ALL locks until transaction commits?
Rigorous 2PL
click to copy
In ARIES, winners (committed transactions at crash) require which recovery action?
REDO - their changes must be reapplied to ensure durability
click to copy

DBMS → Introduction to DBMS 34

Which SQL finds department with most employees?
SELECT dept_id FROM emp GROUP BY dept_id ORDER BY COUNT(*) DESC LIMIT 1
click to copy
EXPLAIN/EXPLAIN ANALYZE in SQL is used to
Show query execution plan (indexes used, join types, row estimates)
click to copy
Given R(A,B,C,D,E) with FD AB→CDE. AB+ equals
ABCDE
click to copy
π(A)(R) where R has 10 rows, A has 4 distinct values returns
4 rows
click to copy
Which creates table same structure as questions but no data?
CREATE TABLE questions_bak AS SELECT * FROM questions WHERE 1=0
click to copy
Which window function computes running total of salaries ordered by hire_date?
SELECT SUM(salary) OVER(ORDER BY hire_date) FROM emp
click to copy
DB::table('questions')->where('q_level',3)->orWhere('q_level',2)->get() generates
WHERE q_level=3 OR q_level=2
click to copy
To retrieve only active non-deleted questions in Laravel
DB::table('questions')->where('is_deleted',0)->get()
click to copy
right_answer_id storing 'option_a','option_b' etc. is which design?
Storing column name reference indicating which option column has correct answer
click to copy
question_type=1 in questions table likely represents
MCQ (Multiple Choice Question) type
click to copy
is_deleted=0 in questions table represents
Record is ACTIVE (not deleted) - soft delete pattern
click to copy
To count questions per assignment_id and q_level in one query
SELECT assignment_id,q_level,COUNT(*) as cnt FROM questions GROUP BY assignment_id,q_level
click to copy
$table->foreignId('assignment_id')->constrained() creates
UNSIGNED BIGINT column PLUS FK constraint referencing assignments.id
click to copy
MERGE statement (SQL:2003) performs
INSERT UPDATE or DELETE based on match condition (UPSERT)
click to copy
To add composite index on (assignment_id, q_level) in Laravel migration
$table->index(['assignment_id','q_level'])
click to copy
Which SQL finds duplicate right_answer_id values in questions?
SELECT right_answer_id,COUNT(*) FROM questions GROUP BY right_answer_id HAVING COUNT(*)>1
click to copy
To get correct answer text when right_answer_id='option_b' for question id=1
SELECT option_b FROM questions WHERE id=1
click to copy
Eloquent query to get hard questions for assignment 1 that are not deleted
Question::where('q_level',3)->where('assignment_id',1)->where('is_deleted',0)->get()
click to copy
solution column in questions table contains
Full explanation/solution text for the question
click to copy
$table->enum('right_answer_id',['option_a','option_b','option_c','option_d','option_e']) creates
ENUM allowing only specified values
click to copy
option_e=NULL in questions table means
Question has only 4 options (no 5th option needed)
click to copy
created_at and updated_at in questions table are managed by
Eloquent automatic timestamp management ($timestamps=true by default)
click to copy
Which command adds CHECK constraint on q_level after table creation?
ALTER TABLE questions ADD CONSTRAINT chk_level CHECK (q_level BETWEEN 1 AND 3)
click to copy
To bulk insert 2000 questions efficiently without memory issues
DB::table()->insert(array_of_2000_arrays) - single bulk INSERT statement
click to copy
Which SQL gets questions for multiple assignments (1, 2, 3)?
DB::table('questions')->whereIn('assignment_id',[1,2,3])->get()
click to copy
Database design process order is
ER Model (conceptual) → Normalize (logical) → Migrate (physical implementation)
click to copy
To retrieve the right answer option text dynamically in SQL for any question
SELECT CASE right_answer_id WHEN 'option_a' THEN option_a WHEN 'option_b' THEN option_b WHEN 'option_c' THEN option_c WHEN 'option_d' THEN option_d ELSE option_e END as answer FROM questions WHERE id=1
click to copy
Which SQL removes all questions for a specific assignment and resets auto-increment?
UPDATE questions SET is_deleted=1 WHERE assignment_id=1 (soft delete preferred)
click to copy
In ARIES, losers (uncommitted at crash) require which recovery action?
UNDO - their incomplete changes must be reversed
click to copy
B+tree with height h requires how many I/Os for point query?
h+1 I/Os (h for tree traversal + 1 to fetch actual record)
click to copy
SQL injection is prevented by
Using parameterized queries (prepared statements) and input validation
click to copy
Principle of Least Privilege means
Grant ONLY minimum permissions needed for each user's tasks
click to copy
TDE (Transparent Data Encryption) protects
Data at rest by encrypting database files on disk
click to copy
RBAC means
Access based on assigned roles - permissions granted to roles, users assigned roles
click to copy

DBMS → Functional Dependency 1

Armstrong axiom: from A→BC, we can derive?
A→B and A→C (decomposition rule)
click to copy

DBMS → Normalization 1

Normalization and Laravel migrations are related because
Migrations implement the normalized schema design in version-controlled PHP code
click to copy