Switch to: V12V11V10V9V8V7V6V5

VDatabase Class: Structure Methods

CREATE Methods

Declaration:

CreateBinaryLink( 
	inName as String,
	inLeftTable as VTable, 
	inRightTable as VTable,
	inLeftPower as EVLinkType = kOne,	
	inRightPower as EVLinkType = kMany,
	inOnDelete as EVOnDelete = kSetNull,
	inStorageType as EVStorageType = kDefault
	inTemporary as Boolean = false ) as VBinaryLink

Parameters:

  • inName - The name of the link.
  • inLeftTable - Pointer to the Left Table.
  • inRightTable - Pointer to the Right Table.
  • inLeftPower - Link type for the Left Table.
  • inRightPower - Link type for the Right Table.
  • inOnDelete - The behavior on deletion of record-owner.
  • inStorageType - Storage type of the link.
  • inTemporary - TRUE if the link is tempоrary.

Description:

Creates a new Binary Link between 2 tables of this database.

To specify a link you should define the following:

  • A name for the link, unique in the scope of the database.
  • Pointers to 2 tables. One table is named Left, the other are named Right.
  • The type of link, i.e. if it is 1 : 1 or 1 : M or M : M.
  • The behavior of the link on deletion of a record in the Table-Owner.
    1. In the case of a 1 : M link, the ONE table is the owner table
    2. In the other cases (1:1 and M:M) the developer can assign whqich table has to be the owner.
  • The storage type for the link. It can be Disk-based or RAM-based.

A BinaryLink creates files on the disk to keep information about linked records. This is why we should specify StorageType.

You can specify the same table in the parameters inLeftTable and inRightTable. In this case you get a recursive link (or self-pointer).

Example:

linkPersonPhone = db.CreateBinaryLink( 
                        "PersonPhone", 
                         tblPerson, tblPhone, 
                         EVLinkType.kMany, EVLinkType.kMany )

Declaration:

CreateForeignKeyLink( 
	inName as String,
	inKeyField as VField, 
	inPtrField as VField,
	inOnDelete as EVOnDelete = kSetNull,
	inOnUpdate as EVOnUpdate = kCascade,
	inTemporary as Boolean = false ) as VLink

Parameters:

  • inName - The name of link.
  • inKeyField - The PRIMARY KEY field of ONE Table.
  • inPtrField - The PTR field in the MANY Table.
  • inOnDelete - The behavior on deletion of record-owner.
  • inOnUpdate - The behavior on update of record-owner.
  • inTemporary - TRUE if link is temprary.

Description:

Creates a Link between 2 tables of this database using the FOREIGN KEY abstraction of the relational model. This link does not create any new structures on the disk. It just establishes logical links between the records using their values in the KEY and PTR fields. This function is 100% the analog of the FOREIGN KEY constraint in SQL of a RDBMS. Valentina allows the way to establish a relational link without the use of SQL.

To specify a foreign key link you should define the following:

  • A name for the link, unique in the scope of the database.
  • The KEY field of the Parent table (ONE table).
  • The PTR field of the Child table (MANY table).
  • The behavior of the link on deletion of a record in the Parent Table.
  • The behavior of the link on the update of a KEY field value in the Parent Table.

Example:

linkPersonPhone = db.CreateForeignKeyLink( 
                      "PersonPhone", tblPerson.fldID, tblPhone.PersonPtr )

VDatabase.CreateTable()

Declaration:

CreateTable( 
	inName as String,
	inTableKind as EVTableKind = kTblPermanent,
	inStorageType as EVStorageType = kDefault ) as VTable

Parameters:

  • inName - The Name of a new Table.
  • inTableKind - The kind of a Table.
  • inStorageType - Storage type for this database.

Description:

Creates a new empty Table in the database.

The parameter inTableKind allows you to choose between permanent and temporary tables.

The parameter inStorageType allows creating Tables in RAM.

Note: This only applies to a DISK-based database. It is obvious that for a RAM-based database you won`t be able to create a disk-based table.

Note: You should add columns to a new table using the VTable.CreateField() method.

Example:

dim tbl as VTable
 
tbl = db.CreateTable( "Person" )

VDatabase.CreateKeyValue()

Declaration:

CreateKeyValue( 
	inName as String,
        inOptions as Int64 ) as VKeyValue

Parameters:

  • inName - The Name of a new KeyValue.
  • inOptions - Bitset of options.

Description:

Creates a new empty Default KeyValue store in the database.

You can specify options:

  • kTemporary
  • kCompressed

Temporary KeyValue keeps files on .tmp volume of Valentina database. Information about such temporary database object is not saved into system tables.

Compressed KeyValue does compression of Big Values. These are values that go into internal segment file (like BLOB). Picture values are not compressed.

Example:

dim kv as VKeyValue
 
kv = db.CreateKeyValue( "KV1" )

VDatabase.CreateKeyValueWithKey()

Declaration:

CreateKeyValueWithKey( 
	inName as String,
        inKeyStructure as String,
        inOptions as Int64 ) as VKeyValue

Parameters:

  • inName - The Name of a new KeyValue.
  • inKeyStructure - The Key Structure.
  • inOptions - Bitset of options.

Description:

Creates a new empty KeyValue WITH KEY in the database.

This is a more complicated KeyValue, which Valentina Database offers to you. You should describe Key Structure, providing a list of TYPES. Having this key structure, Valentina Database can create internal comparator to sort values.

You can specify options:

kTemporary kCompressed Temporary KeyValue keeps files on .tmp volume of Valentina database. Information about such temporary database object is not saved into system tables.

Compressed KeyValue does compression of Big Values. These are values that go into internal segment file (like BLOB). Picture values are not compressed.

Example:

dim kv as VKeyValue
 
kv = db.CreateKeyValueWithKey( "KV1", "ULONG, ULONG, VARBINARY" )

DROP Methods

DropLink( inLink as VLink )

Parameters:

  • inLink - The reference Link to delete.

Description:

Removes the specified Link from the database. This operation is undoable.

Example:

db.DropLink( lnk )

VDatabase.DropTable()

Declaration:

DropTable( inTable as VTable )

Parameters:

  • inTable - The reference of Table to delete.

Description:

Removes the specified Table from the database. This operation is undoable.

Example:

db.DropTable( tbl )

VDatabase.DropKeyValue()

Declaration:

DropKeyValue( inKeyValue as VKeyValue )

Parameters:

  • inKeyValue - The reference of KeyValue to delete.

Description:

Removes the specified KeyValue from the database. This operation is undoable.

Example:

db.DropKeyValue( kv )