Objects
At the core of Charta lies an object oriented model of data. Objects are entities that have a unique identifier and one or more data fields. Objects that share the same data fields belong to the same class. Data fields can have various types, including simple types like Integer, Character, Boolean and Real but also more complex types like Text or other objects. Objects can refer to other objects by defining a data field to hold the unique identifier of an object as an reference to that object.
For now objects are comparable to records as found in many programming languages, meaning that inheritance of data fields currently is not possible. Declaring a new class can be compared to declaring a new table in a relational database. An important difference with a relational database is that objects can refer to each other by using their unique identifiers whereas in a relational database a primary key has to be defined explicitly to use in a primary/foreign key combination.
Besides specifying the type of a data field one also should specify the collection that is to be used for that data field. Currently there are two such collections, namely Singleton and Array. A singleton is used to store just one value, an array is used to store a list of values of the same type. In the future much more collections like Set, LinkedList and BTree will be available.
Finally, one can specify whether an object for a data field should be created automatically by setting the auto-create option to true. In Charta values of data fields are represented by references to other objects. To be able to refer to another object that object should exist. Sometimes one just wants to refer to an already existing object. However, often one wants to create a specific new object for a data field. This can easily be done by specifying that such an object should be created automatically. No objects will be created for data fields that have a simple type like Integer and the auto-create option set to true. Instead, the values for these data fields are stored directly within the object that contains the data field.
Object stores
An object store is an abstract definition of a place where objects can be stored. Currently Charta provides two different types of object stores: internal memory and a file on disk. Objects created in internal memory will be lost whenever Charta is closed whereas objects that are created in a file on disk will be available again once Charta is executed again. Because the definition of an object store is abstract, objects can be stored and retrieved in exactly the same way for both internal memory and a file on disk. In the future also other object stores will be available, for instance, an object store that resides on another computer or an object store that fully manages a hard disk or USB stick by passing the file system of the operating system.
The unique identifier of an object is composed of two fields. The first identifies the object store where the object resides, the second identifies the object within that object store. As a result objects can refer to objects in other object stores. For instance, an object that lives in a file on one's hard disk can refer to an object that resides on a computer at the other side of the world.
