Is it possible to have a relation where the foreign key is also the primary key?
问题 I have a table in a SQL database which should have a relation with one of two tables, but not both. My manager solved it by using the ID field of the table Competitor as both primary key and as foreign key for the two other tables. None of the tables have autoincremental IDs. Problem is, when I try to add a new compeitor, it fails unless there is an entry in both of the other tables with the specified ID, which is the opposite of what I want. Here is an illustration to show you how it's done: