And So I have this table

CREATE TABLE meta (
    id BIGINT(20) NOT NULL,
    type VARCHAR(6) NOT NULL,  
    name VARCHAR(64) NOT NULL,
    value LONGTEXT NOT NULL,
        PRIMARY KEY(id, type, name),

) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

the kind area are only able to have 3 possible values: "article", "user" or "page". And That I have 3 tables for every of individuals content types.

How do i give a constraint that informs mysql to get rid of the "meta" row when the type is "article" and id matches a article id make up the articles table? And 2 more contraints for that "user" and "page" types.

At this time I've:

CONSTRAINT article_meta FOREIGN KEY(id)
    REFERENCES articles(id) ON DELETE CASCADE ON UPDATE RESTRICT

however it does not think of the "type" area, therefore the row will get erased no matter the kind value...

I do not think you could do. Should you take a look at the syntax for a CREATE TABLE statement, foreign secrets need to have this type:

[CONSTRAINT [symbol]] FOREIGN KEY
      [index_name] (index_col_name,...)
    REFERENCES tbl_name (index_col_name,...)
      [MATCH FULL | MATCH PARTIAL | MATCH SIMPLE]
      [ON DELETE {RESTRICT | CASCADE | SET NULL | NO ACTION}]
      [ON UPDATE {RESTRICT | CASCADE | SET NULL | NO ACTION}]

Which means you can't (say) produce a foreign key on WHEN type = '...' THEN id ELSE NULL END (since the foreign key needs to be on the column-title, or multiple column-names, not arbitrary expressions), and also you can't (say) describe an overseas key as only using WHEN type = '...' (due to there being no syntax for your).

However I question &mdash are you certain it's wise to possess a single meta table with metadata its these different tables? When the tables have sufficient in keeping, semantically, that it seems sensible to allow them to share a meta, they also needs to most likely share some kind of parent table, entity, that's accountable for their overall IDs (by which situation you should use multi-column foreign secrets to make sure that types match and everything) but when, when i suspect, they do not have anything in keeping semantically, they should not possess a single shared meta table, but instead, there must be an article_meta table, a user_meta table, along with a page_meta table. No?