| Home | Screenshots | Download | History | Documentation |
PortaBase files are Metakit database files. As such, they can be conveniently accessed and manipulated using the Metakit library via programs written in C++, Python, or Tcl. They can also be used by any program written to work with Metakit files in general, such as KitViewer. For low-level details of the format such as endianness, arrangement of bits in the file, header structure, etc. see the Metakit documentation and source code. What is described here is the set of "tables" that PortaBase creates and uses inside of these files, and a bit about how they interact to make certain PortaBase features possible. With this information, you can write a script or program to create, access, and/or update a PortaBase file; possible uses include:
The addition of support for command-line XML import and export in version 1.5 makes it even easier to programatically create and edit PortaBase files; see the XML format documentation for more information.
Data in Metakit files is organized by columns, where columns are defined independently of any "table". A Metakit "view" is similar to a table in the relational database sense in that it contains rows and columns. In order to prevent name clashes between columns used in different views, PortaBase uses the following naming conventions:
Strings are stored in Metakit files as null-terminated 1-byte character sequences. These character sequences in PortaBase files represent text which has been encoded in UTF-8 in order to support Unicode characters beyond those used by Western European languages.
Metakit format string: _global[_gversion:I,_gview:S,_gsort:S,_gfilter:S,_gcrypt:I]
This view contains exactly one row which contains information about the database file as a whole and the condition in which the user last left it. It uses the following columns:
Metakit format string: _columns[_cindex:I,_cname:S,_ctype:I,_cdefault:S,_cid:I]
This view defines the column structure of the _data view, described below, which contains the rows of data entered by the user. Each row of this view defines one column of the data table. It uses the following columns:
Metakit format string: Varies
This view is where the main database content is stored. The first column is named "_id" and contains the unique ID number of each row. The rows are consecutively numbered, starting at 0 and ending at one less than the number of rows. (When a row is deleted, the rows are renumbered accordingly.) The rest of the column structure of _data is determined by the data in the _columns view. Each column has an identifier which is derived from the column's ID number and data type. Decimal values and Calculation results are actually stored in two consecutive columns; one for a floating point representation (used for sorting, filtering, and statistics) and the other storing the string each value was originally entered as (for display). Similarly, enum values are stored both in a string column containing the option text and an integer column containing the option index. Images are stored in a bytes column, followed by a string column containing the name of the image format (either "JPEG" or "PNG").
For example, a _columns view that looks like this:
| _cindex | _cname | _ctype | _cdefault | _cid |
| 0 | Title | 0 | 0 | |
| 1 | Price | 2 | 39.95 | 1 |
| 2 | Pages | 1 | 400 | 2 |
| 3 | InStock | 3 | 1 | 4 |
| 4 | Cover | 9 | 5 |
would yield this Metakit format string for _data:
_data[_id:I,_S0:S,_F1:F,_S1:S,_I2:I,_I4:I,_B5:B,_S5:S]
Metakit format string: _views[_vname:S,_vrpp:I,_vdeskrpp:I,_vsort:S,_vfilter:S]
This view stores basic information about the PortaBase views (column subsets) defined for this database. It uses the following columns:
The rest of the information needed to define a PortaBase view is in the _viewcolumns view. Note: there is always a PortaBase view named "_all", which includes all the columns from _columns in the same order.
Metakit format string: _viewcolumns[_vcview:S,_vcindex:I,_vcname:S,_vcwidth:I,_vcdeskwidth:I]
This view contains information about each column included in a PortaBase view. It uses the following columns:
Metakit format string: _sorts[_sname:S]
This view gives basic information about the sortings defined for this database. It currently has only one column:
The rest of the information needed to define a sorting is in the _sortcolumns view. Note: if the data in this file has ever been sorted by clicking on a column label in the data viewer, there is a sorting named "_single" which has one entry in _viewcolumns for the clicked column.
Metakit format string: _sortcolumns[_scsort:S,_scindex:I,_scname:S,_scdesc:I]
This view contains information about each column included in a sorting. It uses the following columns:
Metakit format string: _filters[_fname:S]
This view gives basic information about the filters defined for this database. It currently has only one column:
The rest of the information needed to define a filter is in the _filterconditions view. Note: There is always a filter named "_allrows", which has no entries in _filterconditions. There is also sometimes a filter named "_simple", which defines the most recently performed "Quick" filter.
Metakit format string: _filterconditions[_fcfilter:S,_fcposition:I,_fccolumn:S,_fcoperator:I,_fcconstant:S,_fccase:I]
This view contains information about each condition included in a filter. It uses the following columns:
Metakit format string: _enums[_ename:S,_eid:I,_eindex:I]
This view gives basic information about each enum column type which has been defined in the file. It uses the following columns:
Metakit format string: _enumoptions[_eoenum:I,_eoindex:I,_eotext:S]
This view defines the options which are available for each enum column type defined in the file. It uses the following columns:
Metakit format string: _calcs[_calcid:I,_calcdecimals:I]
This view gives basic information about each calculation column which has been defined in the file. It uses the following columns:
Metakit format string: _calcnodes[_cnid:I,_cnnodeid:I,_cnparentid:I,_cntype:I,_cnvalue:S]
This view describes the nodes which define calculation columns. It uses the following columns:
Metakit format string: _crypto[_criv:B,_crhash:B,_crdata:B]
This view is only present in files containing encrypted data. In such files, the only views present are this and _global; the rest of the views are stored in an encrypted block of data in this view. This view uses the following columns:
The file format versions used by the PortaBase releases are as follows:
| PortaBase Version | _gversion |
| 1.0 | 1 |
| 1.1 | 2 |
| 1.2 | 3 |
| 1.3 | 4 |
| 1.4 | 5 |
| 1.4.1 | 6 |
| 1.5 | 7 |
| 1.6 | 8 |
| 1.7 | 9 |
| 1.8 | 10 |
| 1.9 | 11 |
The column data types are represented as follows:
| Code | Data Type | Metakit column type | Example values |
| 0 | String | string (S) | "answer to", "life", "universe and everything" |
| 1 | Integer | integer (I) | 6, 9, 42, -123 |
| 2 | Decimal | float (F) and string (S) | 123.45, -987.65 |
| 3 | Boolean | integer (I) | 0, 1 |
| 4 | Note | string (S) | This entire cell is one example value |
| 5 | Date | integer (I) | 20021113, 19990101 |
| 6 | Time | integer (I) | 0, 86399, 42000 |
| 7 | Calculation | float (F) and string (S) | 123.45, -987.65 |
| 8 | Sequence | integer (I) | 1, 2, 3, 4, 5 |
| 9 | Image | bytes (B) | , ![]() |
| 100, 101, 102... | Enum | string (S) and integer (I) | "Male", "Female", "Deposit", "Withdrawal" |
Note that a date value of 17520914 (the first day of the Gregorian calendar) is treated as a null date and is displayed in PortaBase as blank. A time value is the number of seconds past midnight, with a value of -1 representing a null time displayed as blank.
| Code | Operation |
| 0 | = |
| 1 | contains |
| 2 | starts with |
| 3 | < |
| 4 | > |
| 5 | <= |
| 6 | >= |
| 7 | != |
| Code | Node type |
| 0 | Numeric constant |
| 1 | Reference to a numeric column |
| 2 | Date constant (such as '2003-08-03') |
| 3 | Reference to a date column |
| 4 | Time constant (such as '11:43:27 AM') |
| 5 | Reference to a time column |
| 20 | Addition |
| 21 | Subtraction |
| 22 | Multiplication |
| 23 | Division |
| 24 | Difference between two dates, measured in days |
| 25 | Maximum |
| 26 | Minimum |
| 27 | Average |
| 28 | Absolute value |
| 29 | Square root |
| 30 | Base-10 logarithm |
| 31 | Natural logarithm |
| 32 | Difference between two times, measured in seconds |
| 33 | Difference between two times, measured in minutes |
| 34 | Difference between two times, measured in hours |
Version 11
Version 10
Version 9
Version 8
Version 7
Version 6
Version 5
Version 4
Version 3
Version 2
Version 1
Copyright 2002-2004 by Jeremy Bowman.
(jmbowman at alum dot mit dot edu)