Skip to content
Exercises · Q6
Q.

A school has a rule that each student must participate in a sports activity. So each one should give only one preference for sports activity. Suppose there are five students in a class, each having a unique roll number. The class representative has prepared a list of sports preferences as shown below. Answer the following:

Table: Sports Preferences

Roll_noPreference
9Cricket
13Football
17Badminton
17Football
21Hockey
24NULL
NULLKabaddi

a) Roll no 24 may not be interested in sports. Can a NULL value be assigned to that student’s preference field?

b) Roll no 17 has given two preferences sports. Which property of relational DBMC is violated here? Can we use any constraint or key in the relational DBMS to check against such violation, if any?

c) Kabaddi was not chosen by any student. Is it possible to have this tuple in the Sports Preferences relation?

Dnh Dd CbseNCERTSubjective· 4mImportance★★★★★
50% · 7/14 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

One student = one tuple, identified by Roll_no. So: a NULL Preference is fine (NULL means "unknown/not given"), a repeated Roll_no breaks the uniqueness property of the key and is stopped by a PRIMARY KEY constraint, and a NULL Roll_no is flatly impossible because entity integrity forbids NULL in a primary key.

In this relation the natural design is: Roll_no identifies the student (each roll number is unique), and Preference records the single sport chosen. In SQL:

CREATE TABLE SPORTS_PREFERENCES (
  Roll_no    INT PRIMARY KEY,      -- one tuple per student, never NULL
  Preference VARCHAR(20)           -- may be NULL: preference not yet given
);

a) Can Roll_no 24's Preference be NULL? — Yes.

NULL is the special marker for unknown / not applicable / not yet provided. Preference is an ordinary (non-key) attribute with no NOT NULL constraint, so the tuple (24, NULL) is perfectly valid: it records honestly that student 24 has not indicated any preference. (If the school wanted to force everyone to choose — per its rule — the designer could add NOT NULL to Preference; but as the relation stands, NULL is allowed.)

b) Roll_no 17 appears twice — what is violated, and what prevents it?

The rule broken is the key/uniqueness property of a relation: every tuple must be uniquely identifiable, and here Roll_no is meant to be the key ("each one should give only one preference"). Two tuples with Roll_no 17 mean the key value repeats, so the relation can no longer tell the two apart by its key — a violation of entity integrity/uniqueness.

Yes, a constraint prevents this: declare Roll_no the PRIMARY KEY (or at least UNIQUE). Then the DBMS itself rejects the second entry:

INSERT INTO SPORTS_PREFERENCES VALUES (17, 'Badminton');  -- accepted
INSERT INTO SPORTS_PREFERENCES VALUES (17, 'Football');   -- REJECTED: duplicate primary key 17

The second INSERT fails with a duplicate-key error — the constraint enforces "one student, one preference" automatically.

c) Can the tuple (NULL, 'Kabaddi') exist? — No. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.