KnowledgeBoat Logo
|

Computer Science

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
  1. Roll no 24 may not be interested in sports. Can a NULL value be assigned to that student’s preference field ?
  2. Roll no 17 has given two preferences in sports. Which property of relational DBMS is violated here ? Can we use any constraint or key in the relational DBMS to check against such violation, if any?
  3. Kabaddi was not chosen by any student. Is it possible to have this tuple in the Sports Preferences relation ?

Relational Database

1 Like

Answer

  1. In a relational database model where each student is required to have exactly one preference for a sports activity, assigning a NULL value to Roll no 24's preference field is not permitted.
  2. The primary key constraint ensures uniqueness in a relational database table. If Roll no 17 has two sports preferences, it violates this rule because a primary key constraint on "Rollno" would not allow different values for the same roll number. By using a primary key constraint on "Rollno," the relational database management system (DBMS) can prevent such violations by rejecting attempts to insert rows with duplicate roll numbers.
  3. No, since no student has selected Kabaddi as their preferred sport, there should not be an entry for Kabaddi in the Sports Preferences table.

Answered By

2 Likes


Related Questions