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 → 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 → Introduction to DBMS 36

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
Which is NOT a NoSQL database type
Relational table store
click to copy
MongoDB is an example of
Document store
click to copy
Redis is an example of
Key-value store (in-memory)
click to copy
Apache Cassandra is an example of
Wide-column (column-family) store
click to copy
Neo4j is an example of
Graph database
click to copy
BASE vs ACID: BASE stands for
Basically Available Soft-state Eventually consistent
click to copy
Which database property is BASE designed to relax compared to ACID
Strong Consistency for better availability and performance
click to copy
CAP theorem P stands for
Partition tolerance: system continues operating despite network partitions
click to copy
MongoDB vs MySQL: key structural difference
MongoDB: schema-less documents; MySQL: fixed-schema tables
click to copy
Which SQL command imports a SQL dump file in MySQL command line
mysql -u user -p database < dump.sql
click to copy
mysqldump command creates
A SQL dump file with CREATE TABLE and INSERT statements
click to copy
Which SQL shows all indexes on the questions table in MySQL
SHOW INDEX FROM questions
click to copy
CHECK TABLE questions in MySQL performs
Checks table for errors or corruption
click to copy
OPTIMIZE TABLE questions in MySQL
Defragments the table and updates statistics for better performance
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