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_no | Preference |
|---|---|
| 9 | Cricket |
| 13 | Football |
| 17 | Badminton |
| 17 | Football |
| 21 | Hockey |
| 24 | NULL |
| NULL | Kabaddi |
Roll no 24 may not be interested in sports. Can a NULL value be assigned to that student’s preference field?
Yes, a NULL value can be assigned to that student's preference field. In relational databases, NULL represents unknown or missing data. Since Roll no 24 has not provided any preference, NULL appropriately indicates that the value is unknown or not available. However, if a NOT NULL constraint is applied on the Preference column, then NULL cannot be assigned.
Roll no 17 has given two preferences in 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?
The property violated is Entity Integrity. This principle states that no attribute participating in the primary key of a relation should accept NULL values, and the primary key must uniquely identify each tuple. Having two tuples with the same Roll_no (17) violates the uniqueness requirement.
To prevent such violation, we can use Primary Key constraint on the Roll_no column. A primary key ensures that each roll number is unique and does not allow duplicate values. Alternatively, a Unique constraint can also be applied to ensure all values in the Roll_no column are distinct.
Kabaddi was not chosen by any student. Is it possible to have this tuple in the Sports Preferences relation?
No, it is not possible to have this tuple in the Sports Preferences relation if Roll_no is defined as the primary key. According to Entity Integrity, the primary key cannot contain NULL values. The tuple (NULL, Kabaddi) violates this rule because the Roll_no attribute is NULL. If we need to store sports that are available but not chosen by any student, a separate table for sports should be created rather than inserting tuples with NULL roll numbers in the preferences relation.
Explanation
This case study tests understanding of fundamental relational database concepts: (1) NULL values represent missing/unknown data and can be used when information is unavailable, (2) Entity Integrity ensures primary keys are unique and non-NULL, and (3) Primary Key constraints prevent duplicate and NULL values in key columns. The textbook context reinforces these concepts through similar examples about primary keys, constraints, and entity integrity violations.