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

ANALYZE TABLE questions in MySQL
Analyzes and stores key distribution statistics for the optimizer
click to copy
MyISAM vs InnoDB: key difference
InnoDB supports transactions and FK; MyISAM does not (faster for read-heavy workloads)
click to copy
Row-level locking in InnoDB vs table-level locking in MyISAM
Row-level allows higher concurrency for writes; table-level blocks entire table
click to copy
Which MySQL data type stores IPv4 addresses efficiently
INT UNSIGNED (use INET_ATON/INET_NTOA for conversion)
click to copy
ENUM vs SET in MySQL: difference
ENUM: stores one value from list; SET: stores one or more values from list
click to copy
Which stores multiple selected values in one column
SET
click to copy
JSON column in MySQL 5.7+ allows
Binary JSON with validation and JSON path queries
click to copy
MySQL -> operator on JSON column
Extracts a JSON value: col->'$.key'
click to copy
MySQL ->> operator on JSON column
Extracts JSON value as unquoted string (JSON_UNQUOTE(JSON_EXTRACT(...)))
click to copy
Which MySQL function checks if JSON value contains a path
JSON_CONTAINS_PATH(json,'one','$.path')
click to copy
Generated/Computed column in MySQL is
A virtual or stored column whose value derived from an expression
click to copy
Which SQL creates a virtual generated column for full name
ALTER TABLE emp ADD full_name VARCHAR(100) AS (CONCAT(first_name,' ',last_name)) VIRTUAL
click to copy
Common Table Expression (CTE) scope
Only within the single query that defines it
click to copy
SQL:2003 MERGE statement equivalent in MySQL
INSERT ... ON DUPLICATE KEY UPDATE
click to copy
INSERT IGNORE in MySQL
Silently skips rows that would cause unique constraint violations
click to copy
REPLACE INTO in MySQL
Deletes existing row then inserts new one if PK/unique key conflicts
click to copy
Which SQL checks if a table exists before creating it
CREATE TABLE IF NOT EXISTS questions (...)
click to copy
Which MySQL function returns the last auto-increment ID inserted
LAST_INSERT_ID()
click to copy
PHP PDO lastInsertId() in Laravel context (DB::getPdo()->lastInsertId()) returns
The auto-increment ID of the last inserted row
click to copy
DB::table('questions')->insertGetId(['question'=>'Q?',...]) returns
The auto-increment ID of the newly inserted row
click to copy
DB::select vs DB::statement in Laravel
DB::select returns results; DB::statement returns boolean (for DDL/DML without results)
click to copy
Which prevents N+1 queries when loading questions with their assignment in Laravel
Question::with('assignment')->get()
click to copy
Question::has('reviews')->get() returns
Questions with reviews (at least one related review exists)
click to copy
Question::doesntHave('reviews')->get() returns
Questions with exactly 0 reviews (NO related review records exist)
click to copy
In Laravel migration, how to add index AFTER table creation
Schema::table('questions', function(Blueprint $t){ $t->index('q_level'); })
click to copy
Which Eloquent relationship loads in a separate query by default
Defined relationship accessed as property ($question->assignment)
click to copy
$question->load('assignment') in Eloquent performs
Lazy eager loading: loads relation on already-retrieved model without re-querying the model
click to copy
Question::latest()->get() orders by
created_at descending (most recent first)
click to copy
Question::oldest()->get() orders by
created_at ascending (oldest first)
click to copy
DB::table('questions')->when($level, function($q) use ($level){ $q->where('q_level',$level); })->get() performs
Conditionally applies where clause only if $level is truthy
click to copy
In Laravel, which method returns paginated results for API (without HTML links)
simplePaginate(15)
click to copy
Which Laravel relationship method uses a pivot table
belongsToMany()
click to copy
Pivot table for Question-Tag M:N relationship should be named
question_tag (singular model names in alphabetical order)
click to copy

DBMS → Transactions 4

Which MySQL engine supports ACID transactions
InnoDB
click to copy
Which Laravel method handles database transactions
DB::transaction(callback)
click to copy
DB::beginTransaction() followed by DB::commit() vs DB::rollBack()
beginTransaction starts explicit transaction; commit saves; rollBack undoes all changes
click to copy
Which Laravel method retries a transaction on deadlock
DB::transaction(callback,3) - second param is number of retry attempts
click to copy

DBMS → Joins 1

Lateral join (LATERAL keyword) allows
Subquery in FROM to reference columns from preceding FROM items in same query
click to copy

DBMS → DDL Commands 1

DROP TABLE IF EXISTS questions
Drops table only if it exists (no error if it doesn't exist)
click to copy

DBMS → SQL Basics 1

In Laravel, how to run raw SQL query
DB::select('SELECT * FROM questions WHERE id=?',[1])
click to copy