UGC-NET Dec 2015 · SQL Queries

MCQ · 2 marks · Problem DBMS-SQL-0012

Consider the following database table:
Create table test(
    one integer,
    two integer,
    primary key(one),
    unique(two),
    check(one>=1 and <=10),
    check (two>=1 and <=5)
    );
How many data records/tuples atmost can this table contain?
  1. A
    $5$
  2. B
    $10$
  3. C
    $15$
  4. D
    $50$

Solve it on GATE DA practice →More Relational Model & SQL problems

Show the worked solutionThe primary key one must be non-null and unique, and its CHECK allows only the values \(1,\dots,10\). So there are at most 10 rows. Column two is UNIQUE but not declared NOT NULL. UNIQUE permits several NULLs, and a CHECK on NULL evaluates to unknown, which does not reject the row. So two does not limit the table to 5 rows: 5 rows can use the values 1 to 5 and the other 5 can have two NULL.\[\max=10.\]Answer: B

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com