Тёмный

Database Design 27 - Foreign Key 

Caleb Curry
Подписаться 624 тыс.
Просмотров 40 тыс.
50% 1

Start your software dev career - calcur.tech/dev-fundamentals 💯 FREE Courses (100+ hours) - calcur.tech/all-in-ones
🐍 Python Course - calcur.tech/python-courses
✅ Data Structures & Algorithms - calcur.tech/dsa-youtube
~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~
✉️ Newsletter - calcur.tech/newsletter
📸 Instagram - / calebcurry
🐦 Twitter - / calebcurry
🔗 LinkedIn - / calebcurry
▶️ Subscribe - calcur.tech/subscribe
👨🏻‍🎓 Courses - www.codebreakthrough.com
~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~
↪ My Amazon Store - www.amazon.com/shop/calebcurry
🅿 Patreon - calcur.tech/patreon-calebcurry
🅖 GitHub Sponsors - github.com/sponsors/CalebCurry
Ⓟ Paypal - paypal.me/calcur
🅑 Bitcoin - 3HnF1SWTzo1dCU7RwFLhgk7SYiVfV37Pbq
🅔 Eth - 0x350139af84b60d075a3a0379716040b63f6D3853
📈 Buy Bitcoin - calcur.tech/crypto
Reserve the Ruby Steel crypto rewards card and get a $25 bonus (use affiliate code "Caleb") - calcur.tech/crypto

Наука

Опубликовано:

 

