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 → Functional Dependency 27

Given FDs A to B, B to C, A to D, D to E - compute A+ (attribute closure of A).
A+ = ABCDE (A to B to C, A to D to E, so A determines all)
click to copy
Given R(A,B,C,D) and FDs F={AB to C, C to D, D to A} what are ALL candidate keys?
AB, BC, and BD (compute closures: AB+ = ABCD, BC+ = ABCD, BD+ = ABCD; check minimality: no proper subset works for each)
click to copy
What is the decomposition rule derived from Armstrongs axioms?
If X to YZ then X to Y and X to Z (you can split the right-hand side - derived from Reflexivity and Transitivity)
click to copy
Given F={X to YZ, XY to W, W to V} is the FD X to W derivable from F?
Yes: X to YZ (given), so X to Y (decomposition), then X to XY (augmentation), XY to W (given), X to W by transitivity
click to copy
What is extraneous attribute in the context of finding a minimal cover?
An attribute A in the LHS of an FD X to Y such that removing A still preserves the equivalence: (F minus FD) union ((X-A) to Y) is equivalent to F
click to copy
What is the pseudotransitivity rule derived from Armstrongs axioms?
If X to Y and WY to Z then WX to Z (a generalization of transitivity where the intermediate attribute set Y is augmented with W on both sides)
click to copy
In relation R(A,B,C,D,E) with F={A to BC, CD to E, B to D, E to A} is E to D derivable?
Yes: E to A (given), A to BC (given), B to D (given); E to A to B to D, so E to D by transitivity chain
click to copy
What distinguishes a trivial from a non-trivial multivalued dependency?
X multidetermines Y is trivial if Y is a subset of X or X union Y equals the entire attribute set of the relation (trivial MVDs always hold and convey no information)
click to copy
What is the complementation rule for MVDs stated formally?
If X multidetermines Y in relation R(X,Y,Z) where Z=R-X-Y then X multidetermines Z also holds; also every FD X to Y implies X multidetermines Y
click to copy
Given R(A,B,C) and FDs F={A to B, B to C} compute the canonical cover Fc.
Fc = A to B, B to C (A to C is redundant since it is derivable; both remaining FDs are necessary and have no redundant attributes)
click to copy
In the context of FDs what is the inference closure F+ of a set F?
The set of ALL functional dependencies that can be logically derived from F using Armstrongs axioms - the complete set of FDs that hold in every relation satisfying F
click to copy
What does it mean for a set of FDs F to cover a set G and how is this tested?
F covers G (G is a subset of F+) if every FD X to Y in G can be derived from F - tested by checking if Y is a subset of X+ computed under F for each FD in G
click to copy
What is the difference between full functional dependency and partial functional dependency?
X to Y is a full FD if removing any attribute from X breaks the FD (Y no longer depends on X); partial if Y still depends on some proper subset of X
click to copy
Given R(Supplier_ID,Part_ID,Project_ID,Quantity) with FD Supplier_ID,Part_ID,Project_ID to Quantity - are there other FDs that must be assumed?
No other FDs are specified; the composite key is the only determinant of quantity placing the relation in BCNF assuming no other FDs exist
click to copy
The FD preservation problem in BCNF decomposition means that:
Some FDs in the original relation cannot be enforced by checking just one decomposed relation - they would require joining multiple decomposed relations to verify making constraint enforcement expensive
click to copy
In relation R(A,B,C,D,E) with F={AB to C, D to E, C to B} is AD a candidate key?
AD+ = ADE only: start with A,D, apply D to E getting ADE. Cannot reach B or C without them already in the closure. AD does NOT determine all attributes, so AD is NOT a candidate key.
click to copy
What is a trivial functional dependency and why is it excluded from normal form violation checks?
X to Y where Y is a subset of X - it always holds in any relation (by reflexivity) because a set of attributes always determines its own subset providing no real constraint on data
click to copy
What is the union rule derived from Armstrongs axioms?
If X to Y and X to Z then X to YZ (you can combine right-hand sides when the left-hand side is the same)
click to copy
What is Fagans theorem about lossless join decomposition?
A theorem stating that the binary decomposition of R into R1 and R2 is lossless if and only if (R1 intersect R2) multidetermines (R1-R2) OR (R1 intersect R2) multidetermines (R2-R1) holds as an MVD in R
click to copy
In relation R(A,B,C,D,E) with F={A to BC, CD to E, B to D, E to A} what is the attribute closure of E?
E+ = EABCD by E to A to BC to D and CD to E (already have E): E determines all attributes in the relation
click to copy
What is the Armstrong completeness theorem?
Armstrongs axioms are both sound (only derive valid FDs) and complete (can derive ALL valid FDs) meaning F+ computed by Armstrong axioms exactly equals the set of all FDs logically implied by F
click to copy
What is the difference between a FD X to Y being satisfied by a relation instance vs being implied by a set of FDs?
Satisfied by an instance: this specific relation instance happens to have X to Y hold (extensional). Implied by a set F: X to Y holds in EVERY possible instance that satisfies F (intensional) - a much stronger condition capturing the semantics of the schema
click to copy
Given the FDs F={A to B, B to C, C to D, D to A} what is the canonical cover Fc?
Fc = A to B, B to C, C to D, D to A - each FD is individually necessary (no FD is derivable from the others) since removing any one breaks the cycle
click to copy
What is an independent set of FDs and why is it important?
A set of FDs where none of them can be derived from the others - important because it means each FD adds genuine new information about the schema and removing any one would change the closure F+
click to copy
What is the key lemma used to prove that Armstrongs axioms are sound?
For soundness: Reflexivity holds trivially by definition. Augmentation: if t1[X]=t2[X] then t1[XZ]=t2[XZ] which implies t1[Y]=t2[Y] gives t1[YZ]=t2[YZ]. Transitivity: if t1[X]=t2[X] implies t1[Y]=t2[Y] and t1[Y]=t2[Y] implies t1[Z]=t2[Z] then t1[X]=t2[X] implies t1[Z]=t2[Z]
click to copy
What is the chase algorithm used for in relational theory?
Testing whether a decomposition has the lossless join property and whether functional dependencies are preserved by applying FDs to a canonical table (tableau)
click to copy
What is the concept of dependency basis in the context of MVDs?
For a set of attributes X the dependency basis is the finest partition of (R-X) such that X multidetermines each block; this partitions the other attributes into independent groups that X independently multidetermines
click to copy

