What are MySQL foreign keys?

后端 未结 3 2023
时光取名叫无心
时光取名叫无心 2021-02-01 23:20

In an answer on Stack Overflow, I saw this code:

CREATE TABLE Favorites (
    user_id INT NOT NULL,
    movie_id INT NOT NULL,
    PRIMARY KEY (user_id, movie_id         


        
3条回答
  •  北荒
    北荒 (楼主)
    2021-02-02 00:02

    You can also add the ability to cascade when a related record is deleted. For example if I have a library table with many books in a related "book" table and I delete a given library from my library table its' dependent book records will also be deleted.

提交回复
热议问题