helloI am creating a page to manage a sports competition. I need to create a match entity and have a match schedule entity that references it, etc.In the match entity, I set the match code as the primary key. The match code is 8 characters of text. On the registration page, I created a local variable to take in the 8 characters of text and assign it to the primary key when I hit the save button.When I edit the other attributes of the match entity on the edit page, I should be able to edit the match code as well, but with the logic I've created now, editing the match code adds a new ROW.Is it not possible to modify the match code that I set as the primary key, and if it is, will other tables that reference this entity automatically update their data with the changed match code?I am new to databases and new to outsystems.Please tell me how to do this.Thanks.
Hi Jiwon,
Ideally primary key should not change. In your case match code is primary key and as per requirement it is changeable also. But issue is it may have been referenced by some other tables as well.
So if you are in development phase, I would suggest remove match code from primary key. It will introduce little bit work for now but will save you from future trouble. Definitely you need to do some data migration or update foreign key references.
Or you can keep this match code as primary key as it and add new column for match column, which will be updatable by the user. So by this way you will have 2 columns. In this case also you need to copy data in new column, also it may lead some confusion to the user.
regards
Hi @JIWON KIM
It is not possible to edit primary key of the record because primary is identifier of record which identifies record based on that value. If you change primary key it will be considered as new record.
Alternative 1) Match code should not be a primary key if its changing when you update the record add another col as primary key.
Alternative 2) If still want to keep it as primary key then Whenever you are updating record delete previous record and you have to manually update referenceid with new match code in match schedule entity because it will not automatically update the foreign key.
Regards,
Pramod.