Developer Documentation Library > Data Model > Extending the UNICOM Intelligence Data Model > Creating a CDSC > Handling hierarchical data > VDATA and HDATA examples
 
VDATA and HDATA examples
This topic uses examples to illustrate the interaction between the (the Provider) and a CDSC when VDATA and HDATA are implemented. The examples are based on the example survey described in Handling hierarchical data, earlier in this section.
Implementing SELECT for VDATA
When the Provider retrieves the records for the Area, Age, and Transport columns from the example survey's VDATA table, the Provider first creates a new Command object by calling the Source object's CreateCommand property. The Provider indicates to the CDSC which columns to retrieve by creating three DataBinding objects (one for each of the Area, Age, and Transport columns) and adding them to the Command object. When the Provider calls the Command object's MoveFirst subroutine, the CDSC stores the values North, 30, and Car in the three DataBinding object's Value objects, ready for the Provider to retrieve. When the Provider calls MoveNext, the CDSC stores the values North, 30, and Bike in the Value objects.
The Provider calls MoveNext a further six times to update the value of the three DataBinding objects. The CDSC tells the Provider when to stop by setting the EOF property on its Command object to true. The Provider therefore obtains the following information:
Area
Age
Transport
North
30
Car
North
30
Bike
North
28
Bike
East
65
Car
East
65
Bike
East
65
Truck
South
25
Car
South
25
Car
Implementing ADD for VDATA
To illustrate how the Provider adds new data records, consider an extra person being included in the example survey. The inclusion of the new person in the VDATA table requires an additional row to be added to the table. Suppose an additional person moves into the flat in the North. The details for this person are:
ID
Area
HouseType
Gender
Age
Vote
Transport
UseItOften
1
North
Flat
Fem
27
Lib
Null
Null
The sequence when a new record is added is as follows:
The Provider creates the Command object.
The Provider adds bindings for the variables for which it wants to add data.
The Provider calls AddNew and the CDSC creates the new record.
The Provider sets the values in the Value objects.
The Provider calls Update and the CDSC writes the data from the Value objects.
To cancel the addition of the new record, the Provider would call Delete instead of Update, and no data should be written by the CDSC.
When writing data, the CDSC should store NULL (or the best default it can use) for any variables that weren't bound.
The data would then resemble the following table:
ID
Area
HouseType
Gender
Age
Vote
Transport
UseItOften
1
North
Flat
Male
30
Lib
Car
True
1
North
Flat
Male
30
Lib
Bike
False
1
North
Flat
Fem
28
Dem
Bike
True
2
East
Farm
Male
65
Con
Car
False
2
East
Farm
Male
65
Con
Bike
True
2
East
Farm
Male
65
Con
Truck
False
3
South
Villa
Male
25
Lib
Car
True
3
South
Villa
Male
25
Lib
Car
False
1
North
Flat
Fem
27
Lib
Null
Null
See also
Implementing UPDATE for VDATA
Implementing DELETE for VDATA
Implementing SELECT for HDATA
Implementing Add, Update, and Delete for HDATA
Handling hierarchical data