简体   繁体   中英

On foreign key delete destroy child rows?

I'm pretty new to using foreign keys, and can't really find anything on the MySQL website. Here is my database structure:

hosts
    id
    etc.
events
    id
    host_id
    etc.

One or multiple events belong to a host . When the host is deleted I need all events attached to it to be deleted. How can I achieve this?

Thanks!

use case cade on delete properly

You can check details here -

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM