Consider the following database table: CREATE TABLE test ( one INTEGER, two…

2015

Consider the following database table:

CREATE TABLE test (

one INTEGER,

two INTEGER,

PRIMARY KEY (one),

UNIQUE (two),

CHECK (one >= 1 AND one <= 10),

CHECK (two >= 1 AND two <= 5)

);

How many data records/tuples can this table contain at most?

  1. A.

    5

  2. B.

    10

  3. C.

    15

  4. D.

    50

Attempted by 729 students.

Show answer & explanation

Correct answer: A

Answer: At most 5 rows.

Reasoning:

  • Column one is constrained by check(one >= 1 and <= 10), so it can take 10 distinct values (1 through 10).

  • Column two is constrained by check(two >= 1 and <= 5), so it can take 5 distinct values (1 through 5).

  • Both columns have uniqueness enforced (primary key on the first column and unique on the second), so each column must have distinct values across rows.

  • Therefore the maximum number of rows is limited by the column with the fewest distinct allowed values: min(10, 5) = 5.

Explore the full course: Mppsc Assistant Professor