CS FundamentalsModerateGATE CS · Product placement
Which statement about a UNIQUE constraint versus a PRIMARY KEY in standard SQL is correct?
- A. A table may have several UNIQUE constraints, and UNIQUE columns may hold NULLs; there is only one PRIMARY KEY and it cannot be NULL
- B. A table may have several PRIMARY KEYs but only one UNIQUE constraint
- C. UNIQUE columns cannot be NULL
- D. A foreign key can reference only a PRIMARY KEY, never a UNIQUE column
Correct answer: A. A table may have several UNIQUE constraints, and UNIQUE columns may hold NULLs; there is only one PRIMARY KEY and it cannot be NULL
PRIMARY KEY = UNIQUE + NOT NULL, one per table. Any number of UNIQUE constraints are allowed, and NULLs in them are not treated as duplicates in the standard.
More DBMS and SQL questions
- Consider the schedule R1(B), W3(B), W3(A), R2(B), W2(A), R1(A), W1(A). Which statement is correct?
- Extendible hashing uses the LOWEST-order bits of a key's binary value, bucket capacity 2, and starts with global depth 0 and one empty…
- Table Takes(sid, cid, marks) rows: (1, 'C1', 80), (1, 'C2', NULL), (2, 'C1', 65), (3, 'C2', 90), (3, 'C3', 75), (5, 'C1', 50). What does…
- R(A, B, C, D, E, F) has functional dependencies BD → E, D → AF, E → AB, BC → D. Which of the following is the complete set of candidate…
- T1: W1(B), R1(B), R1(A) and T2: W2(A), R2(B), R2(A). Of all 20 interleavings that keep each transaction's own order, how many are conflict…
- Σ = {B → C, C → B, AE → D, F → B, DF → C} on R(A, B, C, D, E, F). Exactly one FD in Σ is redundant (it can be derived from the others)…