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 36

EXPLAIN output 'type=ALL' in MySQL means
Full table scan - no index used (worst case for large tables)
click to copy
EXPLAIN output 'type=ref' in MySQL means
Non-unique index lookup - finds rows matching an index condition
click to copy
EXPLAIN output 'type=const' in MySQL means
Single row found via unique index or PK - fastest possible lookup
click to copy
Which SQL creates a composite index for queries filtering by assignment_id and q_level
CREATE INDEX idx ON questions(assignment_id,q_level)
click to copy
SELECT DISTINCT question_type FROM questions returns
Unique question_type values (one row per distinct type)
click to copy
To add assignment_id=3 and copy all questions from assignment 1 in SQL
INSERT INTO questions(assignment_id,...) SELECT 3,...FROM questions WHERE assignment_id=1
click to copy
TRUNCATE vs DELETE: which can be rolled back (in most databases)
DELETE can be rolled back (DML); TRUNCATE typically cannot (DDL in most databases)
click to copy
Which SQL gets all questions where solution contains the word 'DBMS'
SELECT * FROM questions WHERE solution LIKE '%DBMS%'
click to copy
DB::table('questions')->where('question','LIKE','%DBMS%')->get() generates
SELECT * FROM questions WHERE question LIKE '%DBMS%'
click to copy
To get paginated questions (page 3, 10 per page) in Laravel
DB::table('questions')->skip(20)->take(10)->get()
click to copy
Laravel Eloquent selectRaw('option_a as correct_answer') WHERE right_answer_id = 'option_a' uses
SELECT with alias
click to copy
To find questions where right_answer_id is not one of the standard options
SELECT * FROM questions WHERE right_answer_id NOT IN ('option_a','option_b','option_c','option_d','option_e')
click to copy
Which Laravel method returns the count of questions per assignment efficiently
DB::table('questions')->select('assignment_id',DB::raw('COUNT(*) as cnt'))->groupBy('assignment_id')->get()
click to copy
Which SQL verifies data integrity after bulk insert of questions
SELECT * FROM questions WHERE option_a IS NULL OR option_b IS NULL OR option_c IS NULL OR option_d IS NULL OR right_answer_id IS NULL
click to copy
Which query uses window function to find rank of each question by q_level within each assignment
SELECT assignment_id,id,q_level,RANK() OVER(PARTITION BY assignment_id ORDER BY q_level DESC) as rnk FROM questions
click to copy
To get next 5 questions after current question id=50 in same assignment_id=1
SELECT * FROM questions WHERE assignment_id=1 AND id>50 ORDER BY id LIMIT 5
click to copy
Which SQL creates an auto-updating updated_at column in MySQL
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
click to copy
Laravel $table->timestamps() creates exactly which columns
created_at TIMESTAMP NULL and updated_at TIMESTAMP NULL
click to copy
In the questions screenshot, q_level is NULL. This means
Questions have no difficulty level set
click to copy
To set q_level for all NULL questions in assignment 1 to level 2 in Laravel
DB::table('questions')->whereNull('q_level')->where('assignment_id',1)->update(['q_level'=>2])
click to copy
Which SQL verifies referential integrity of assignment_id in questions
SELECT q.* FROM questions q LEFT JOIN assignments a ON q.assignment_id=a.id WHERE a.id IS NULL
click to copy
MySQL auto_increment value can be reset with
ALTER TABLE questions AUTO_INCREMENT=1
click to copy
To copy questions from assignment 1 to assignment 2 (new rows) in SQL
INSERT INTO questions(question_type,q_level,question,option_a,option_b,option_c,option_d,option_e,right_answer_id,solution,is_deleted,created_at,updated_at) SELECT question_type,q_level,question,option_a,option_b,option_c,option_d,option_e,right_answer_id,solution,0,NOW(),NOW() FROM questions WHERE assignment_id=1 AND is_deleted=0
click to copy
DB::table('questions')->insert() vs DB::table('questions')->insertOrIgnore(): difference
insertOrIgnore skips rows that would violate UNIQUE constraints without throwing error
click to copy
DB::table('questions')->upsert(rows, uniqueBy, update) performs
INSERT rows; if unique key conflict UPDATE specified columns
click to copy
Codd's 12 rules define requirements for a fully relational DBMS. Rule 1 states
The information rule: all data stored in tables
click to copy
Entity integrity rule means
Primary key attributes must NOT have NULL values
click to copy
Referential integrity rule means
FKs must either be NULL or match PK values in referenced relation
click to copy
The degree (arity) of a relation is
Number of columns (attributes)
click to copy
The cardinality of a relation is
Number of rows (tuples) in the current instance
click to copy
Closed World Assumption in databases means
If data not recorded in DB, fact is assumed FALSE
click to copy
Three-valued logic in SQL uses values
TRUE, FALSE, and UNKNOWN (from NULL comparisons)
click to copy
NULL = NULL in SQL evaluates to
NULL/UNKNOWN
click to copy
Impedance mismatch problem arises from
OO programming model vs relational data model incompatibility
click to copy
Object-Relational Mapping (ORM) solves
Impedance mismatch by automatically mapping objects to database tables
click to copy
Which design pattern does Eloquent ORM use
Active Record: model = table, instance = row, CRUD methods on model
click to copy

DBMS → Transactions 1

In MySQL a transaction spanning multiple DELETE statements rolls back correctly when
TRANSACTION is explicitly started with BEGIN/START TRANSACTION before the DELETEs
click to copy

DBMS → Deadlock 1

Deadlock scenario: T1 locks question_id=1 then tries to lock question_id=2; T2 locks question_id=2 then tries question_id=1. Resolution is
DBMS detects cycle, selects one transaction as victim (aborts it), other proceeds
click to copy

DBMS → Joins 1

Which relational algebra operation is equivalent to SQL NATURAL JOIN
πcommon(σA.k=B.k(A×B))
click to copy

DBMS → Relational Model 1

In relational model, a relation is formally defined as a SUBSET of the Cartesian product of
Its attribute domains (D1×D2×...×Dn)
click to copy