DBMS → SQL Basics 13

What is the correct logical execution order of SQL clauses in a SELECT statement?
FROM WHERE GROUP BY HAVING SELECT ORDER BY LIMIT
click to copy
What is the difference between WHERE and HAVING clauses in SQL?
WHERE filters individual rows BEFORE grouping; HAVING filters groups AFTER GROUP BY and aggregation - HAVING can reference aggregate functions, WHERE cannot
click to copy
What does the SQL clause NULLIF(expr1, expr2) return?
NULL if expr1 equals expr2 (returns expr1 otherwise); used to avoid division-by-zero errors: NULLIF(count, 0) returns NULL instead of causing error when count=0
click to copy
What is the behavior of aggregate functions (SUM, AVG, COUNT, MAX, MIN) with respect to NULL values?
Aggregate functions (except COUNT(*)) IGNORE NULL values - COUNT(*) counts all rows including NULLs; COUNT(column) counts only non-NULL values
click to copy
What is the purpose of the SQL WITH clause (Common Table Expression - CTE)?
To define named temporary result sets that can be referenced multiple times within a query improving readability and enabling recursive queries (WITH RECURSIVE)
click to copy
What is the difference between CHAR(n) and VARCHAR(n) data types?
CHAR(n) is fixed-length (always uses n bytes, padded with spaces if shorter); VARCHAR(n) is variable-length (uses only the space needed plus 1-2 bytes for length storage)
click to copy
What does the SQL CASE expression return when no WHEN condition matches and no ELSE clause is specified?
It returns NULL (the CASE expression evaluates to NULL when no WHEN matches and no ELSE is provided)
click to copy
What is a correlated subquery in SQL and how does it differ from a non-correlated subquery?
A subquery that references a column from the outer query causing it to be executed once for each row of the outer query (vs. non-correlated subquery which executes once independently)
click to copy
What is the SQL EXISTS operator and when should it be preferred over IN?
EXISTS returns TRUE if a subquery returns at least one row (stops at first match), preferred over IN when the subquery could return NULLs (IN with NULL has counterintuitive behavior) or when checking existence is more efficient
click to copy
What does SELECT * FROM employees WHERE department_id IN (SELECT department_id FROM departments WHERE location = NULL) return?
An empty result set - the condition WHERE location = NULL is always FALSE (must use IS NULL instead of = NULL)
click to copy
What is the difference between RANK(), DENSE_RANK(), and ROW_NUMBER() window functions?
ROW_NUMBER(): unique sequential number with no gaps or ties; RANK(): same rank for ties then skips numbers (1,1,3); DENSE_RANK(): same rank for ties no gaps (1,1,2)
click to copy
What are LEAD() and LAG() window functions used for?
Accessing values from subsequent rows (LEAD) or preceding rows (LAG) within the result partition useful for computing differences between consecutive rows without self-joins
click to copy
What is the OVER(PARTITION BY...ORDER BY...ROWS/RANGE BETWEEN...) clause used for?
Defining the window frame for window functions - specifying which rows to include in each computation relative to the current row
click to copy