- This topic has 3 replies, 2 voices, and was last updated 12 years, 1 month ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.
Integrated Application Platform
Integrated Application Platform › Forums › General › Composite keys
I have tabel with a key combined out of 2 columns, in this case ‘id’ and ‘changedDate’. In another table I need to create a foreign key reference, but I want it to only refer to the ‘id’ of the master table. Is that possible? At first it didn’t work, so I added a seperate key, only using ‘id’. In that case I can use it as a foreign key reference, but only in some cases. Some other references to it still report an error. Are there any known issues regarding this type of use?
Unfortunately, you cannot make a foreign key to only part of another key, although technically this would be possible
Can you give me details on when the foreign key is not working? What kind of error are you getting?
I’m sorry, I made a mistake. I was working client-server, and when changing code, sometimes the server needs to be restarted to make the changes active (I assume that the code was server sided). After restarting it worked fine. The situation is now:
table1:
key(id, changedDate)
key(id)
table2:
index(pid) in table1(id)
The index of table2 refers to the id of table1. This works fine, but only after adding key(id) on table1. I also do not understand why that works, but it does.
Glad you got it working.