8 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 42   
@veedjohnson
@veedjohnson 3 года назад
Hi, just here to tell you that it's 2021 and this database playlist is really helpful!
@codebreakthrough
@codebreakthrough 10 лет назад
Learn about Foreign Keys by watching this video. Please click "like" on the video! buff.ly/1swqZBQ
@wejoyskp
@wejoyskp 7 лет назад
Thank you Caleb. Very clear and i understood with your real life example.
@asirsakin5562
@asirsakin5562 8 лет назад
i,v noticed you worked late at night sir, but you made that morning useful
@abdessamadbourhjoul7386
@abdessamadbourhjoul7386 3 года назад
Still helpful in 2021! thank you for this masterpiece.
@dhegana
@dhegana 8 лет назад
Nice one caleb! Please keep on making videos about database
@FabianBarajas
@FabianBarajas 8 лет назад
really well done. Thanks
@ganiyatadebayo8725
@ganiyatadebayo8725 6 лет назад
Hi, I've got an orderDetails table that has orderID and productID as primary keys. However, i'm confused if they are both going to be foreign keys as well.
@UsefIbba
@UsefIbba 7 лет назад
What's up dude, thanks bro!
@arnmazing3156
@arnmazing3156 6 лет назад
IDK if I'm getting this but as I understand if you want to create a table that needs columns from another table you have to use Foreign Key to access it. Kinda like in java to access another class you need to initialize an object that reference the class that you want to use. Do foreign keys have to be Primary keys?
@Patignar
@Patignar 9 лет назад
Great Tutorial!
@Serraomomma
@Serraomomma 8 лет назад
Thanks!
@titorojas7703
@titorojas7703 7 лет назад
Hey caleb, I was wondering how to join tables with no common columns? Love your videos dude!
@nikunjkelatkar313
@nikunjkelatkar313 8 лет назад
nice video dude thanx
@rohitmewar9094
@rohitmewar9094 9 лет назад
thanks Caleb... :)
@minhtao9774
@minhtao9774 7 лет назад
Thank youuuuuuuuuuuuu!!!!!!!!!!!!!
@nayooti298
@nayooti298 9 лет назад
Hey Caleb, tx for all the work. I do have a question though. If a primary key of a entity-type is kombined by two attribute-types, say a student's 'first name' and 'last name'. How does is this student represented in a different table, or generally: how does the foreign key looks like, when it's related primary key consists of two or more keys? Tx!!!!
@najoudalabeedi8906
@najoudalabeedi8906 9 лет назад
thank u so much
@dis0rder3d
@dis0rder3d 9 лет назад
way to break it down my brother. thanks
@changeluhia
@changeluhia 6 лет назад
this video is legitt
@arslanali774
@arslanali774 6 лет назад
how can i connect with you ?
@whereweregoingwedontneedey4374
Here's a question - the reasoning for using lookup tables and using foreign keys is sometimes stated as to avoid mistakes if things change (in this example, you gave if the building name changed from legit to legitt - however, doesn't the DbMS automatically do this for you anyway - for example, change all instances of legit to legitt?
@3Nex
@3Nex 9 лет назад
Paul French Of course not, and it would be horrible if it did. That would also imply that if you have a table with users (where there is a varchar column called `name`), and two of those users were named David; when one of the Davids changes his name to Mark, the other one would have his name changed. That is never supposed to change automatically, in the real world, or a digital one. Unless you have specifically designed your table to do so because of your own internal reasons that are familiar to you and make sense for your scenario.
@satadhi
@satadhi 9 лет назад
good job man
@amandaknapton1626
@amandaknapton1626 9 лет назад
A class im taking touches on databases and we are supposed to develop tables based on a case study and then draw relationships, primary and foreign keys. Every time I think I get it, I don't. Help?
@codebreakthrough
@codebreakthrough 9 лет назад
Amanda Knapton my advise is to just study your face off on the matter. School will try to tell you there is only 1 definite right way to do things, but this isn't always the case. Often it is though.Learn every concept in this course. They will cover all of the subjects covered in class likely. Any other questions can be left in a comment.
@amandaknapton1626
@amandaknapton1626 9 лет назад
Thanks Caleb, you are very good in your videos! Regarding this primary and foreign key business, Lets say *PtID# is the primary key in a table, in the next table I would have it as the **foreign key so that I will have the direct relationship... but then what would the *primary key of my second table be since the PtID# seems to be the only unique identifier in the table but it is already the foreign key? follow? I'm just trying to get a basic understanding because this a relatively small part of the class content, and maybe 35% of the final grade... theres a group assignment due saturday and then our database individual assignments are due in a month. With other assignments due before that and moving on to different topics. Thanks again! p.s. I'm also not so savvy about how youtube comments even work... so ummm hopefully after I leave the library I will be able to find your reply...have so much to learn.
@codebreakthrough
@codebreakthrough 9 лет назад
I'd tell you how to find your reply but that would kinda be pointless :P The second table...what is it for? What is it storing? Whatever it is storing will have a primary key. So I'm guessing PtID# is pateint ID number or something? Well if you had a table for diet plans you would have diet plan ID (PK) and PtID (foreign key). It might not be the same example but you can apply it the same.
@GinnHardcore
@GinnHardcore 6 лет назад
If you take his example and say you have 3 building 16's because you have building 16 recurring does that mean the database is not normalized or are foreign keys an exception to the rule and aloud duplicates in there row
@codebreakthrough
@codebreakthrough 6 лет назад
Foreign key columns can allow duplicates if the column is labeled NULL-able. That's because they are purely a reference and the db restrains you from doing dumb stuff.
@GinnHardcore
@GinnHardcore 6 лет назад
CalebTheVideoMaker2 thank you for the reply Caleb much appreciated:) I think I've near enough watched your entire series!
@abrorakhmedov7389
@abrorakhmedov7389 Год назад
well its 08.2022 still helpfull
@hermainesanchez4514
@hermainesanchez4514 7 лет назад
gwapo tani lain man agi hehehe
@sierrakilo9695
@sierrakilo9695 5 лет назад
Hey Caleb, great videos, hope you're still active here. So if you are adding 2 foreign keys to one entity, what does that make it? As in 1:n or m:n at that point?
@AnontheGOAT
@AnontheGOAT 5 лет назад
I think it would be a m:n because you are connecting essentially two data tables/entities to one or more rows in another table.
@bharat3519
@bharat3519 7 лет назад
can there be two primary keys in a single table ? For example if a table CONTACT contains contact number, contact name, address. Then generally contact number has to be primary key. But what if two different persons use the same contact number ? (like father and son).
@codebreakthrough
@codebreakthrough 7 лет назад
+Bharat Chandra there can never be two primary keys. There can be composite keys or surrogate keys, though. If you don't have enough to make each row unique, consider adding a column or two!
@mohamed_elhariry
@mohamed_elhariry 7 лет назад
There can't be more than one primary key in a relation (table). Therefore you might think about choosing another key as primary. Although, if you can't choose another one, you might consider creating a composite key or a surrogate key. A composite key combines multiple attributes so that you can uniquely identify a row. For example, in a given table where you have attributes like name, surname, address, phone#, neither of these attributes alone can uniquely identify a row. But if you consider all or some of them together, then you will be able to uniquely identify a specific row. This is how you create a composite key: CREATE TABLE CONTACT( Name VARCHAR(20), Email VARCHAR(50), PRIMARY KEY (Name, Email) ) A surrogate key, instead, is just an incrementing ID that you create every time a new tuple is created. That way you will always be able to uniquely identify a row. This is how you create a surrogate key: CREATE TABLE CONTACT( ID int NOT NULL AUTO_INCREMENT, Name VARCHAR(20), Email VARCHAR(50), PRIMARY KEY (ID) );
@sreism
@sreism 6 лет назад
+Mohamed Elhariry can you please explain the difference a bit more?
@sreism
@sreism 6 лет назад
+Mohamed Elhariry can you please explain the difference a bit more?
@albaghdadinoah7196
@albaghdadinoah7196 2 года назад
Why I do feel that you are explaining the same concepts in the last 10 videos
@vikasgautam7717
@vikasgautam7717 7 лет назад
handwriting is pathetic or else good
Далее
Database Design 28 - NOT NULL Foreign Key
13:12
Просмотров 20 тыс.
Database Design 23 - Superkey and Candidate Key
19:15
Database Design 22 - Look up Table
16:53
Просмотров 70 тыс.
SQLite3 in Node with better-sqlite3
12:08
Просмотров 4,8 тыс.
Primary & Foreign Keys
8:25
Просмотров 471 тыс.
Learn Database Normalization - 1NF, 2NF, 3NF, 4NF, 5NF
28:34
Database Design 29 - Foreign Key Constraints
11:46
Просмотров 39 тыс.
Database Design 7 - Data Integrity
13:26
Просмотров 90 тыс.
Сложная распаковка iPhone 15
1:01
Просмотров 15 тыс.