Switch to: V11V10V9V8V7V6V5

KeyValue for Link

Overview

KeyValue for Link is a special case of KeyValue With Key intended to be integrated with a Binary Link of Valentina Database.

We have the following inheritance:

Therefore you should read the description of parent classes also.

Up to now, there was a problem with Binary Link: how attach additional information to link? For example, in the relational model when MM-table is used, you can add more columns:

PersonPtr ProductPtr ItemsCount Date
1 45 8 2016-05-29
1 24 3 2016-07-16

As you know each Valentina Table have RecID field to identify a record, and a Binary Link saves pairs {RecID1, RecID2} to links records of two tables.

Observation: Such structure as “ULONG, ULONG, VARCHAR” allows to add any number of key-value pairs to any record of Binary Link!

KeyValue for Link is integrated to Link in the following way:

  • Link owns KeyValue for Link
    • If Link is deleted then KeyValue also will be deleted.
    • Link knows the count of such KeyValues.
    • Link is able to return you such KeyValue by its index or name.
  • If the record of Link is deleted, then related key-value pairs also are deleted.
  • When you insert key-value pair, then engine checks that link {RecID1, RecID2}, specified in the Key, does exist in the Table.

CREATE

To create KeyValue for Link you should use:

Notice, that you can create many KeyValues around single Link, if you want.

DROP

To drop KeyValue for Link you should use:

WRITE DATA

INSERT INTO BINARY LINK linkSales (1, 45);
KEYVALUE kv_LinkSales INSERT( '1.45.ItemsCount':8, '1.45.Date':'2016-05-29' );

The same in more short form (syntax sugar):

INSERT INTO BINARY LINK linkSales (1, 45);
KEYVALUE kv_LinkSales INSERT( 'ItemsCount':8, 'Date':'2016-05-29' ) FOR RECORD (1, 45);
Realize that Valentina DB can do this syntax sugar only because it is aware of this special kind of KeyValue, so it is able to provide special forms of SQL command.