Тёмный

17 | Create Database Tables in MySQL PHP Tutorial | 2023 | Learn PHP Full Course for Beginners 

Dani Krossing
Подписаться 475 тыс.
Просмотров 55 тыс.
50% 1

In this PHP tutorial I will talk about how to create a MySQL database table, so we can insert data into our newly created database! 🙂 This will be a lon lesson, and I will have chapters bellow the video for easy navigation. 😉
I will cover MySQL tables, including data types, primary keys, foreign keys, and table relationships. 🙂 So there is quite a bit to learn in this video.
➤ TIMESTAMPS
00:00:00 - Introduction to tables
00:04:02 - SQL data types
00:15:42 - SQL SIGNED & UNSIGNED
00:17:20 - Creating our first table
00:26:48 - SQL PRIMARY KEY
00:29:58 - Creating our second table
00:32:28 - SQL FOREIGN KEY
00:35:56 - SQL ON DELETE
➤ GET ACCESS TO MY LESSON MATERIAL HERE!
First of all, thank you for all the support you have given me!
I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank you!
I am now using Patreon and RU-vid Memberships to share improved and updated lesson material, and for a small fee you can access all the material either from my memberships or Patreon, depending on your preference. I have worked hard, and done my best to help you understand what I teach.
I hope you will find it helpful :)
Memberships: / @dani_krossing
Patreon: / mmtuts

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

 

