Quote:
Originally Posted by misticism
R937: Do you mean make each of those items a primary key, or do you mean to some how link them so that they are as a group a single primary key? If the later, how do I do that?
|
yes, the latter
Code:
CREATE TABLE user_creature_link
( user_id INTEGER NOT NULL
, creature_id INTEGER NOT NULL
, PRIMARY KEY ( user_id , creature_id )
, FOREIGN KEY ( user_id ) REFERENCES users (id ) ON DELETE CASCADE
, FOREIGN KEY ( creature_id ) REFERENCES creatures (id ) ON DELETE CASCADE
);
Quote:
Originally Posted by misticism
... it seems like a very important part of MySQL
|
foreign keys are an essential part of all relational databases, not just mysql