Exercises · Q6
Q.Distinguish between a primary key and a foreign key, and explain how a foreign key creates a relationship between two tables with an example.
Maharashtra MsbshseTextbookSubjectiveImportance★★★★★est
43% · 6/14 Questions
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →A primary key and a foreign key are both keys, but they do different jobs.
- A primary key is a field whose value uniquely identifies each record within its own table; it must be unique and never blank.
- A foreign key is a field in one table whose values refer to the primary key of another table. It is the mechanism that creates a relationship (link) between two tables.
Example. Consider two tables:
Customer(CustID, Name, City)— hereCustIDis the primary key.Orders(OrderNo, CustID, Amount)— hereOrderNois the primary key, andCustIDis a foreign key that refers back toCustIDin theCustomertable. …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.