1. Primary Key
- Importance: Most frequently tested.
- Key Points to Study:
- Unique identifier for table rows.
- Cannot be NULL.
- Only one primary key per table.
- Examples:
- In a Students table,
Roll_Number
is often a primary key.
- In a Students table,
2. Foreign Key
- Importance: Often paired with primary key questions.
- Key Points to Study:
- Links two tables by referencing the primary key in another table.
- Helps maintain referential integrity.
- Examples:
Student_ID
in an Enrollments table referencingStudent_ID
in a Students table.
3. Candidate Key
- Importance: Concept often linked to primary keys.
- Key Points to Study:
- A set of attributes that can uniquely identify rows.
- Can have multiple candidate keys in a table.
- One candidate key becomes the primary key.
- Examples:
- In a Employees table: Both
Employee_ID
andEmail_ID
can be candidate keys.
- In a Employees table: Both
4. Composite Key
- Importance: Less frequent but still relevant.
- Key Points to Study:
- A primary key made up of two or more attributes.
- Used when a single attribute is insufficient to uniquely identify rows.
- Examples:
- In an Orders table,
Order_ID
andProduct_ID
together form a composite key.
- In an Orders table,
5. Super Key
- Importance: Lesser priority, but helpful for understanding other keys.
- Key Points to Study:
- A set of attributes that can uniquely identify rows, may include extra unnecessary attributes.
- All candidate keys are super keys, but not all super keys are candidate keys.
- Examples:
- In a Students table, both
Roll_Number
and{Roll_Number, Name}
are super keys.
- In a Students table, both
MCQ
Which key uniquely identifies a row in a table and cannot contain NULL values?
A) Candidate Key
B) Foreign Key
C) Primary Key
D) Super Key
Answer: C
Which key is used to link two tables in a relational database?
A) Primary Key
B) Composite Key
C) Candidate Key
D) Foreign Key
Answer: D
What is the purpose of a foreign key in a database?
A) To ensure data integrity within a single table
B) To link two tables and maintain referential integrity
C) To store large amounts of data efficiently
D) To generate unique values for each record
Answer: B
in a relational database, which key ensures that no duplicate values exist in a column or set of columns?
A) Foreign Key
B) Candidate Key
C) Primary Key
D) Composite Key
Answer: C
Which of the following is an example of a composite key?
A) Employee_ID
B) {Order_ID, Product_ID}
C) Email_ID
D) Department_Name
Answer: B
What is the main difference between a candidate key and a primary key?
A) Candidate keys cannot be NULL, but primary keys can.
B) Candidate keys are unique identifiers, but only one is selected as the primary key.
C) Candidate keys enforce referential integrity, while primary keys do not.
D) Candidate keys must include all columns in a table, but primary keys do not.
Answer: B
Which key can contain redundant attributes in addition to the minimum required attributes to uniquely identify a row?
A) Primary Key
B) Composite Key
C) Super Key
D) Foreign Key
Answer: C
How many primary keys can a table have?
A) One
B) Two
C) Unlimited
D) None
Answer: A
What is a super key that contains no unnecessary attributes called?
A) Composite Key
B) Candidate Key
C) Primary Key
D) Foreign Key
Answer: B
Which of the following is true about a foreign key?
A) It must always match the primary key in the same table.
B) It must always match the primary key in a related table.
C) It can have duplicate values within the same table.
D) Both B and C.
Answer: D
In a banking system, which key is best suited to link a customer table with an accounts table?
A) Primary Key
B) Candidate Key
C) Composite Key
D) Foreign Key
Answer: D
Which key is most often selected as the primary key from a set of candidate keys?
A) The key with the longest name
B) The key that best ensures uniqueness and simplicity
C) The key with the highest number of attributes
D) The key with foreign relationships
Answer: B