# Glom User Guide V0.2

for Glom v1.6
2004
Murray Cumming
2007
David Lodge (dave@cirt.net)
Glom Development Team

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation Licence (GFDL), Version 1.1 or any later version published by the Free Software Foundation with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. You can find a copy of the GFDL at this link or in the file COPYING-DOCS distributed with this manual.

This manual is part of a collection of GNOME manuals distributed under the GFDL. If you want to distribute this manual separately from the collection, you can do so by adding a copy of the licence to the manual, as described in section 6 of the licence.

Many of the names used by companies to distinguish their products and services are claimed as trademarks. Where those names appear in any GNOME documentation, and the members of the GNOME Documentation Project are made aware of those trademarks, then the names are in capital letters or initial capital letters.

DOCUMENT AND MODIFIED VERSIONS OF THE DOCUMENT ARE PROVIDED UNDER THE TERMS OF THE GNU FREE DOCUMENTATION LICENCE WITH THE FURTHER UNDERSTANDING THAT:

1. DOCUMENT IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE DOCUMENT OR MODIFIED VERSION OF THE DOCUMENT IS FREE OF DEFECTS MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY, ACCURACY AND PERFORMANCE OF THE DOCUMENT OR MODIFIED VERSION OF THE DOCUMENT IS WITH YOU. SHOULD ANY DOCUMENT OR MODIFIED VERSION PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL WRITER, AUTHOR OR ANY CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENCE. NO USE OF ANY DOCUMENT OR MODIFIED VERSION OF THE DOCUMENT IS AUTHORISED HEREUNDER EXCEPT UNDER THIS DISCLAIMER; AND

2. UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER IN TORT (INCLUDING NEGLIGENCE), CONTRACT OR OTHERWISE, SHALL THE AUTHOR, INITIAL WRITER, ANY CONTRIBUTOR OR ANY DISTRIBUTOR OF THE DOCUMENT OR MODIFIED VERSION OF THE DOCUMENT OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES OR LOSSES ARISING OUT OF OR RELATING TO USE OF THE DOCUMENT AND MODIFIED VERSIONS OF THE DOCUMENT, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES.

Murray
Cumming
Glom Development Team

     murrayc@murrayc.com

Glom 1.6
20 June 2004

Murray Cumming

Murray Cumming

This manual describes version 1.6 of Glom

## Feedback

To report a bug or make a suggestion regarding the Glom or this manual can be submitted to the GNOME Bugzilla , under the Glom product. Please search bugzilla before submitting your bug to ensure that yours hasn't already been reported.

User manual for Glom.

## Introduction

Glom allows you to design and use database systems.

## Getting Started

### Starting Glom

You can start Glom in the following ways:

Applications menu

  Choose Office Glom.

### When You Start Glom

When you start Glom, the following window is displayed.

#### Glom Start Up Window

Shows Glom main window.

## Using Glom as an Operator

To open an existing Glom document, either open that document from the File Manager, or choose Glom from the Applications menu, and then choose the document when asked. Glom will ask you for a user name and password to access the database. Your administrator will provide your user name and password.

When you open an existing document, Glom will be in `Operator` `user level`. This user level allows you to find and edit records, but does not allow you to change the fundamental structure of the database.

### Navigation

Each database has several tables. To look at a different table, choose `Tables` from the `Navigate` menu. Then double-click on the table, or select it and click the `Open` button.

#### Navigating to a Table

Navigating to a Table.

### Viewing and Entering Data

When in `Data Mode`, you can view or enter information in either the `List` or `Details` view.

#### The List View

The List view shows many records at once and usually shows only the most important fields.

When you enter data into a field it will be saved into the database immediately after you finish editing the field. If it is a date or time field then the data format will be checked for you.

To create a new record just click the `New` button, or start typing into a field in the last empty row. A new record row will be created with blank fields for you to fill in.

##### The List View

The List View.

To sort the records just click on a column header. For instance, you could might click on a date column to list invoices in order of their date, and click again to list them in reverse order.

#### The Details View

The details view shows only one record and usually shows all the fields arranged suitably.

When you enter data into a field it will be saved into the database immediately after you finish editing the field. If it is a date or time field then the data format will be checked for you.

To create a new record just click the `New` button. A new record will be created with blank fields for you to fill in.

##### The Details View

The Details View.

### Finding Data

Choose `Find Mode` from the Mode menu. The fields in the List and Details views will now be empty, and a Find button will appear at the bottom of the window.

Enter information, or part of the information, into a field to find records with that information in that field. For instance, enter Jim into a name field to find records with "Jim" or "Jimmy" in the name.

When you press the `Find` button, Glom will search for records and then display them. If only one record is found then it will show you that record in the Details view. If several records are found then it will show you those records in the List view.

