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 34

$table->softDeletes() adds
deleted_at NULLABLE TIMESTAMP column
click to copy
$table->boolean('is_deleted') creates
TINYINT(1) MySQL boolean column
click to copy
$table->foreign('assignment_id')->references('id')->on('assignments') creates
Foreign key constraint referencing assignments.id
click to copy
$table->decimal('price',10,2) creates
DECIMAL(10,2) - 10 total digits 2 decimal places
click to copy
$table->json('metadata') creates
JSON column for native JSON storage
click to copy
$table->index(['assignment_id','q_level']) creates
Composite index on (assignment_id, q_level)
click to copy
hasMany(Comment::class) on Post means
Post HAS MANY Comments (FK post_id in comments table)
click to copy
belongsTo(Post::class) on Comment means
Comment belongs to ONE Post (stores FK post_id)
click to copy
Local scope scopeActive() on model allows
Reusable query constraint callable as Question::active()->get()
click to copy
paginate(15) returns
Paginator with 15 records per page plus metadata (total, pages, etc.)
click to copy
DB::table('questions')->pluck('question') returns
Flat Collection of values from question column only
click to copy
DB::table('questions')->skip(10)->take(5)->get() returns
Questions 11 through 15 (offset 10, limit 5)
click to copy
whereIn('id',[1,2,3]) generates
WHERE id IN (1,2,3)
click to copy
whereNull('q_level') generates
WHERE q_level IS NULL
click to copy
DB::table('questions')->max('id') executes
SELECT MAX(id) FROM questions
click to copy
Question::chunk(100, function($qs){}) processes
Records 100 at a time preventing memory exhaustion
click to copy
DB::table('questions')->insert([rows]) bulk inserts
All rows in single efficient INSERT statement
click to copy
DB::table('questions')->truncate() before seeding
Removes all existing rows quickly before inserting fresh data
click to copy
Which query finds employees earning more than their department average?
SELECT * FROM emp e WHERE salary > (SELECT AVG(salary) FROM emp WHERE dept_id=e.dept_id)
click to copy
Second highest salary in SQL
SELECT MAX(salary) FROM emp WHERE salary < (SELECT MAX(salary) FROM emp)
click to copy
NOT IN with NULL in subquery causes
No rows returned (NULL comparisons return UNKNOWN, NOT IN evaluates to UNKNOWN)
click to copy
Schedule with precedence graph T1→T2→T1 (cycle) is
NOT conflict serializable (cycle in precedence graph)
click to copy
In ARIES, pageLSN on each data page records
LSN of LAST log record that modified that page
click to copy
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

DBMS → Relational Model 1

R(A,B,C,D) with FDs: A→B, B→C, A→D. The candidate key is
A
click to copy

DBMS → Normalization 1

R(A,B,C) with AB→C and C→B. Is C→B a BCNF violation?
Yes - C is NOT a superkey (C+={C,B}≠{A,B,C}) so C→B violates BCNF
click to copy

DBMS → SQL Basics 1

SELECT RANK() OVER(PARTITION BY dept ORDER BY salary DESC) ranks employees
Within each department partition by salary descending
click to copy

DBMS → Joins 1

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

DBMS → Transactions 1

Which 2PL variant holds ALL locks until transaction commits?
Rigorous 2PL
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