CREATE TABLE jokecategory (
jokeid INT NOT NULL,
categoryid INT NOT NULL,
PRIMARY KEY (jokeid, categoryid)
) DEFAULT CHARACTER SET utf8;
especially PRIMARY KEY (jokeid, categoryid)? or is there a better way to write this?
Thank you in advance;-)
Yes it is a perfectly good table and primary key (I might call this an “association” table, but I would not call it a “lookup” table).
Some people (not I) would insist on having a surrogate key column jokecategoryid as the primary key; if you do that you still need a UNIQUE constraint on (jokeid, categoryid) to enforce the business rule.