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 → SQL Basics 2

In Laravel, how to run raw SQL query
DB::select('SELECT * FROM questions WHERE id=?',[1])
click to copy
Which SQL query most efficiently counts questions per q_level without NULL q_level
SELECT q_level,COUNT(*) FROM questions WHERE q_level IS NOT NULL GROUP BY q_level
click to copy

DBMS → Introduction to DBMS 30

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
To attach tags to a question in Eloquent M:N
$question->tags()->attach($tagIds)
click to copy
To remove all tag associations from a question in Eloquent M:N
$question->tags()->detach()
click to copy
$question->tags()->sync($newTagIds) in Eloquent
Adds new tags and removes old ones so the relationship matches exactly $newTagIds
click to copy
Which Eloquent method creates a model AND saves it to database in one step
Question::create(['question'=>'...'])
click to copy
Question::firstOrCreate(['question'=>'Test?'],['option_a'=>'A']) does
Finds first matching row or creates it if not found
click to copy
Question::updateOrCreate(['id'=>1],['q_level'=>3]) does
Updates if found by first arg, creates if not found
click to copy
Which prevents concurrent duplicate inserts in Laravel
Unique database constraint + try-catch for IntegrityConstraintViolationException
click to copy
Database connection pooling improves
Performance by reusing existing connections instead of creating new ones for each request
click to copy
Which Laravel config file sets database connection settings
config/database.php (reads from .env variables)
click to copy
DB_CONNECTION=mysql in .env sets
The database driver (mysql, pgsql, sqlite, sqlsrv)
click to copy
To add a new column 'marks' INT DEFAULT 0 to existing questions table in Laravel migration
Schema::table('questions', function(Blueprint $t){ $t->integer('marks')->default(0); })
click to copy
$table->after('solution') in migration column definition
Places the new column AFTER the solution column in the table structure
click to copy
$table->change() in migration is used to
Rename table
click to copy
Which SQL command shows FK constraints on questions table in MySQL
SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_NAME='questions'
click to copy
To safely drop a column that might not exist in migration
Schema::table('questions',fn($t)=>$t->dropColumn('old_col')) in a try-catch or use Schema::hasColumn() check first
click to copy
Which is the correct way to handle database errors in Laravel
Catch Illuminate\\Database\\QueryException for DB errors
click to copy
Which PHP/Laravel code correctly inserts a question matching the screenshot table format
Both A and C are correct
click to copy

DBMS → Relational Model 1

To add a foreign key constraint to existing questions.assignment_id column in migration
$table->foreign('assignment_id')->references('id')->on('assignments')->onDelete('cascade')
click to copy

DBMS → Transactions 3

DB::transaction(function(){ /* multiple inserts */ }) advantage
Ensures all inserts succeed or all fail atomically - no partial data
click to copy
DB::table('questions')->lockForUpdate() in a transaction
Acquires an exclusive lock preventing other transactions from reading/writing these rows
click to copy
DB::table('questions')->sharedLock() in a transaction
Acquires a shared lock allowing reads but preventing exclusive locks from other transactions
click to copy

Software Project Management → Introduction to SPM 1

Which of the following is not project management goal?
avoiding customer complaints
click to copy

Software Project Management → Project Planning 1

Which of the following is not considered as a risk in project management?
testing
click to copy

Software Project Management → Project Scheduling 1

The process each manager follows during the life of a project is known as
project management life cycle
click to copy

Software Project Management → Risk Management 1

A 66.6% risk is considered as
high
click to copy