Learning MySQL - FOREIGN KEY CONSTRAINTS

Publicado el: 02 junio 2019
en el canal de: Steve Griffith - Prof3ssorSt3v3
44,679
697

This tutorial covers what Foreign Keys are, what Constraints are, how to create foreign keys, constraints and how to implement actions based on the constraints.

MySQL Playlist:

MySQL Foreign Key Constraint Reference:

CODE SAMPLE:
ALTER TABLE characters DROP FOREIGN KEY `fk_character_race`;
DROP TABLE IF EXISTS races;
DROP TABLE IF EXISTS characters;

CREATE TABLE races (
race_id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
race_name VARCHAR(30) NOT NULL
)ENGINE=INNODB;

CREATE TABLE characters(
character_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY Key,
character_name VARCHAR(50) NOT NULL,
race_id TINYINT UNSIGNED NOT NULL,
INDEX `idx_race`(race_id),
CONSTRAINT `fk_character_race`
FOREIGN KEY (race_id)
REFERENCES races(race_id) ON UPDATE CASCADE ON DELETE RESTRICT
)ENGINE=INNODB;


En esta página del sitio puede ver el video en línea Learning MySQL - FOREIGN KEY CONSTRAINTS de Duración hora minuto segunda en buena calidad , que subió el usuario Steve Griffith - Prof3ssorSt3v3 02 junio 2019, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 44,679 veces y le gustó 697 a los espectadores. Disfruta viendo!