تقييمات الطلاب
( 5 من 5 )
١ تقييمات
فيديو شرح Learning MySQL - FOREIGN KEY CONSTRAINTS ضمن كورس MySQL SQL شرح قناة Steve Griffith - Prof3ssorSt3v3، الفديو رقم 26 مجانى معتمد اونلاين
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
)ENGINEINNODB;
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
)ENGINEINNODB;