What's in a Database?
An easier way to diagram accout table.
Every one having different hobbies. Remove the hobbiles column and put it in its own table
Linking two tables in a diagram
Connecting Two tables
The problem we're trying to use name field to somehow let use connect the two tables. But what if two people in the accout table have the same name ?
Foreing Key Facts :
A foreign key can have a different name that the primary key it comes form.
The primary key used by a foreign key is also knownas a parent key. the table where the primary key is from is knows as a parent table.
The foreing key can be used to make sure that the rows in on table have corresponding rows in another table.
Foreign key values can be null, even thugh primary key values can't.
Foreign key don't have to be unique - in facts, they ofter aren't
CREATE TABLE accout(
user_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
CREATE TABLE hobbies(
hob_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,hobby VARCHAR(100) NOT NULL,
user_id INT NOT NULL,