CS FundamentalsHardProduct company interview · GATE level
A relation Enrollment(student_id, course_id, semester, grade) has candidate key (student_id, course_id, semester). A functional dependency student_id, course_id → grade also holds (i.e. a student's grade in a course doesn't depend on which semester is recorded, perhaps because retakes always show the latest grade under the same key). Is this FD a violation of 2NF?
- A. No, because grade is only ever accessed together with semester
- B. No, because this FD does not involve semester at all, so it cannot affect normalization
- C. Yes, but only because of BCNF, not 2NF
- D. Yes, because (student_id, course_id) is a proper subset of the key (student_id, course_id, semester), and grade is non-prime — this is a textbook partial dependency
Correct answer: D. Yes, because (student_id, course_id) is a proper subset of the key (student_id, course_id, semester), and grade is non-prime — this is a textbook partial dependency
The declared candidate key is the full triple (student_id, course_id, semester). Since (student_id, course_id) is a proper, non-empty subset of that key, and grade is a non-prime attribute depending on just that subset, this is exactly a partial dependency — a direct 2NF violation, regardless of what the FD 'means' conceptually.
More DBMS and SQL questions
- A poorly designed table stores repeating groups as separate columns: Student(sid, sname, course1, course2, course3). What specific 1NF…
- A relation R(A, B, C, D) decomposes into R1(A, B) and R2(A, C, D). For this decomposition to be DEPENDENCY PRESERVING, what must hold?
- Decomposing R(A, B, C) with FDs A → B and B → C into BCNF can require R1(A, B) and R2(B, C). Is this decomposition dependency-preserving?
- A relation R(A, B, C) has FDs A → B and A → C, but NOT B → C or C → B (B and C are independent given A). Decomposing R into R1(A, B) and…
- A relation R(A, B, C, D) has only the FD A → B (C and D are independent, part of the key). Decomposing R into R1(A, C) and R2(B, D) — is…
- A SERIALIZABLE transaction in PostgreSQL (which uses Serializable Snapshot Isolation, SSI) can occasionally abort with a serialization…