### Printing Reports

If your database developer has defined some reports for a table then you will seem them listed in the `Reports` menu. Just choose the report from the menu to create the report. If you have previously performed a search then the report will contain only the currently-found data. Otherwise it will contain all data in the current report. Remember that each table has its own reports so you may need to switch to the relevant table to use a particular report.

#### A report

A report.

## Using Glom as a Developer

When you create a new document, Glom will be in the `Developer` `user level`. You can also change to the Developer user level after opening an existing document, with the `User Level` menu. Glom will only allow this if the administrator has allowed it.

### Adding Tables

You can see the list of existing tables by choosing `Tables` from the `Navigate` menu. You will also see this window after connecting to a database server, after creating a new document. To create a new table, click the `Add` button and enter the name for the new table. Glom will suggest a human-readable title for this table. `Operators` will see this title instead of the actual table name. You can also mark a tables as `hidden` from Operators. For instance, Operators should see "Invoice Lines" as related records from the "Invoices" table, but they should never be able to navigate directly to the "Invoice Lines" table.

You can also specify one table as the `default table`. This table will be shown whenever an operator opens an existing document, without asking him to select a table from the list.

You can also use this window to rename an existing table.

Click the `Open` button to look at the selected table.

### Editing Fields

Choose `Fields` from the `Developer` menu. This shows the list of fields in the table. New tables automatically have a primary key field, but you can change this field if necessary.

Click the `Add` button to add a new field, then enter the name of the new field. Glom will guess an appropriate human-readable title for this field, but you can edit this. `Operators` will see this title instead of the actual field name.

To specify more field details, select the field and click the `Details` button.

#### Editing Fields

Editing the table's fields.

#### Primary Keys

Each table must have one, and only one, `Primary Key`. The value in this field will be unique, meaning that each value in this field will appear in only one record in the table. For instance, each record in a "Customers" table would have a "Customer ID". This value will be used to refer to that customer from other tables, such as "Projects" and "Invoices" records. See the Creating Relationships section to see how you can relate tables together.

#### Field Types

Glom offers a few simple field types:

1. Number

2. Text

3. Date

4. Time

5. Boolean - either true or false

6. Image

#### Calculated Fields

Field values can be calculated in terms of other fields, using the Python programming language. This calculation should be the implementation of a python function, which should return a value. The return value will be used as the value of the field. This value will be recalculated every time one of the source fields changes. TODO: This only works for default values at the moment, and you can not use field values in the calculation yet.

You can also use calculations to specify a default value for fields, by selecting the `Default Value` tab in the `Field Details` window, clicking on the `Calculate Value` check box, and then entering a Python calculation. You can test this calculation in the `Edit` window.

### Arranging Layouts

Each table has `List` and `Details` views, and by default these show all fields in the table, in order of creation. You can edit the layout by choosing `Layout` from the `Developer` menu.

#### Arranging the List View

For the `List` view, you can specify the sequence of field columns, and whether some fields are hidden.

##### Editing the List Layout

Editing the list layout.

#### Arranging the Details View

For the `Details` view, you can create groups of fields, and give these groups titles. You can then place fields in these groups and specify the sequence fo fields in these groups. You can also specify the sequence of these groups. For instance, in a "Contacts" table, you might create a "Name" group, and place the "title", "first_name" and "last_name" fields in that group. You might have other groups for the "Address" fields.

##### Editing the details Layout

Editing the Details Layout.

### Creating Relationships

Tables in the Database are often related together. For instance, an "Invoices" table might have a "Customer ID" field. A value in this field would specify a record in the "Customers" table with the same value. Glom can show extra information, such as the customer name, from that related record. Or it can show a list of several related records - for instance, several related "Invoice Lines" that are related to a record in the "Invoice" record.

To create relationships, choose `Relationships` from the `Developer` menu. This will show the list of existing relationships. Click the `Add` button to create a new relationship, and enter a name for it. You should then choose a field in the current table, and a field in another table to which it should be related. This relationship will find any records in the other table for which the values in both fields are equal.

You can use the relationship in the following places.

1. To show a related field on the List or Details view.

2. To show a list of related records on the Details view.

3. To lookup a value from a field in a related record. For instance, to copy the current price of a "Product" into the "Price" field of an "Invoice Line" record.

4. To calculate a field value.

### Users Administration

To define the `Operators` who can use your database, and to specify what access they have to the various tables, choose `Users` from the `Developer` menu.

### Translations

Glom's user interface (and this document) is translated into several languages, as you should see already if you are using your computer with a non-English user interface. In addition, Glom automatically shows and understands numbers and dates according to the current user's local conventions. For instance, a user in the USA might enter a price as 1.99 and a date as 1/13/2008, but a German user of the same database will later see that as 1,99 and 13.1.2008.

