Hi!

Im changing my database engine from MyISAM to InnoDB

its because I learned online that if I were to use FK's that its more likely that I have to use InnoDB

my question is:

if I have a one-to-many relationship tables:

ie. one PK in table 1 can have: many instances of records as FK in table 2 ref in table 1

which should have the cascade on update and delete?

table 1 or table 2

another thing

i know how to alter a table using a console

but do you happen to know if theres a tool in phpmyadmin on how to do it using a GUI?

Thanks!

Dani AI

Generated

A few practical clarifications that build on 's intent to move to InnoDB and on 's phpMyAdmin comment.

The cascade actions (ON DELETE / ON UPDATE) are part of the foreign-key definition on the referencing (child) table β€” they are not properties set on the referenced (parent) table. Typical choices are: ON DELETE CASCADE to remove dependent rows when the parent is removed, ON DELETE SET NULL to keep the dependent row but clear the link (requires nullable FK), and NO ACTION/RESTRICT to prevent deletion. ON UPDATE CASCADE only makes sense if the referenced key will actually change; it is rarely needed when using surrogate auto-increment keys. For full details on allowed actions and behavior see the MySQL InnoDB foreign-key documentation ().

Before converting: ensure referenced and referencing columns match exactly (type, length, unsigned, collation for text types), that the parent column is indexed, and that both tables use InnoDB when the FK is created. Back up large tables, test the conversion on a copy, and verify cascade behavior on test deletes/updates. phpMyAdmin can do engine changes and (when its relation feature is configured) help build FK constraints via the GUI; otherwise use ALTER TABLE to add constraints. See MySQL docs on creating foreign keys for precise syntax and rules (Creating foreign key constraints).

Recommended Answers

All 2 Replies

options are available in phpmyadmin for altering the table i.e. look for operations tab

on update, it depends which table information you are updating, while deleting, both table should have cascade

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.