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 → Introduction to DBMS 33

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
Database auditing records
ALL database activity (who did what, when, from where)
click to copy
Data masking replaces
Sensitive real data with realistic-looking but fictitious data for non-production use
click to copy
Data warehouse is characterized by
Subject-oriented, integrated, time-variant, non-volatile collection for decision support
click to copy
OLAP is optimized for
Complex analytical queries on large historical datasets
click to copy
Star schema fact table contains
Numeric measures + foreign keys to dimension tables
click to copy
ETL stands for
Extract Transform Load
click to copy
CAP theorem: during network partition choose between
Consistency OR Availability (cannot guarantee both)
click to copy
Sharding distributes
Table rows across multiple database servers based on a shard key
click to copy
NoSQL database best for social graph traversal
Graph database (Neo4j, Neptune)
click to copy
Recursive CTE requires
BASE CASE (anchor member) AND RECURSIVE CASE
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

DBMS → Transactions 1

In ARIES, winners (committed transactions at crash) require which recovery action?
REDO - their changes must be reapplied to ensure durability
click to copy

DBMS → Joins 1

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 → Views 2

Materialized view differs from regular view because
It physically stores query results and can be refreshed periodically
click to copy
WITH CHECK OPTION on updatable view ensures
Updates through view MUST satisfy view's WHERE condition
click to copy

DBMS → PL/SQL 2

INSTEAD OF trigger on a view
Intercepts DML on views and executes custom logic replacing the standard DML
click to copy
Stored procedures improve security by
Allowing users to call procedure without direct table access (execute-only permission)
click to copy