MySQL Forums
Forum List  »  MySQL Workbench

Re: QUESTION ABOUT FOREIGN KEY
Posted by: Henrique Garcia
Date: April 28, 2026 11:20AM

Hi Herve, how are you?

You cannot create a foreign key that references only filtered rows (e.g., WHERE ParamTyp = 'Type1').

Foreign keys must reference a PRIMARY KEY or UNIQUE KEY column, and MySQL does not support conditional or partial foreign keys.

If this rule is required, enforce it at the application level, or normalize the model (e.g. split PARAMS into separate tables per type).


Best regards,
Henrique Garcia

Options: ReplyQuote


Subject
Views
Written By
Posted
101
April 28, 2026 02:52AM
Re: QUESTION ABOUT FOREIGN KEY
43
April 28, 2026 11:20AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.