Комментарии:
CREATE TABLE customers (
customer_id INT PRIMARY KEY AUTO_INCREMENT,
first_name VARCHAR(50),
last_name VARCHAR(50)
);
INSERT INTO customers (first_name, last_name)
VALUES ("Fred", "Fish"),
("Larry", "Lobster"),
("Bubble", "Bass");
SELECT * FROM customers;
-- Add a named foreign key constraint to a new table
CREATE TABLE transactions (
transaction_id INT PRIMARY KEY AUTO_INCREMENT,
amount DECIMAL(5, 2),
customer_id INT,
FOREIGN KEY (customer_id) REFERENCES customers(customer_id)
);
ALTER TABLE transactions
AUTO_INCREMENT = 1000;
-- Add a named foreign key constraint to an existing table
ALTER TABLE customers
ADD CONSTRAINT fk_customer_id
FOREIGN KEY (customer_id) REFERENCES customers(customer_id);
@brocode I am late to the party. This is hands down the best video I have watched to explain PK and FK. Thank you
ОтветитьThe typing sound is so satisfying😅
Ответитьi like ur videos short and unique style of teaching, very easy to get, specially my main language is not english
ОтветитьWhat if I have 3 tables and the 2 nd table has a dk with 3 rd table and vice-versa and it shows error while execution.
ОтветитьThanks a ton Man!
ОтветитьI HAVE A QUESTION WHY YOU HAVE DROPPED THE TABLE?
PLS CAN SOMEONE RESPOND!!!!
thank you so much, help me to understand
Ответитьwhy is mine key.. doesn't exist in table i write it exact like yours tho
Ответитьnice video, easy to understand. May Allah increase your knowledge and be blessed with knowledge
Ответитьbro why u always have the BEST tutorials out there and as much as i search the whole yt i always end up warching YOUR vids?😂 keep up the good work man all of us IT students appreciate it. you are far better than our professors
Ответитьdidnt work..column missing
ОтветитьThank you so much!!!
ОтветитьThank you
ОтветитьVery Nice Explanation,Sir.Needs More.
ОтветитьYou are the best! You make a difference on this world!
ОтветитьBro your tutorials are better than my sql teacher , you probly saved my test and also made me appreciate sql way more, much thanks!
ОтветитьWhat is transaction_ibfk_1?
ОтветитьCan we put a foreign key in a constraint. Like table_1 has column_D.O.B as primary key and table_2 has column_joining_date and joining_date should be greater than D.O.B .
How do we do that?
Thank you, you made this super easy to understand! One question, would the foreign key ever be a primary key as well in the transactions table?
Ответитьhow to make foreign key on non primary columns?
ОтветитьThis has saved my life! Managed to get my module done with weeks to spare thanks to you :)
ОтветитьReally frustrated till now trying to learn how primary key work.
I have no idea how to insert multiple same column data (the assigment the gave me) meanwhile primary key doesn't work if you add duplicate data, besides that problem i pretty much know well how to use mySQL, thanks to this video ofc
I really like all your videos!
And I really want you will upload about Spring Framework. 😇
very concise and understandable, thanks master!
ОтветитьHey Bro Code, Can you please please help me with creating a draw method in a tick-tak-toe game you created your-self, I really want that, and I've been trying for weeks, but I could not figure any way out. Please if you know how to create one, replay in my comment.
ОтветитьGreat video! Any plans on covering relational databasing? That's probably the next thing that stumps a lot of people imo
Also huge respect for the fundraiser, it's a great cause :)
Cool video bro :) better than going through theoretical crap - straight to action
ОтветитьLitarly covered this in class yesterday tnx Bro! Your timing is as always great
ОтветитьWeeks of classes condensed into just a few videos, thank you for making this!
ОтветитьI rarely need these kinds of videos but i still click and give a like just cuz ur a good guy and teacher
Ответить