What is the difference between Primary Key, Composite Key and Foreign Key?

preview_player
Показать описание
I am trying to make the concepts easier for myself and others around me to understand and visualize and remember and revise the SQL topics before an interview.

Please find my slide notes on my blog -
Рекомендации по теме
Комментарии
Автор

This was a very good explanation. Thank you x

lolaoduguwa
Автор

Your explanation is very helpful for me... Thanks and keep it up 😇

Imyashmita...
Автор

U were stucking fumbling alot while explaining. It is distracting Lister. So just try to improve that

sujatajamale
Автор

Hey there, keep up the good work in this channel.
I have a general enquiry as a new sql learner.
What is the major difference between primary key and unique unique.. In what way they are different inside sql syntax?
Thanks for taking care of this.

hasanmougharbel
Автор

Hi,
thanks for your tutorial...
I am trying to apply what you said in my current task of my project and I'm having a dilemma.
Please help me with this.
I have 3 tables:
table Title:
- id
- name
table TitleRank:
- id
- name
- title_id
- rank
table UserTitleRank
-id
-name
-user_id
I want to create FK at `UserTitleRank` to reference the `title_id` and `rank` at `TitleRank`.
I have 2 choices:
1/ create composite FK `title_id` and `rank` at `UserTitleRank` table referencing `title_id` and `rank` of `TitleRank`
2/ create single FK `title_rank_id` referencing `id` of `TitleRank`
Which one is better?
What is the pros and cons of each and what is the implication and context I should take into account to select one over another?
Thank you.

freeidol