This topic is locked

Master Detail Orphans

11/6/2020 5:59:40 PM
PHPRunner General questions
P
PaulM author

When a master record is null, the 'Add' button is still highlighted and usable on the detail tables in a dashboard which allows users to create orphans. Can I stop records being added in the detail tables unless a master record exists?

Sergey Kornilov admin 11/10/2020

What does it mean "master record is null"?
Normally you need to make users added a record to the master record first and then add details (or add master and details at the same time). If your project configuration allows users to add details without creating a master record first - this is a serious issue and you need to fix this in your project.
As a workaround, you can set master record ID in the details table to be a required field to prevent this from happening. This is not a real solution but it may be enough in your case.

P
PaulM author 11/10/2020



What does it mean "master record is null"?
Normally you need to make users added a record to the master record first and then add details (or add master and details at the same time). If your project configuration allows users to add details without creating a master record first - this is a serious issue and you need to fix this in your project.
As a workaround, you can set master record ID in the details table to be a required field to prevent this from happening. This is not a real solution but it may be enough in your case.


Thanks, I did already set the master record ID to be a required field. My problem is that in a dashboard I have a master record and detail records. When a user is added they can go to the dashboard which doesn't have any data. At this point the master table and the detail tables all have the 'ADD' button available to be used. I would like to blank out the detail table 'ADD' button until the Master Record has been added so that no orphans are created. Alternatively the detail tables aren't available until the Master record has been added.

R
ruud 11/15/2020



Thanks, I did already set the master record ID to be a required field. My problem is that in a dashboard I have a master record and detail records. When a user is added they can go to the dashboard which doesn't have any data. At this point the master table and the detail tables all have the 'ADD' button available to be used. I would like to blank out the detail table 'ADD' button until the Master Record has been added so that no orphans are created. Alternatively the detail tables aren't available until the Master record has been added.

R
ruud 11/15/2020

Only add through the master table? See the example.

woodey2002 11/15/2020

also maybe look at your actual database design, ensure the masterkey field is set to "not null" via phpmyadmin.
https://www.w3schools.com/sql/sql_notnull.asp
Cheers,

J