However, the Glom system that you create also contains text that must be translated if it will be used by people who speak different languages. For instance, you must provide translations for the titles of your tables, fields, and reports. All of these text items can be seen in a list when you choose `Translations` from the `Developer` menu. In this window you can specify the language that you used for the original text, and enter translations for each text item for additional languages. When the Glom system is opened by a user of that language then these text items will be shown in the user interface.

#### Translations

Translations.

Experienced translators may be more familiar with the .po file format, or you might wish to use the many tools that work with the .po file format. By using the `Export` button you can create a .po file to use in a separate tool or to send to a translator. You can then import the resulting translation by using the `Import` button.

### Defining Reports

#### Adding or Editing Reports

Glom can produce reports to show specific fields for sets of records, sorted and grouped. For instance, a shop might need a report listing all products sold in one month, grouped by product type, and sorted by price inside each group. Each table has its own reports, which are available to the operator from the `Reports` menu.

To define a report, or to change the definition of an existing report, choose `Reports` from the `Developer` menu.

##### Creating or Editing Reports

Creating or editing reports.

Notice that each report has an ID as well as a human-readable name. This allows your report to have a translated title when used on a computer that uses a different language.

#### Editing a Report

A Glom report has three areas:

1. The Header, which appears at the start of the report

2. The Main area, in which the records and summary lines are shown, with the actual data from the database.

3. The Footer, which appears at the end of the report.

Inside an area, such as the Main part, you may add report `Parts`, such as fields, text, or images. These will usually appear in a row on the printed report, with one row for each record. In the simple case, this will look much like Glom's list view. You can add parts to your report by selecting them from the `Available Parts` list and then clicking the `Add` button. The part will then be added to the `Parts` list, in the selected area.

To specify details for the parts, such as the text or image to display, or to choose the field to display, select the part in the `Parts` list and click the `Edit` button. You may also specify field formatting by clicking the `Formatting` button, just as you would when defining a details or list layout.

##### Editing a Report

Editing a report.

Some parts may contain other parts and have extra properties to control how they present their child parts. For instance, the `Group By` part groups records together by a field. For instance, a products report might group a list of products by product type. You can even add a second sub-grouping inside the main `Group By` part, by selecting your top-level `Group By` part in the `Parts` list while adding a new `Group By` part from the `Available Parts` list. For instance, you might group your products by manufacturer, inside each product type group.

To specify the field by which the records should be grouped, select your `Group By` part in the `Parts` list and click the `Edit` button. You can then choose the field by which the records should be grouped, and select the fields by which these records should be sorted within the group. You may also specify some additional fields to be displayed in the group's title row. For instance, you might want to group products by a manufacturer ID, but also show the manufacturer name.

##### Editing a Group By Part

Editing a report.

The `Vertical Group` part may contain other items. For instance, it allows you to arrange fields below each other instead of just one after the other in the horizontal row. This is useful for grouping related fields such as address lines, or just to squeeze more information into the records's row on the report.

##### A Report with Vertical Groups

A Report with Vertical Groups.

When you have finished, click the `Close` button to save the report's definition. Your report can then be chosen from the `Reports` menu. See the Printing Reports section for more details.

## Dialogues

### Dialog: Initial dialog

This dialog allows the user to choose an existing document or create a new document. Existing documents may be selecting from the list of recently opened documents or by select a file with the file chooser dialog. Documents can also be opened via the network if other users are running Glom on the local network. Finally, a new document can be created either by opening a template file which already contains some initial tables and records, or by creating an empty document.

### Dialogue: New database

### Dialogue: Create database

### Dialogue: Connection

This dialogue requests a user name and password for connection to a database server. This is usually not the same username and password combination with which you log in to your system. All Glom systems require a database server on which the actual data will be stored. If the database server is not running on your local computer ("localhost"), then you must also provide its network hostname, such as "glomserver.openismus.com", though your hostname will be different.

Your system administrator can provide these database login details.

If you are the system administrator, see Glom's Postgres Configuration web page for help with installing and configuring a database server.

### Dialogue: Connection Error

This dialogue is shown when Glom could not connect to the specified database server. Either the database server is not running at the specified hostname, or the user name and password were not accepted by the database server. See the Connection Dialogue section for more details.

### Dialogue: Database preferences

### Dialogue: Change language

### Window: Textobject

### Window: Imageobject

### Dialogue: Notebook

### Dialogue: Data invalid format

### Dialogue: Relationship overview

### Window: Groups

### Dialogue: Group by sort fields

### Dialogue: Group by secondary fields

### Window: Button script