27 июн 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 75   
@Dani_Krossing
@Dani_Krossing Год назад
Hi everyone! Sorry about the long break 🙂 For people who check my community posts, you'll know that I have had to take care of Frida (my dog), who had been extremely sick for the past few weeks. Unfortunately she didn't make it, so I needed some time to deal with all that... But I'm back again now. 🙂
@samnako
@samnako Год назад
Sorry bro for the loss
@yousifky
@yousifky Год назад
😢
@gensys244
@gensys244 Год назад
😢Sorry to hear this all the best
@johnellempuerto3659
@johnellempuerto3659 Год назад
:(
@GerritforBazeja
@GerritforBazeja Год назад
Sorry to hear. Can imagine you needed some time to it.
@ingelegenial
@ingelegenial 4 месяца назад
You are underrated, Daniel. Thank you for everything.
@theSassySquatch
@theSassySquatch Месяц назад
Dani, you are awesome! You are a great teacher! Thank you for your videos!
@UHDking
@UHDking Год назад
Thanks for the freshest mySQL tut from the god of programming tuts(the best one was New Boston but he does not make any tuts anymore for a long time and this is a fresh vs his 2013). Love your tuts Dani and thanks for your time. You are the best on RU-vid.
@davescorneroftheworld1147
@davescorneroftheworld1147 Год назад
Very sorry for your loss. I am not a dog lover but I have lost a few cats in my 73 years so I understand your pain. THANK YOU FOR ALL YOU DO ON THIS TOPIC. I have learned so much from you.
@SamBoxEthiopia
@SamBoxEthiopia 2 месяца назад
Learning php at 73??? You're my Hero.
@davescorneroftheworld1147
@davescorneroftheworld1147 2 месяца назад
@@SamBoxEthiopia Thank you SanBox Ethiopis, I am NOT a Hero! I started out with electricity “talking to me”. Just into high school (in about 1966 or so) I decided I was to lazy to go across the room to turn my TV on and off. I made a WIRED remote control that would turn the TV on and off along with changing the volume. In 1966 NOBODY had ever heard of remote control on TV’s. After high school I went to an electronics school. In 1971 I was a certified electronics technician in the state of Missouri. I only did that for about three years of so. Then I went to work as a welder, with many welding jobs throughout my life. In about 1978 or 79 I started working at of the Pacific Northwest biggest saw mills. In 1983 I touched my FIRST computer. Make sure you get the date right. That was BEFORE Bill Gates was a household name. I have been addicted to them DAMN things every since. I welded in several jobs until about 2003 or so. Then I became a videographer, not long after that I got several jobs as a professional videographer. I retired in 2013 (or so I thought) I still have three to seven video shoots per year, I also help out friends out welding all the time. Soooo, now WHY NOT learn PHP. I am doing pretty well but I will probably never make any money with PHP. After all who wants to hire a 73 year old man. Besides that, I DO NOT WANT A FULL TIME JOB. So here I am setting in front of my two 27” monitors with a gaming system that is very very powerful. NO, I am not a gamer. But like I said I am addicted to computers. So I am not a hero by any means. Just someone that NEVER figured out what to do with my life. (:
@samnako
@samnako Год назад
I'm glad this video is out now when i am trying to design a new website and I will definitely pick one or two knowledge to add to what I'm doing right now. Thank you Daniel
@jackiedavis5574
@jackiedavis5574 5 месяцев назад
You are just the best!! Amazing delivery, simple logical explanation - you have freed me from my exasperation with my websites! Been looking for way to learn to do logins and comments on my site. (I hate those non-verbal, canned music, no explanation videos) but you are phenomenal! Forget binging tv shows, I am binging your tutorials!! Thank you so much! - and I am so sorry about your pup :(
@decall
@decall Месяц назад
I am so sorry to hear about your dog. We recently lost a cat and almost also our dog (but he went well fortunately). I love your lessons... Learned a lot of it...
@akashgola2153
@akashgola2153 3 месяца назад
Sorry to hear about Frida. Hopefully ur over it now. The video was amazing as always. Also what i am liking the most is the logics or practicality inside ur videos. Great Work Keep going🔥
@ArgieHista
@ArgieHista Год назад
Here I am again... Watching your videos and learning for something that no one can taught me easily but You... Thank you for sharing your knowledge.. Godblessed 🙏
@Killer-ke6ff
@Killer-ke6ff Месяц назад
Man you're a savior I have a web development course and you are saving me time and I actually understand you well Thanks for your efforts
@andymalunes8316
@andymalunes8316 16 дней назад
damn, many people just straight to this one, im new to programming and php but i noticed the views jump up for this specific lesson.
@benjicanones1454
@benjicanones1454 Год назад
Superb!
@renatusrichard
@renatusrichard 2 месяца назад
Thank you so much sir, have enjoyed the lesson
@jd2722
@jd2722 3 месяца назад
This is awesome, thank you!
@x6c3
@x6c3 11 месяцев назад
very help for a beginner ❤
@dusandrazevic
@dusandrazevic Год назад
Thanks for the video
@sungodd63
@sungodd63 6 месяцев назад
Very nice video. I was so into it
@sundayemmanuel4789
@sundayemmanuel4789 6 месяцев назад
Thank you
@bilalbeny4172
@bilalbeny4172 4 месяца назад
thank you my brother 😍😍
@nisanka
@nisanka 7 дней назад
Dani Krossing deserves 1 Million subscribers
@yousifky
@yousifky Год назад
❤🎉
@armandoWebDev
@armandoWebDev Месяц назад
Daniel, correct me if I'm wrong, but I read that VARCHAR has tha capability to take a VARIABLE amount of memory, so if we define (30) characters this doesn't mean that will reserve that space in memory, it is just the maximum amount of memory/characters can take in one spot but if you store let's say, 10 characters in a VARCHAR(30) will just consume 10 characters space in memory. Hope my idea is clear. Thank you for your course.!
@fotonext7441
@fotonext7441 10 месяцев назад
FOREIGN KEY REFERENCES must be PRIMARY KEY in the parent table, or can it be any column?
@user-ug9gr3ne1s
@user-ug9gr3ne1s 4 месяца назад
Maybe we have several IDs in the users table. On what basis does the database value users_id?
@omarghabawi1913
@omarghabawi1913 Месяц назад
Hi, I followed your instruction and encountered an error. The database did not accept CURRENT_TIME; instead, it accepted CURRENT_TIMESTAMP. Is there a different syntax to resolve this error? I am also using phpMyAdmin like you. Thank you!
@noelradhakrishnan4423
@noelradhakrishnan4423 7 месяцев назад
I have a doubt though, shouldn't we refer the username from the users table as a foreign key to the comments table?
@IEmirovic
@IEmirovic 11 месяцев назад
Thanks Dani. I have a question. Do we need "username" column inside comments table? We can reach "username" column inside users table with "join" querys. Because we defined foreign key. Thanks again.
@Dani_Krossing
@Dani_Krossing 11 месяцев назад
You are correct, you would be better off doing a inner join SQL statement. 🙂
@ASmallGreenBean
@ASmallGreenBean 11 месяцев назад
​@@Dani_Krossing Thanks! I had the same question. But to clarify a bit more, we don't need to add the "username" column in the "comments" table, right? We can just reference it to the "users" table through the foreign key "users_id", correct? Is there any reason to actually have this kind of "redundant" information in a database table? (On that matter, do you have any video about the key principles of structuring your SQL database? - With your teaching skills, I might finally be able to grasp that... 😅) Oh, and thank you so much for all this useful information and the perfectly structured course!!
@MohammedAlziko
@MohammedAlziko 6 месяцев назад
😘😘😘
@houssainhafed4180
@houssainhafed4180 Год назад
pls create Laravel course
@pain7359
@pain7359 5 месяцев назад
What if, I want to make a note pad project, do i need to make a database for it?
@ShootYourBricks
@ShootYourBricks Год назад
What happens when the auto increment reaches the max allowed number?
@Dani_Krossing
@Dani_Krossing Год назад
Your data will “overflow” and create errors. But unless you plan on creating a website that uses billions of rows in one table, that won’t happen. IF you plan on having more rows than a INT has storage for, then just use BIGINT instead for the id 🙂 Or if you plan on creating a HUGE commercial site like Facebook, which literally stores billions of messages a day, I can imagine they use custom databases with multiple databases specifically for messages only hehe.
@ShootYourBricks
@ShootYourBricks Год назад
@@Dani_Krossing interesting. Yeah I don't plan on ever having 4 billion users on a website lol
@fathimaifla9215
@fathimaifla9215 Год назад
Pls upload a video for front end connected to back end use insert delete upload select update every things in one video . I'm a software engineer student . Your videos are very useful for me
@Dani_Krossing
@Dani_Krossing Год назад
Once I'm done with this MySQL part of the course, the plan is to teach that. 🙂 I do have a older PHP course that shows it too, if you need it now.
@fathimaifla9215
@fathimaifla9215 Год назад
Please do python language also
@fathimaifla9215
@fathimaifla9215 Год назад
​@@Dani_Krossing I need complete video of web-based application design with your explanation. I think it's useful for student
@user-ge1sq3nx1z
@user-ge1sq3nx1z 3 месяца назад
We have the username in both the users table and the comments table? Is that ok? Seems to defeat the point of the relational db.
@hellofromiqbal
@hellofromiqbal 3 месяца назад
Including the `username` column in the `comments` table alongside the `users_id` foreign key column depends on your specific requirements and design considerations. Having the `username` column in the `comments` table can be beneficial in scenarios where you frequently need to display comments along with the username without having to join the `users` table every time. This denormalization can improve query performance, especially in cases where you're frequently retrieving comments and displaying them with usernames, as it eliminates the need for a join operation. However, if you're concerned about data redundancy or prefer a more normalized database design, you can omit the `username` column from the `comments` table and rely solely on the `users_id` foreign key to associate comments with users. In this case, when you need to display a comment along with the username, you would perform a join operation between the `comments` and `users` tables to retrieve the username. In summary, whether to include the `username` column in the `comments` table depends on factors such as performance considerations, data redundancy, and your specific application requirements. Both approaches are valid and have trade-offs that you should consider based on your particular use case. At least this is what I got from chatGPT lol.
@samnako
@samnako Год назад
But Daniel, how do i join your patreon's? I live in Lagos, NIGERIA and I need to do so to support your works.
@Dani_Krossing
@Dani_Krossing Год назад
If you would like to join, there is a link for either my Patreon, or my RU-vid memberships, in the bottom of the description. 🙂
@techgamer734
@techgamer734 Месяц назад
I am getting error that Foreign key constraint is incorrectly formed
@Dineshsharma-ec6ys
@Dineshsharma-ec6ys Год назад
Why php is dying language? And why people are running after javascript frameworks?
@TOMAKAIROS
@TOMAKAIROS 10 месяцев назад
im getting this error.... #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CURRENT_TIME, PRIMARY KEY (id) )' at line 6 is my version too new??? or is it too old? how do i check the version?
@Dani_Krossing
@Dani_Krossing 10 месяцев назад
What is the full SQL that you tried to submit?
@TOMAKAIROS
@TOMAKAIROS 10 месяцев назад
@@Dani_Krossing I’m not sure what you mean by that but I did everything that’s in the video. It seems it only works if I do CURRENT_TIMESTAMP instead of CURRENT_TIME. Is there a difference?
@hortensiamusic6670
@hortensiamusic6670 4 месяца назад
​@@Dani_Krossing I have the same problem: CREATE TABLE users ( id INT(11) NOT NULL AUTO_INCREMENT, username VARCHAR(30) NOT NULL, pwd VARCHAR(200) NOT NULL, email VARCHAR(100) NOT NULL, created_at DATETIME NOT NULL DEFAULT CURRENT_TIME, PRIMARY KEY(id) );
@RelateAndElevate
@RelateAndElevate 11 месяцев назад
Do you have paid courses in Udemy?
@typo368
@typo368 10 месяцев назад
Mine is throwing errors at the "DATETIME" statements in both tables, i deleted both of them and is good?
@TOMAKAIROS
@TOMAKAIROS 10 месяцев назад
im getting the same error.... did you find the solution? this is my error #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CURRENT_TIME, PRIMARY KEY (id) )' at line 6
@Noah-qu9fb
@Noah-qu9fb 22 дня назад
i'm getting the same thing. from what i can gather from searching it, DATETIME will be obsolete in about 15 yrs? people seemed to lean toward using timestamp so...i just used that instead and stopped getting the error lol
@davescorneroftheworld1147
@davescorneroftheworld1147 Год назад
At 29:08 of this video when you created the TABLE, just above you we see two tables. "New" and "users", where did the "New" table come from?
@Dani_Krossing
@Dani_Krossing Год назад
That’s not a table 🙂 that’s a button you can click to create a new table
@davescorneroftheworld1147
@davescorneroftheworld1147 Год назад
@@Dani_Krossing OK. Thank you very much for your time.
@andymalunes8316
@andymalunes8316 12 дней назад
bro is there a difference between CURRENT_DATE CURRENT_TIMESTAMP, and CURRENT_DATE CURRENT_TIME?
@bilalbeny4172
@bilalbeny4172 4 месяца назад
I just have one note, by default when we define a column as a primary key, its is impossible to be null and must be unique, in other words: PRIMARY KEY = NOT NULL + UNIQUE, so we can not use NOT NULL constraint with a column when it's a primary key.
@henryuchenna7785
@henryuchenna7785 6 месяцев назад
Am getting user_id error.
@Trunk_Tech
@Trunk_Tech 9 месяцев назад
Why did we not use the field "ID" (PRIMARY KEY) in the Comments table as the FOREIGN KEY in references rather than creating user_id Field to act as a FOREIGN KEY ??
@Dani_Krossing
@Dani_Krossing 9 месяцев назад
Because the ID has to be unique to that particular entry, and not based on other tables. Otherwise a bunch of issues can happen. Primary Keys should not be Foreign Keys.
@heinzerbrew
@heinzerbrew 4 месяца назад
What's the point of having an id when you already have a unique username?
@Dani_Krossing
@Dani_Krossing 4 месяца назад
The ID is for the table row, which is different. There HAS to be a unique id for all rows of data, which isn’t up to the user to decide. Having the ID be a number, also makes it easier to list them all out if needed.
Далее
Спасибо Анджилишка, попил😂
00:19
Gale Now VS Then Edit🥵 #brawlstars #shorts
00:15
Просмотров 317 тыс.
Full SQL Crash Course - Learn SQL in 90 Minutes
1:28:09
6 SQL Joins you MUST know! (Animated + Practice)
9:47
Просмотров 110 тыс.
Learn SQL Basics in Just 15 Minutes!
16:57
Просмотров 118 тыс.