MySQL Forums
Forum List  »  Newbie

Re: would like to make primary key the product of two indices, 2 questions...
Posted by: Peter Brawley
Date: April 14, 2021 01:52PM

> make the primary key of a table based on the product of two indices.

Your discussion indicates you don't mean "product" in the usual math sense of that word.

Making the PK of one table dependent on values in other tables introduces vulnerabilities and maintenance issues that can be avoided by, for example, a surrogate (ie auto_increment) key, then enforcing your constraint as ordinary foreign keys.

Note also that a constraint on an item name also introduces vulnerabilities, since names in the real world often change. You're best off keying on a value that the real world will not ever change.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

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.