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 37

Eloquent create() requires
$fillable array set on model (mass assignment protection)
click to copy
$question->save() performs
INSERT for new model or UPDATE for existing model
click to copy
Soft delete uses
deleted_at TIMESTAMP column (NULL=active, timestamp=deleted)
click to copy
withTrashed() includes
All records including soft-deleted ones
click to copy
belongsToMany() is used for
Many-to-many relationship requiring pivot table
click to copy
chunk(100, callback) in Eloquent
Processes records 100 at a time preventing memory exhaustion
click to copy
DB::table('questions')->get() returns
Plain PHP stdClass objects (not Eloquent model instances)
click to copy
DB::table('questions')->where('is_deleted',0)->count() returns
Integer count of non-deleted questions
click to copy
php artisan migrate:fresh
Drops ALL tables then re-runs all migrations
click to copy
Schema::create() in migration
Creates a new database table
click to copy
$table->id() creates
AUTO_INCREMENT UNSIGNED BIGINT primary key column named id
click to copy
$table->string('question') creates
VARCHAR(255) column named question
click to copy
$table->text('solution') creates
TEXT column for large text content
click to copy
$table->timestamps() adds
created_at and updated_at TIMESTAMP NULL columns
click to copy
$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

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