This topic is locked
[SOLVED]

 Master-Detail, One-to-One

6/13/2019 1:38:22 PM
PHPRunner General questions
rdsanford author

Hello,
It appears that PHPR supports one-to-one relationships at first glance. I have several tables that have one-to-one relationships. The relationships were defined outside of the PHPR datasource tables tool and were recognized during sync.
In list view, the referenced tables work as expected except that the "Add new" button continues to be displayed after the child record is added. I would think this button would be hidden until after the child record is deleted.
Attempted to create the relationship within PHPR and define it as one-to-one but wasn't able to do it, no option seen.
I suppose my only option is to write an event that checks for child records and then hides the add new button. Is this my solution or am I overlooking something? Would anyone have some code event to share if

this is the way to go?
PHPR is incredible. I'm learning, but still a lot to learn. I wish I had only found this sooner!
Thank you in advance!

admin 6/13/2019

The problem is that there is no such thing as one-to-one relationship. If you have a situation like this it means you have one table in fact that is, for some reason, were split into two physical tables.
If you cannot change your database structure you can sort of get away using master-details relationship and hiding Add button when child record was added already. But it will be much easier just to have a single table in this case.

rdsanford author 6/13/2019



The problem is that there is no such thing as one-to-one relationship. If you have a situation like this it means you have one table in fact that is, for some reason, were split into two physical tables.
If you cannot change your database structure you can sort of get away using master-details relationship and hiding Add button when child record was added already. But it will be much easier just to have a single table in this case.


The database was designed years ago. In this situation, the child tables included rarely used data fields and linked only if needed. However, I do have the opportunity to modify the structure and can move into a single table. In fact, I can move the rarely used fields into separate tabs when adding/editing. The tabs are then only visible to the user when the value of a "control" field equals certain data. So thanks for making me think out of the box!