SQL JOINS

Contents:

  1. Intro 
  2. Basic Joins
    1. Inner Join
    2. Left Join
    3. Right Join
    4. Full Join
  3. Extra Joins
    1. Self Join
    2. Cross Join
    3. Natural Join
    4. Union
    5. Union All
    6. Intersect
    7. Except
    8. Semi Join
    9. Anti Join
  4. Set Theory 
  5. Edge Cases
Primary & Foreign Key
Just a class has a roll number for every student, a table in SQL has a primary key for every row. Foreign key is your roll number in another table which contains your fee installments. 
Primary key is a column in a table which has unique values to identify each row in that table for example your roll number is your class. Foreign key is a column in fees table which links roll number back to the class table. 

In the FEES table, you probably have a different Primary Key for the payment itself (like Receipt_ID).

The Rule: In the FEES table, the Receipt_ID is the Primary Key (each receipt is unique), but the Roll_Number is the Foreign Key (linking that receipt to a specific student).

“A Primary Key says: ‘This is me.’ A Foreign Key says: ‘This belongs to them.’

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top