Gittens Web site
 
Font size:      

Introducing Data Manipulation in the ObjectTalks Data Language

Introduction

This page is about the data manipulation part of the ObjectTalks data definition and manipulation language abbreviated as Ot. This language is intended to serve as part of the Data Transformation componenent in the so-called Semantic Infrastructure of the Business Integration solution and it is also plays a similar role in the discourse representation system that I am working on.

Hello World

The following fragment presents the traditional Hello world program in the Ot programming language.

		/* a first program */
		//
		//	hello world in Ot.
		//                                                   
		print "hello world\n";
		

The print statement is employed to write the string Hello World to the stdout stream. This first program also illustrates that similar, to Java and C/C++ line comments are denoted by a pair of forward-slash characters while block comments are enclosed within the /* and */ character pairs.

The foreach tuple statement

The Ot data language is much influenced by relational theory and predicate logic. Consequenlty relational extensions, which in the absence of nulls can be viewed as relational tables are supported natively. In addition a foreach statement which was inspired by the universion quantifier found in predicate logic is also part of the Ot language.

		foreach tuple in party
		{
			print party.name "\n";
		}
		

The example above prints the name of all party tuples which are member of the relational extension party.

Being a relational language, ObjectTalks supports cartesian products of extensions as shown in the following example.

		foreach tuple in party, partyType
		where party.type = partyType.name
		{
		   print party.name ", " partyType.name "\n";
		}                       
		

This example prints the name and type of parties found in the data scope accessed by our example program by computing the cartesian product of the party and partyType extensions and using a where clause to filter the number of tuples printed.

Assuming that a foreign key relation exists between the party and partyType instances, the following example also prints the name and type of all party in our example data scope. However in this case, the so-called tuple selection syntax is employed for efficiency and clarity of intent.

		foreach tuple in party, partyType[party.type]
		{
		   print party.name ", " partyType.name "\n";
		}
		

The syntax partyType[party] selects the tuple in the partyType extension which is identified by each tuple in the party extension.

The following example exploits the expressiveness of the relational model even more by explicitely employing a foreign key relation to display the same information presented in the previous example.

		foreach tuple in party
		{
		   print party.name ", " party.typeref.name "\n";
		}
		

In this case it is understood that the name of the foreign key relation between party and partyType in this example would be typeref. Using this relation, this example illustrates how the relation data structure in our example can be traversed in a highly intuitive manner.

The exists tuple statement

Similar to the foreach statement the Ot language also support an exists statement. This statement employs the tuple selection syntax as in the following.

		exists tuple in person["maurice"]
		{
		  print person.name ", " person.age "\n";
		}
		else
		{
		  print "no person called maurice found in the current data scope\n";
		}
		

Working with Orthogonals

@still needs to be written...@@