openark.org - code.openark.org – Blog by Shlomi Noach

Example domain paragraphs

Blog by Shlomi Noach

Things that don’t work well with MySQL’s FOREIGN KEY implementation MySQL May 1, 2023 May 2, 2023 Foreign keys are an important database construct, that let you keep an aspect of data integrity within your relational model. Data integrity has many faces, most of which are application-specific. Foreign keys let you maintain an association integrity between rows in two tables, one being the parent , the other being the  child . I’ve personally mostly avoided using foreign keys in MySQL for many years in my pr

But, first, as in the past this caused some confusion: when I say I’m not using foreign keys, that does not mean I don’t JOIN tables. I still JOIN tables. I still have some id column in one table and some parent_id in another. I still use the benefit of the relational model. In a sense, I do use foreign keys. What I don’t normally is the foreign key CONSTRAINT , i.e. the declaration of a CONSTRAINT some_fk FOREIGN KEY ... in a table’s definition.

Links to openark.org (11)