TIP: HOW TO fill FK value by a Parent PK value?
- Let you have tables A and B, related as 1 to Many.
- Let table A (parent table) have PK field(s), e.g. “ID”.
- Let table B (child table) have FK field(s), e.g. “T1_ID”.
Many DB GUI Tools when you make new record into table B, show you a “LookUp” dialog, which lists all distinct values of PK from table A. You can locate some ID in this list.
Problems with this approach are:
- This is the additional query of kind “SELECT PKfld FROM A”.
- This can be very big list actually, equal to the number of records in table A (so even million records).
- If PK is a synthetic key (e.g. 1,2,3,…) this not helps at all, and they show 1 or 2 other fields, which should help you identify correct record.
Valentina Studio provides another way with the help of Related Data Editor.
- In the top Data Editor you keep table A, in the bottom Data Editor you keep table B.
- You can locate a parent record in the table A quite easy using e.g. Filter of Data Editor. And you see all fields of Table A so easy can identify correct one.
- In the bottom data editor click “New Record” button, and this immediately creates a new record in the bottom Data Editor with FK field, automatically filled by PK value(s).