Q: 1 An ________ is a field or a combination of fields that can be used to access or retrieve records from a table.
Foreign Key
Secondary Key
ERD (Entity Relationship Diagram)
Command Key
[ Option B ]
A Secondary Key is a field or a group of fields that is used to retrieve or search records in a table but does not uniquely identify a record.
For example, in a student table, attributes like name or city can be used as secondary keys to retrieve multiple matching records.
Q: 2 In context of a relational database, choose a false statement :
A super key is not always a candidate key.
A minimal super key is called a candidate key.
One of the candidate keys is designated as primary key.
Primary key is a proper subset of one of the candidate keys.
[ Option D ]
In a relational database, a Super Key is any set of attributes that uniquely identifies tuples, but it may contain extra attributes and hence is not always minimal.
A Candidate Key is a minimal super key, meaning no subset of it can be a super key. Among candidate keys, one is chosen as the Primary Key to uniquely identify tuples.
Since the Primary Key itself is a candidate key, it cannot be a proper subset of another candidate key.
| KEY TYPE | DESCRIPTION |
|---|---|
| Super Key | A set of one or more attributes that uniquely identifies a tuple in a relation. It may contain extra attributes. |
| Candidate Key | A minimal super key, i.e., a super key with no unnecessary attributes. Each relation can have one or more candidate keys. |
| Primary Key | A candidate key chosen by the database designer to uniquely identify tuples in a relation. Must not contain NULL. |
| Alternate Key | Any candidate key that is not selected as the primary key. |
| Foreign Key | An attribute in one table that refers to the primary key of another table to maintain referential integrity. |
| Composite Key | A key that consists of two or more attributes to uniquely identify a tuple. |
| Partial Key | Used in weak entity sets to uniquely identify tuples only when combined with the primary key of the identifying entity. |
Q: 3 Which of the following is a column constraint in SQL?
NOT NULL
PRIMARY KEY
CHECK
All of the above
[ Option D ]
A column constraint is applied directly to a single column while defining a table.
Q: 4 Let relation R2 has a 'foreign key' that refers to the primary key of relation R1. Which of the following operation may cause violation of referential integrity constraints?
Insertion of new tuple into R2
Deletion of tuple from R1
Both (a) and (b)
Neither (a) nor (b)
[ Option C ]
Referential integrity constraint ensures that a Foreign Key in one relation (R2) must always refer to an existing Primary Key in another relation (R1).
If we insert a tuple in R2 with a foreign key value that does not exist as a primary key in R1, it violates referential integrity.
If a tuple in R1 is deleted but there are still tuples in R2 that reference it, the relationship becomes invalid, causing a referential integrity violation.
| Operation | Reason for Violation | Possible SQL Solutions |
|---|---|---|
| Insertion in R2 | Foreign key in R2 points to a non-existent primary key in R1. |
|
| Deletion from R1 | R2 has orphan references after deletion in R1. |
|
| Update in R1 | Violation occurs because foreign key values in R2 no longer match R1. |
|
| Update in R2 | Violation occurs because foreign key values in R2 no longer match R1. |
|
Q: 5 How many primary keys can a table have?
One
Two
Three
No limit
[ Option A ]
A table can have only one primary key. The primary key uniquely identifies each record in a table.
It may consist of one attribute or a combination of multiple attributes (composite primary key).
Q: 6 Consider the following statements regarding key-
(I) A super key is an attribute or combination of attributes that uniquely identifies records in a RDBMS table.
(II) A candidate key is a subset of a super key.
(III) All super keys are candidate keys but vice versa is not true.
Only (I) is true
Only (II) is true
(I) and (III) are true
(I) and (II) are true
[ Option D ]
In a Relational Database Management System (RDBMS), keys are used to uniquely identify records in a table or relation. A super key is an attribute or a combination of attributes that ensures the uniqueness of each record. Among these super keys, a candidate key is a minimal set of attributes that can still uniquely identify a record, meaning it does not contain any unnecessary attributes.
In other words, every candidate key is a subset of a super key, but not all super keys are candidate keys because some may include extra attributes that are not needed for uniqueness.
Q: 7 Which integrity rule ensures that a foreign key value in one table must match an existing primary key value in another related table?
Referential Integrity
Domain Integrity
Entity Integrity Constraint
A Data Validation Constraint
[ Option A ]
Referential Integrity means that you cannot enter a value in a foreign key column unless that value already exists as a primary key in another table. This rule ensures that the relationship between tables remains valid and consistent.
E.g.:
CREATE TABLE Student
(
RollNo INT PRIMARY KEY,
Name VARCHAR(50)
);
The RollNo is the primary key of the Student table.
CREATE TABLE Course
(
CourseNo INT PRIMARY KEY,
RollNo INT,
FOREIGN KEY (RollNo) REFERENCES Student(RollNo)
);
The CourseNo is the primary key of the Course table and RollNo is a foreign key that refers to Student(RollNo).
INSERT INTO Student VALUES (101, 'Suresh Kulahry'); /* Valid (Allowed) */
INSERT INTO Course VALUES (201, 101); /* Valid (Allowed) */
INSERT INTO Course VALUES (202, 105); /* Invalid (Not Allowed) */
Q: 8 In relational database minimal super keys is known as-
Primary Keys
Foreign Keys
Candidate Keys
Reference Keys
[ Option C ]
A super key is a set of one or more attributes that uniquely identify each record in a table. However, a super key may include extra attributes that are not necessary for uniqueness.
When we remove all unnecessary attributes from a super key, leaving the minimal set of attributes that still uniquely identify each record, it becomes a candidate key.
Every candidate key is a minimal super key, meaning it cannot be reduced any further without losing the ability to uniquely identify records. From among the candidate keys, one is selected as the primary key to uniquely identify rows in the table.
Q: 9 Consider a relation R with attributes (A, B, C), where B is the only candidate key. Identify the total number of possible super keys of the relation R.
1
3
4
2
[ Option C ]
A superkey is any set of attributes that can uniquely identify a tuple in a relation. If you have a relation with n attributes and one candidate key consisting of k attributes, the total number of super keys is 2n−k.
Remember, this formula can only work with a relation has only one candidate key consisting of k attributes.
Given,
Relation: R(A, B, C)
Total Attributes (A,B,C) n = 3.
Candidate key B : k = 1
Total super keys: 23−1 = 22 = 4.
Q: 10 Which of the following is not a super key in a relational schema with attributes V, W, X, Y, Z and primary key VY?
VXYZ
VWXZ
VWXY
VWXYZ
[ Option B ]
A super key is any set of attributes that contains the primary key or a superset of it. Since the primary key is VY, any super key must at least include both attributes V and Y.
(a) VXYZ: Has V,X,Y,Z. It contains both V and Y. So, this is a super key.
(b) VWXZ: Has V,W,X,Z. It contains V but does not have Y. So, this is not a super key.
(c) VWXY: Has V,W,X,Y. It contains both V and Y. So, this is a super key.
(d) VWXYZ: Has V,W,X,Y,Z. It contains both V and Y. So, this is a super key.
Q: 11 Which integrity rule states that a primary key cannot contain NULL values, and if the primary key is composite, none of its component attributes can be NULL?
Referential Integrity
Domain Integrity
Entity Integrity Constraints
A Data Validation Constraint
[ Option C ]
The entity integrity constraint states that a primary key cannot contain NULL values. This rule ensures that every record in a table can be uniquely identified.
In the case of a composite (more than one field) primary key, then none of those fields are allowed to be NULL.
E.g. (1):
CREATE TABLE Student
(
Rollno INT PRIMARY KEY,
Name VARCHAR(50)
);
Here, Rollno is the primary key and it cannot be NULL. Every student must have a valid Rollno.
E.g. (2):
CREATE TABLE Enrollment
(
Rollno INT,
Courseno INT,
PRIMARY KEY (Rollno, Courseno)
);
Here, the primary key is composite, made of Rollno and Courseno. Both fields must have values. Neither Rollno nor Courseno can be NULL.
Q: 12 A non-key field is a field that is __________.
Not a candidate key for the primary key
A candidate key for the primary key
A primary key
None of the above
[ Option A ]
In a database table, a non-key field (non-key attribute) is a field that does not uniquely identify a record. It is not part of any candidate key and therefore cannot serve as a primary key.
Q: 13 In context of keys of a relation in DBMS, choose the true statements:
I. A superkey of a relation is a set of one or more attributes whose values are guaranteed to identify tuples in the relation uniquely.
II. A candidate key is a minimal superkey, that is, a set of attributes that forms a superkey, but none of whose subsets is a superkey.
III. One of the candidate keys of a relation, containing highest number of attributes, is chosen as its primary key.
I and II only
I and III only
II and III only
I, II and III
[ Option A ]
In a Database Management System (DBMS), Keys are attributes or sets of attributes used to uniquely identify each tuples (rows) in a table (relation).
In a relational database, a Super Key is any set of attributes that uniquely identifies tuples, but it may contain extra attributes.
A Candidate Key is a minimal super key, meaning no subset of it can be a super key.
Among candidate keys, one is chosen as the Primary Key to uniquely identify tuples but it is not chosen based on the number of attributes. It is usually selected for simplicity, stability, and efficiency, not because it has the highest number of attributes.
So, statements I and II correctly describe Super Key and Candidate Key, while III is incorrect because the primary key is not selected based on attribute count.
Thank you so much for taking the time to read my Computer Science MCQs section carefully. Your support and interest mean a lot, and I truly appreciate you being part of this journey. Stay connected for more insights and updates! If you'd like to explore more tutorials and insights, check out my YouTube channel.
Don’t forget to subscribe and stay connected for future updates.