3 years later and its still useful, love these timeless education videos. Thank you for putting the effort and time to make these!
@jacksurtees85775 жыл бұрын
Gimli to Legolas: I never thought I’d end up in the same database as an elf!
@twotentsdown2 жыл бұрын
Thank you, thank you! This video helped me with several syntax errors I had. You also explained foreign key constraints in a way that finally made sense to me!
@ravenkavoori5 жыл бұрын
I've been using MySQL for a couple of years but never created foreign keys despite the advice of fellow developers because i dont have clear understanding about it until now thank you.
@jamesarvinrozul82934 жыл бұрын
Thanks a lot. I'm having trouble in creating relationships in MySQL and this really helped me.
@kalkalasch4 жыл бұрын
5:10 is when he writes the actual query to make the link between the tables. Thanks alot for the videos, they're very high quality!
@simplejuan3 жыл бұрын
Thank you Steve! You don't know how happy I am (new to MySQL) to find your video. This is really helpful. Very clear explanation on Foreign Key! I salute you!
@SteveGriffith-Prof3ssorSt3v33 жыл бұрын
Be sure to check out the rest of the MySQL playlist too
@mohammedakel5204 жыл бұрын
Whether it's for school or work, Steve's videos will always save your ass👌
@niek18993 жыл бұрын
Explained the right way, easy to follow. Great video!
@victornwulu609511 ай бұрын
Thank you Steve, keep doing what you do!!
@ignaciodamiang3 жыл бұрын
Thank you very much! from Buenos Aires, Argentina.
@ultimatebot9002 жыл бұрын
Very good video! Been trying to figure out how to do this for a long time. Specifying on update and on delete helped me out very much!
@jogarule Жыл бұрын
Thank you so much! Great presentation and clear understanding.
@SLCODEGEN Жыл бұрын
Very bright Explanation! Thank a Lot
@olivierkrull30744 жыл бұрын
Very clear and understandable. Thank you
@taki-eddinechih51977 ай бұрын
excellent example and explanation!
@azuredominus57394 жыл бұрын
Really well done lesson! You earned a subscriber!
@MonisKhan4 жыл бұрын
Great explanation. Absolutely loved it ♥️
@ZizoAhmed4 жыл бұрын
you're great sir , you made me love it though i'm not a specialist , I just have a little job that is related to mysql
@Rohan1223 жыл бұрын
This is awesome!Thank you so much
@jorgedavalos56632 жыл бұрын
thanks for the tutorial! really good
@elmirabelo89965 жыл бұрын
Your videos are so good that one like isn't enough.
@chujekwu4 жыл бұрын
Great job Man... Please could you make a video based on table with blob data type ?
@SteveGriffith-Prof3ssorSt3v34 жыл бұрын
Please add your requests in the comments here - kzbin.info/www/bejne/gnTIq5SuZ9qBacU
@madiarification3 жыл бұрын
Thanks! Very nice explanation!
@darter19905 жыл бұрын
Professor, really thank you for these tutorials. May I ask you one thing: "when" someone may be classified as an "expert" in SQL? These tutorials, from one to ten, how much do they say about sql skills for a job?
@SteveGriffith-Prof3ssorSt3v35 жыл бұрын
Well there will be 40 or so videos in this course. If you really understand everything that I cover then you really should be capable of doing most development work with MySQL. I would say that this is a DBA course because I'm not covering management of the database or optimization to a great degree. So I would not expect you to be an expert but competent and capable yes.
@darter19905 жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 I appreciate your answer Professor; I'm studing for becoming an etichal hacker by using open source tecnologies like Kaly Linux, and since it run a PostgreSQL DB, your course is a great boost to my studies; for now i'll use my LAMP Xubuntu for training.Thanks again.
@sythous13132 жыл бұрын
You mentioned what when you have a foreign key, that you should add an index to it. What is that? And could you maybe explain what the index does? (3:32)
@SteveGriffith-Prof3ssorSt3v32 жыл бұрын
If you don't create the index on the foreign key it will be automatically created for you. Indexes are to improve search performance on tables - kzbin.info/www/bejne/r4jNZGVmpKqEe9E
@FlyMoe69 Жыл бұрын
Great video, but what if I wanted to delete Men out of the Races table? Would I have to remove all instances of Men from the Characters table first?
@SteveGriffith-Prof3ssorSt3v3 Жыл бұрын
That or set up a trigger to do the deletes for you
@JoshuaMusau3 жыл бұрын
This is awesome!
@Maccelerate5 жыл бұрын
Do you sleep? Great video!
@007-h3v4 жыл бұрын
Great video thanks so much!!! I have a question. What if say Soren killed all humans. I want it instead of preventing the delete to delete all the human entries and delete the race entry?
@SteveGriffith-Prof3ssorSt3v34 жыл бұрын
You would want to use ON DELETE CASCADE as the trigger. to remove all entries where the race_id matched the value in the RACES table that you delete. Deleting the value in the RACES table is the starting point.
@007-h3v3 жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 Thank you! :)
@user-fr5be6gy3u3 жыл бұрын
Thank you.
@KonohaNoSai20083 жыл бұрын
Hi, first of all, many thanks for your tutos... they are super clear ! I've got a question: At minutes 8:00, when you click on the dropdown list, you've got the "id" and the "race" value. When I try this on my computer, i've got the "id", but, in my case I would have the "customer_name", instead i've got the "city" of my customer. I've checked my FK twice, and it seems to be correct. Any idea? Thanks for your help
@SteveGriffith-Prof3ssorSt3v33 жыл бұрын
If you had previous foreign keys with the same name or on the same columns then it could just be phpMyAdmin using a saved cached reference value.
@KonohaNoSai20083 жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 I don't think, but I forgot to mention that I've imported the tables from an SQLite DB. Anyway, I will try to clear the cache. Thanks for your help💪🙏
@SteveGriffith-Prof3ssorSt3v33 жыл бұрын
@@KonohaNoSai2008 yeah. Without seeing exactly what was imported and set up it's hard for me to say.
@EduardoDiNapoli665 ай бұрын
Hi, great tutorial. Never used Foreign key in my web applications. Appreciate this tutorial, It's great but how make "characters.race_id" follow "races.race_id" while inserting new records in "races" table and "characters" table ? Do they must have the same "Autoincrement" value when start populating them ? Or/and...what if I make "insert" queries only into one of them ? Except for the reasonable motife to avoid the accidental corruption of data, I can't really see why "Foreign Key" must be used....Please convince me that I'm wrong. Thanks in advance.
@SteveGriffith-Prof3ssorSt3v35 ай бұрын
Inserting into two tables is two steps, two separate queries. The auto increment value is only used for a primary key. When you insert into two tables, do the one with the auto increment value first. Then that number gets used as the foreign key in the other table. Constraints control what happens when a foreign key value doesn't match the primary key in the related table, or if you are deleting a record whose primary key is a foreign key in another table. Do you want to delete the related records? stop the delete happening? or go ahead and let the record have a null foreign key value. Marking a primary key column as being a foreign key means that you are clearly explaining the relationship between two tables. Eg: Users user_id int (auto increment primary key) username varchar user_type int (foreign key here defines the connection to the UserTypes table) UserTypes type_id int (auto increment, primary key) this is used as a foreign key type_name varchar
@EduardoDiNapoli665 ай бұрын
@@SteveGriffith-Prof3ssorSt3v3 Suppose that I have 1) "Products" table with prod_id Auto_increment, and... + - - - -+ - - - - - - + | prod_id | name | + - - - -+ - - - - - - + | 1 | prodOne | | 2 | prodtwo | + - - - -+ - - - - - - + 2) "images" table with id_image in Auto_Increment + - - - - + - - - - + - - - - + | id_image | filename | id_prod | + - - - - + - - - - +- - - - + | 55 | one.jpg | 1 | | 68 | two.png | 1 | | 76 | tree.jpg | 2 | | 76 | four.jpg | 1 | | 76 | five.jpg | 2 | | 76 | six.jpg | 1 | | 76 | seven.jpg | 2 | + - - - - | - - - - | - - - - + What i'm suppose to do for automatically store the "prod_id" of a new product just inserted into the "id_prod" column of images table without to recour the special native functions like mysqli_insert_id($conn) or similar stuff, but with a foreign key constraint instead ?
@CharlesDv5 жыл бұрын
Nice!
@superfreiheit14 жыл бұрын
09:43 Is it possible to delete rows at the character table? Probably yes because their primary key does not used in other tables?
@SteveGriffith-Prof3ssorSt3v34 жыл бұрын
yes. correct.
@yashito81503 жыл бұрын
I set up a couple of tables with foreign key constraints similar to your clip. I had already created the two tables, so I designated constraints using the Relation View. When I tried to insert or update the id field, it only shows the number ("2" instead of "2-Man" in your example). This makes inputting the data much more inefficient. Do you know how I may be able to fix this problem?
@SteveGriffith-Prof3ssorSt3v33 жыл бұрын
Sounds like you are missing the index that I created on the second table, when creating my foreign key.
@yashito81503 жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 Thank you for your prompt comment. I thought I did but I may be wrong. I will try your example using SQL to see what I am doing differently.
@yashito81503 жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 The result was the same with SQL. I only got the number. Perhaps it is the phpMyAdmin available from the rental server. It's version is 4.4.15.8.
@yashito81503 жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 I tried the latest phpMyAdmin ver. 4.9.7 from MAMP and it worked the same way as your example. Thank you!!
@yinkagiwa4154 жыл бұрын
what is the use of the constraints name please?
@SteveGriffith-Prof3ssorSt3v34 жыл бұрын
A constraint is a type of restriction that you are putting on the table. You are adding restrictions on what data is allowed to be added to the table (or updated or deleted) dev.mysql.com/doc/refman/5.7/en/constraints.html
@yinkagiwa4154 жыл бұрын
Thanks alot for the response. I understand what the constraint is for . I just don't understand why it had to be named since the name wasnt referenced anywhere else in the query .
@SteveGriffith-Prof3ssorSt3v34 жыл бұрын
You will almost never reference a constraint by name. It does its work behind the scenes. It is making sure that you other queries don't do things that you don't want to have happen.
@yinkagiwa4154 жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 Alright, i see. Thank you.
@juanyang8384 жыл бұрын
W/o any of offensives, It's really bad idea having same name 'race_id' in 2 different tables in my opinion. It makes hard to figure out which race_id is in race table or character table.
@SteveGriffith-Prof3ssorSt3v34 жыл бұрын
If the field is the primary key in one table and the foreign key in another then they are the same number regardless of the table. In your queries you should always include the table name or alias. It is actually a best practice to give them the same name. That way you can tell at a glance that they are related keys. If the fields are not related, or not the same values, then you shouldn't give them the same name.
@aadil42364 жыл бұрын
Does a foriegn key has to point to primary column...?
@SteveGriffith-Prof3ssorSt3v34 жыл бұрын
Yes. That is what makes it a foreign key.
@aadil42364 жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 you're the best teacher ever, thanks for the answer.
@AfricaTake22 жыл бұрын
might you have deleted the links you said you would post?
@SteveGriffith-Prof3ssorSt3v32 жыл бұрын
What links?
@rohith63133 жыл бұрын
can foreign key be null?
@SteveGriffith-Prof3ssorSt3v33 жыл бұрын
If you allow null as a value for the column yes. But then it's not connected to the other table.
@V99.23 жыл бұрын
Why do you need that many browsers??? 🤔🤔
@SteveGriffith-Prof3ssorSt3v33 жыл бұрын
As a web developer I need to be able to test features across all the platforms. Lots of browsers, different versions and I have other OS with the browsers too.