Primary Key and Foreign Key in MySQL Explained with Examples | MySQL Tutorial

  Рет қаралды 90,670

WsCube Tech

WsCube Tech

Күн бұрын

Пікірлер
@gauravpathak4479
@gauravpathak4479 Жыл бұрын
01:27 Primary key and foreign key constraints in relational databases 02:54 Creating a primary key in a database for unique identification 04:21 Foreign key creates linking between two tables 05:48 Foreign keys link the primary keys of two tables, enabling joint operations. 07:15 Creating a students table with primary and foreign keys 08:42 Creating a city table with id as primary key and city_id as foreign key 10:09 City ID 522 is located in city ID 609 11:29 Enforcing primary key and foreign key constraints is crucial in large-scale relational databases.
@vinaymishra8533
@vinaymishra8533 2 жыл бұрын
sir great work I had search more then 10 tutorials to find this concept but now it is clear
@MuhammadAyaz_786
@MuhammadAyaz_786 Жыл бұрын
what a great work sir
@abdul_moiz_7
@abdul_moiz_7 3 ай бұрын
Great explanation of this topic.
@rksvlog2529
@rksvlog2529 Жыл бұрын
Great....amazing technique
@strangerealm796
@strangerealm796 Жыл бұрын
Jinka error aa rha ho vo cities ki table me primary key (Id) rakhe phrr chal jayega.
@puneetsharma8091
@puneetsharma8091 11 ай бұрын
Thanks
@strangerealm796
@strangerealm796 Жыл бұрын
Sir table banai hai lekin bol rha hai referencing column city_id and referenced column cities (id)is incompatible.😢
@manyadewangan6765
@manyadewangan6765 Жыл бұрын
I have a good doubt sir if we use primary key while creating columns then unique constraint ka koi use nhi hoga?
@Bhumi_rai
@Bhumi_rai Жыл бұрын
unique key mysql accept hi nhi karaga because 1 column pa 2 constraint nhi hote
@hamzaarif6000
@hamzaarif6000 Жыл бұрын
Jab ap kisi column ko primary key set krtay ho to unique constraint lganay ka faida hi nahi q k primary key k column ki hr value unique e hoti hai. Primary key or Unique constraint mein difference ye hai k Primary key hum table k kisi aik column pr lga sktay hain jabkay unique constraint hum table k multiple columns pr lga sktay hain
@hamzaarif6000
@hamzaarif6000 Жыл бұрын
​@@Bhumi_rai2 constraint ho sktay hain. Mainy try kiya tha or mere accept hogaye thy
@rohitk472
@rohitk472 Ай бұрын
Best Explanation sir
@nikhilmore3771
@nikhilmore3771 Жыл бұрын
PRIMARY KEY is parent (confirm on other sources)
@theAdam586
@theAdam586 9 ай бұрын
5. What is a foreign key? Write a query to implement the same in MySQL. This is one of the prevalent MySQL queries interview questions for both beginner and experienced candidates. A foreign key is used to connect two tables. A FOREIGN KEY is a field (or assortment of it) in one table that alludes to the PRIMARY KEY in another table. The FOREIGN KEY requirement is utilised to forestall activities that would crush joins between tables. To assign a foreign key, it is important to mention it while creating the table. It can be assigned by invoking the FOREIGN KEY query. Something like this: FOREIGN KEY (Any_ID) REFERENCES Table_to_reference(Any_ID)
@coolanujkumar5
@coolanujkumar5 Жыл бұрын
missing index for constraint .... in the referenced table
@divyanshsingh8807
@divyanshsingh8807 Жыл бұрын
Solution h kya kuch
@Akagarkar2024
@Akagarkar2024 2 жыл бұрын
kodular ya thunkable per ek video upload kijiye sir please
@CodingMan-f1v
@CodingMan-f1v 2 жыл бұрын
Good explanation
@technicalrider6196
@technicalrider6196 Жыл бұрын
Wrong teaching u have add primary key to city_id if ur refering city_id primary key to foreign key (cid)
@RajeshKumar-jx9ql
@RajeshKumar-jx9ql Жыл бұрын
city_id kisi or table ki primary key hone wali h.....esa kyu hoga???? jbki kisi or table me to already primary ki hmne de rakhi h
@Ukmmtj1
@Ukmmtj1 11 ай бұрын
2:06 email bhi unique hi hota h🤔
@MinabenPatel-u7v
@MinabenPatel-u7v 3 ай бұрын
Ha hota hi haina 😮
@bhaveshmorankar8579
@bhaveshmorankar8579 Жыл бұрын
failed to add the foreign key dikha raha hai isko kaise solve kre?
@prasantaroutray2506
@prasantaroutray2506 Жыл бұрын
bro are you from odisha?
@vedsharma1933
@vedsharma1933 Жыл бұрын
thanks
@lion7366
@lion7366 Жыл бұрын
Error Code: 1822. Failed to add the foreign key constraint. Missing index for constraint
@khushiv2003
@khushiv2003 Жыл бұрын
Same problem
@ruturajkadam5164
@ruturajkadam5164 Жыл бұрын
​@@khushiv2003add constraint while adding foreign, you can give it any namr
@_.innovative_pixel
@_.innovative_pixel 7 ай бұрын
8:00
@vinaymishra8533
@vinaymishra8533 2 жыл бұрын
sir pura syllabous nahi hua hai abhi
@shak1maangaming849
@shak1maangaming849 2 жыл бұрын
failed to add misssing constraints error aa rha hai sir g??
@Tadapatiatma
@Tadapatiatma Жыл бұрын
Mila answe nhi mila to main bata sakta hun
@divyanshsingh8807
@divyanshsingh8807 Жыл бұрын
Koi batayega iska solution kya h
@pulkitjadoun8596
@pulkitjadoun8596 Жыл бұрын
@@Tadapatiatma bata de bhai kese theek hoga
@Tadapatiatma
@Tadapatiatma Жыл бұрын
​@@pulkitjadoun8596 pehle apko 1st table Banna hai jismein apko primary key rakhna hai jo apka 2nd table ka foreign key hoaga means apko pehle 1st table ka primary key create karna ho ga tabhi to ap usko 2nd table mein foreign key aur reference de payenge
@pulkitjadoun8596
@pulkitjadoun8596 Жыл бұрын
@@Tadapatiatma ok bro thanks
@Roller_Roaster
@Roller_Roaster Жыл бұрын
id mai 3 kyu show kr raha last mai?
@harshadaborade5712
@harshadaborade5712 6 ай бұрын
Worst explanation
@shelkeonka
@shelkeonka 2 жыл бұрын
Sir 3 br try Kara laekin failed to add missing constraints error araha hai
@Tadapatiatma
@Tadapatiatma Жыл бұрын
Mila answer nhi mila to main bata sakta hun
@gopalbarnwal7459
@gopalbarnwal7459 Жыл бұрын
@@Tadapatiatma bolo
@rahuldatta1382
@rahuldatta1382 Жыл бұрын
@@gopalbarnwal7459 in the settings of cities, you have to select cid as a primary key
@pulkitjadoun8596
@pulkitjadoun8596 Жыл бұрын
@@rahuldatta1382 kar liys fir bhi nahi ho raha
@vishnujatav6329
@vishnujatav6329 2 жыл бұрын
important
@shubhamnimbalkar8659
@shubhamnimbalkar8659 Жыл бұрын
yedee chale mat kar aaise .....important portion tu bad mai sikha raha hai student ko ...primary key foreign key pahile sikhana tha....time wast
@samiahirfanghouri1136
@samiahirfanghouri1136 7 ай бұрын
Good explanation
FOREVER BUNNY
00:14
Natan por Aí
Рет қаралды 34 МЛН
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 25 МЛН
MySQL PRIMARY KEY & FOREIGN KEY Tutorial in Hindi / Urdu
14:56
Yahoo Baba
Рет қаралды 341 М.
Keys in RDBMS
22:49
Neso Academy
Рет қаралды 376 М.
Database Indexing Explained (with PostgreSQL)
18:19
Hussein Nasser
Рет қаралды 319 М.
MySQL: FOREIGN KEYS are easy (kind of)
8:17
Bro Code
Рет қаралды 243 М.
6 SQL Joins you MUST know! (Animated + Practice)
9:47
Anton Putra
Рет қаралды 205 М.
How to Design a Database
10:57
Database Star
Рет қаралды 72 М.
SQL Joins: Difference Between Inner/Left/Right/Outer Joins
10:52