This topic is locked

Unable to use primary key as the detail field in master:detail

5/21/2008 11:42:39 AM
PHPRunner General questions
S
steveh author

Hi,
I need to provide a back to front master:detail relationship, but I am unable to select the ID of the detail record as the foreign key.
For now I'm going to just select another field then edit the generated code.
But would it be possible to have this restriction removed (I know that this can never be a true master detail as it will only ever provide a single record but it is extremely useful in this scenario).
Thanks

J
Jane 5/22/2008

Steve,
this restriction is applied to auto-increment field in the detail table.

Selection of autoincrement field is a consequence of bad design of database and these relationships won't work in 99% cases.

S
steveh author 5/22/2008

Maybe change to a warning then as in this case it's 100% correct to be an autoincrement.
E.g let's say we have an orders system, the order detail record will have a part number, the part number table has an autoincrement ID field which is correct. The order detail record has a partnumberID, I want to allow the drilldown to the part number (there will only be one) from the order detail.

J
Jane 5/22/2008

Steve,
auto-increment means that you can't change field value, this value is generated automatically in the database.

When you add new record to the detail table you need to save value from master table in the auto-increment field. It's not good.

You can do it only in MySQL database, but all other databases do not allow to change auto-increment field.
You can use your schema in your project but I'm not sure it's common issue.

This restrictions was added in order to avoid different errors with incorrect foreign keys.

Thank you for understanding.

S
steveh author 5/22/2008

Hi Jane,
I think you're missing the point, changing the value isn't going to happen, there is no requirement to edit, I just need to allow hover viewing and the view of the full record.
Look at the example and you'll understand.
Any chance you could remove this and replace with a "don't do this" in the documentation or a popup warning in the designer as the ability to do this will be required on quite a few projects I'm working on.

J
Jane 5/22/2008

Steve,
I see what you're saying.

Unfortunately we do not plan to change this restriction.