Switch to: V9V8V7V6V5

Data Editor - Linking Records [ObjectPtr]

ONLY for Valentina Database.

Valentina Database except FK-links has ObjectPtr and BinaryLinks.

ObjectPtr-link is very similar to FK-link. It is also based on additional field in the table, the difference is only that ObjectPtr stores values of another special Valentina field “RecID”, while FK-field can be of any type.

RecID is a special field that exists in each Valentina Table and keeps system-assigned values. This differs it from a regular ID field, which keeps user-assigned values.

Exactly because of these system-values of RecID, we was need to invent a special way how to link records without typing values by user, because user simply should not care about system values. Valentina Studio introduces this new way with the help of Related Table Editor and mouse clicks.

Example

Let we have two tables. Table “tblPerson_ObjPtr” is linked to table “tblPhone_ObjPtr” as 1:M with the help of ObjectPtr-link “linkPhonePerson_ObjPtr”. This link is based on “tblPerson_ObjPtr.RecID” and “tblPhone_ObjPtr.fldPersonPtr” fields.

 ObjectPtr Linking 1

Note, that Valentina Studio shows you a lots of info and prompts about link and its character:

  • in the menu you can see the name of link and its cardinality.
  • “RecID” field in the top Table “tblPerson_ObjPtr” has icon of KEY.
  • “fldPersonPtr” filed in the bottom Table “tblPhone_ObjPtr” has icon of PTR.
  • both these columns are highlighted by yellow color.

Linking

You can link records in the related Table in two ways:

  • by mouse click.
  • by value edit.

By Mouse Click

To link records by mouse clicks:

  • Mark a record in the top Table.
  • Click in the first mark-column of the bottom Table on a record that should be linked.

 ObjectPtr Linking 2

In result, the ObjectPtr field “fldPersonPtr” was automatically assigned by the value of the RecID field of the marked record in the table “tblPerson_ObjPtr”.

In such way you can link any amount of records in the bottom table with records of the top table.

By Value Edit

You can set value of ObjectPtr field manually to link records in tables. For this double click its cell and type some RecID value.

Note, that if you enter not valid RecID value, then Valentina DB engine will return error.

Unlinking

You can unlink records in two ways:

  • by mouse click.
  • by value edit.

By Mouse Click

To unlinking record(s) by mouse click:

  • mark a parent-record in the top Table.
  • unmark the needed child-record (one click in the first column of the record) in the bottom Table.

You can see that the value of the ObjectPtr field becomes NULL.

By Value Edit

You can set the value of the ObjectPtr field manually to NULL value, what will means unlink it from the parent record.

To set value to NULL you can

  • click button NULL at bottom of Data Editor
  • choose command “Set NULL” in the main menu Record
  • use the keyboard shortcut CMD + L for mac or CTRL + L for other OS.