### Window: Field calculation

### Dialogue: New group

### Dialogue: Choose user

### Dialogue: User

### Dialogue: Translation identify original

### Dialogue: Translation copy

### Dialogue: Choose Date

### Dialog: Import Into Table

This dialog allows the user to import a CSV (comma separated value) file into the current database table. It shows the first few rows of the file to import and allows the user to select the target field in the database for each column in the CSV file. For auto-incremented primary keys, the primary key field cannot be used as a target field, but otherwise one column must be imported into the primary key field.

## About Glom

Glom is maintained by Glom and GNOME community volunteers. To find more information about Glom, please visit the Glom Web site.

To report a bug or make a suggestion regarding this application or this manual, you can submit them using bugzilla.

Another excellent source of information are the Glom mailing lists.

This program is distributed under the terms of the GNU General Public licence as published by the Free Software Foundation; either version 2 of the Licence, or (at your option) any later version. A copy of this licence can be found at this link, or in the file COPYING included with the source code of this program.

## Concepts

Glom is easy to use, but you must understand the following basic concepts.

1. `Database`: Each Glom document allows access to one database.

2. `Table`: Each database contains several tables, such as "Customers" and "Invoices" tables.

3. `Field`: Each table has several fields, such as "Customer ID", "First Name", and "Date of Birth" fields. In other documents and applications, fields are sometimes called "Columns"

4. `Records`: Each table contains several records, each of which has values for each of the fields. For instance, the "Customers" table will have a record for each customer. In other documents and applications, records are sometimes called `Rows`.

5. `Relationships`: Each table might be related to other tables, via fields in both tables. For instance, a "Customers" table could have a relationship to the "Invoices" table, so that people could see all the invoices for that customer. Only developers need to understand this concept. In other documents and applications, relationships are sometimes called "Joins".

## Calculated fields and button scripts

Calculated fields and button scripts use the Python programming language. The calculation or script is the implementation of a function whose signature is provided for you.

### Editing the definition of a calculated field

Editing the definition of a calculated field.

### Field values

For instance,

    record["name_first"]

is the value of the name_first field in the current record.

### Related Records

For instance,

    record.related["location"]

provides the related records for the current record.

#### Single related records

For relationships that specify a single record, you can get the value of a field in that record. For instance,

    record.related["location"]["name"]

is the value of the name field in the table indicated by the location relationship (often called location::name).

#### Multiple related records

For relationships that specify multiple records, you can use the aggregate functions (sum, count, average) to get overall values. For instance,

    record.related["invoice_lines"].sum("total_price")

.

### Testing for empty values

How you test for empty values depends on the type of field:

#### Non-text fields

Non-text fields may be empty, indicating that the user has not entered any value in the field. For instance, Glom does not assume that an empty value in a numeric field should mean 0.

You can test whether a field is empty by using Python's None. For instance:

      if(record["contact_id"] == None):
        return "No Contact"
      else:
        return record.related["contacts"]["name_full"]

You might also test whether there are any related records. For instance:

      if(record.related["contacts"] == None):
        return "No Contact"
      else:
        return record.related["contacts"]["name_full"]

#### Text fields

For text fields, you should check for zero-length strings. It is not possible in Glom to distinguish between zero-length strings and the absence of any string, because there is no advantage to doing so. For instance:

      if(record["name_full"] == ""):
        return "No Name"
      else:
        return record["name_full"]

### Using the full pygda API

pygda is a python API for the libgda API. The record's `connection` attribute provides a gda.connection that can be used to access the current database directly. This allows you to run any SQL query, for instance to read data from the database with a SELECT, or to change values in the database with an UPDATE. Note that the connection is already open so you can avoid the difficult work of specifying the connection details.

The record's `table_name` attribute also provides the name of the current table.

This example reads all data from the current table and prints the values to the terminal:

    # Use the current database's connection
    # to get all the data for the current table.
    #
    # record.connection is an already-open gda.connection object,
    # saving us the bother of opening the connection,
    # or even knowing the name of the database.

    query = "SELECT * FROM %s" % record.table_name
    data_model = gda.gda_execute_select_command(record.connection, query)

    rows = data_model.get_n_rows()
    columns = data_model.get_n_columns()
    print "    Number of columns: ", columns

    for i in range(columns):
        print "      column ", i;
        print "        name=", data_model.get_column_title(i)

        # Find out whether it's the primary key:
        field = data_model.describe_column(i)
        if field.get_primary_key():
            print "        (primary key)"

        print "\n";

    print "    Number of rows: ", rows

    for row_index in range(rows):
        print "      row ", row_index;

        for col_index in range(columns):
            print "        value=", data_model.get_value_at(col_index, row_index).get()

        print "\n";