Foreign key is used to______
Answer: A) Establish relationship
A Foreign Key is a field or combination of fields in one table that refers to the Primary Key of another table. It is mainly used to establish a relationship between two tables in a relational database.
A. Establish relationship – Correct
A Foreign Key connects two related tables and helps maintain referential integrity.
Example:
- Student Table: Student_ID (Primary Key)
- Marks Table: Student_ID (Foreign Key)
Here, the Student_ID in the Marks Table refers to the Student_ID in the Student Table. This creates a relationship between the two tables.
B. Indexing table – Incorrect
A Foreign Key is not primarily used for indexing a table. However, Microsoft Access automatically creates an index for a Foreign Key field in some relationship settings.
C. Unique record – Incorrect
A Foreign Key does not necessarily contain unique values. Multiple records can have the same Foreign Key value.
For example, several subjects or marks records may belong to the same student.
D. All of the above – Incorrect
Since options B and C are not the primary purposes of a Foreign Key, this option is incorrect.
Foreign Key (फरेन की) भनेको एउटा Table मा रहेको यस्तो Field वा Fields को समूह हो, जसले अर्को Table को Primary Key लाई Reference गर्छ। यसको मुख्य प्रयोग Database का दुईवटा सम्बन्धित Tables बीच Relationship (सम्बन्ध) स्थापना गर्नु हो।
A. Establish relationship – सही उत्तर
Foreign Key ले दुईवटा सम्बन्धित Tables लाई जोड्ने काम गर्छ र तिनीहरूबीचको सम्बन्धलाई व्यवस्थित राख्न मद्दत गर्छ।
उदाहरण:
- Student Table: Student_ID (Primary Key)
- Marks Table: Student_ID (Foreign Key)
यहाँ Marks Table मा रहेको Student_ID ले Student Table को Student_ID लाई Reference गर्छ। यसरी दुईवटा Tables बीच सम्बन्ध स्थापित हुन्छ।
B. Indexing table – गलत
Foreign Key को मुख्य उद्देश्य Table मा Index बनाउनु होइन। यद्यपि Microsoft Access मा केही Relationship Settings अनुसार Foreign Key Field मा स्वतः Index सिर्जना हुन सक्छ।
C. Unique record – गलत
Foreign Key मा एउटै Value धेरै पटक आउन सक्छ। यसमा Unique Value हुनैपर्छ भन्ने छैन।
उदाहरणका लागि, एउटै विद्यार्थीका धेरै विषयका प्राप्ताङ्कहरू हुन सक्छन् र ती सबै Records मा एउटै Student_ID प्रयोग हुन सक्छ।
D. All of the above – गलत
B र C Foreign Key का मुख्य उद्देश्य नभएकाले यो विकल्प सही हुँदैन।
Exam Tip:
- Primary Key: प्रत्येक Record लाई Unique रूपमा पहिचान गर्छ।
- Foreign Key: दुईवटा Tables बीच Relationship स्थापना गर्छ।
Primary Key मा Duplicate र NULL Value हुँदैन।
Foreign Key मा Duplicate Value हुन सक्छ।

