mysql - Getting complicated about foreign key -


i beginner in innodb , not in database. m getting confused foreign keys. want know is:

  • if delete pk( fk on table)
    • is fk on child table deleted?
    • so how if delete fk on child table?
    • record in parent table deleted?
  • also, if add new record parent table
    • child table added?
    • how add child table?
    • how if update data?

please me, confused foreign key reference in innodb database . guide me easiest way. thanks.

what your'e asking cascading update/deletion child element.

the docs : http://dev.mysql.com/doc/refman/5.6/en/innodb-foreign-key-constraints.html

example :
constraint foreign key (jobabbr) referencesffxi_jobtype(jobabbr) on delete cascade on update cascade

the "on delete cascade" means when key deleted, fk's deleted aswell, useful data integrity. it's not automatic.

deleting foreign key not delete key it's based upon either way.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -