Using Caravan Database: Intro: Caravan database gives flexible, reliable and fast access to data. It can hold text,numeric,time and file types in its fields. All data is stored using a tree structure, for fast searching and update. Additionally, data in text fields are indexed using a seperate search engine. It is possible to create and export database information in XML format. Caravan language provides the objects and methods needed to search, insert and update this data. Special care has been taken to ensure the integrity of this database. Under normal circumstances the data will not get corrupted. But can happen due to power failures or system crashes. Using DBMS.HTML ================= Caravan gives a simple interface to manage the caravan database through the dbms.html interface. Access is restricted to admins. Open the link in a browser. The best way to understand and learn this is to use it. So here I will just give explanations for some of the stuff that you will come across when you go to dbms.html. Databases are really subdirectories within the database home directory. They are created with .db extention. Tables are files in the database sub-directory and have .data extensions. Large objects like files are stored in seperate subdiretories and have the fieldname as extention. So if you have a database named "people" and a table within it named "users" which have a field named "picture" in which you want to hold a image file, you will have these: 1. /people.db database directory 2. /people.db/users.data table file 3. /people.db/users.picture contains image files You will also see as many .xml files as there are tables in a database. These files contain the information about the table in XML format. The table files hold data in records. Each record is a multiple of 512 bytes long. You can add/delete/modify the fields in existing tables. Creating Tables: Fieldname: When you create a field you have to specify a fieldname which is text string like "name", "age", "telno" etc. Width : text length for text fields only, otherwise it is always one. Dimension : This indicates the number of such values in each record. Normally set this to 1. If it is more than one it becomes multi-dimensional. In multi-dimensional fields. only the first value is linked to the btree, so multi-diemnsional fields are not so useful, except for text where the search engine indexes all values. Field types: Here you have following choices -------------------------------------------- 1. String : text data , indexed by search engine also. 2. Numeric : integer data 3. Time : Time and date stored with a resolution of one second. 4. Image : Binary files not indexed by search engine. 5. Text : Text data indexed by search engine. 6. Relation ->: The value in this field is a pointer to a record in another table, all fields of which are also accessible from this table. Automatically added to this list as more tables are created.If this is a mandatory field, the record is also deleted when the related record is deleted. More about this later. Flags: Can be combined to give additional properties. L: This is a reserved flag for "Local" fields, these fields will not get replicated in a distributed/replicating setup. Leave it unchecked. M: Mandatory -- This fields cannot be blank, records cannot be added if this field is blank. Check this when the data is incomplete without this information. U: Unique ---- The values in this field are unique, no other record in this table can have same value for this field. Check this only if you expect unique values here. example telephone number, email address etc. B: Binary ------ The values in this field should not be indexed by search engine. Check this if you dont want the overhead of indexing this field through search engine. If there are only a few distinct values possible in this field it is best to check it. Default value: This value will be inserted into this field, when blank.Not applicable for Mandatory fields. When you click on a table name in a table list you are shown the current structure of the table with options to add/modify/delete fields. You will also see some additional fields which you did not create. These are system fields and not selectable for modify/add/delete operations. The backup button is used create a backup of this table. The backup will have "_" prepended to its name. You can also send this data to another caravan server if you specify the address. This is usefull especially for migrating the data in case future versions of caravan change the internal structure of the tables. You can also set the maxiumum number of records in any table. When the table grows to this size every new record added causes the oldest one to be deleted. Usefull in some applications where data comes fast and gets outdated fast, like news. If you dont want to set a limit, it is fine -- tables can grow to any size. You can view/modify/add/delete records from existing tables directly using the link provided. Each record has a record identifier called recordno, which is a permanent property of the record. Recordnos are never reused eventhough the space alloted is recycled when the record is deleted.