KEY ATTRIBUTES A "key attribute" (or simply a "key") in xpg is an attribute which was selected by the user, either by double-clicking the attribute name (which appears above the attribute's column in the table), by defining the attribute as a key attribute in the resources file (see the XPG RESOURCES section below), or by using the "-keys" command-line switch (see the COMMAND-LINE SWITCHES section below). xpg uses key attributes for 3 purposes: - performing specific operations on a set of attributes, such as printing and math calculations. (The set of attributes is the set of key attributes). - displaying a set of attributes in a scrollable area of the viewer (this area scrolls only vertically). This feature is useful if the viewer is too narrow to show all the relation attributes at the same time, requiring the horizontal scrollbar to view different portions of the data. Key attributes are placed in a vertically scrollable area, to the left of the relation data. This set of attributes is always visible on the screen, regardless of the position of the horizontal scrollbar. A key attribute is not removed from the relation data display when it is selected to be a key attribute, making it appear twice on the screen. While this has the disadvantage of some redundant data on the screen, it has the more important advantage of keeping the integrity of the relation. - sorting the relation by selected attributes: When a new attribute is selected to be a key attribute, it is displayed to the right of the previously selected key attributes. When sorting is performed, the leftmost (ie. the first selected) key attribute is taken to be the primary sort key; the key attribute immediately following it is taken to be the secondary sort key, and so on. The sort operator used is always the default sort operator for the attribute type, as defined by Postgres. There are 3 cases when sorting is done: - The Sort item from the Data menu is selected; - The "autoSort" resource is true for a retrieved relation (see the XPG RESOURCES section); - The "-autoSort" command-line switch is specified (see the COMMAND-LINE SWITCHES section). In the last two cases, sorting is automatically performed whenever a key attribute is added or removed, and when the class is retrieved, either because of user request (viewing a new relation, manual retrieval request), or after a class operation (append, replace, delete). Obviously, sorting is done only if there are key attributes. Sorting is implemented using the "sort" keyword in the retrieve command. You should consider this when sorting large relations, because you may encounter long delays after each of the operations which cause automatic sorting. If you encounter this problem, you can set the "autoSort" resource to false for such relations, avoid using the "-autoSort" command-line switch, or use the "-noAutoSort" command-line switch to explicitly turn off automatic sorting for large relations. * Key attributes are deselected by double-clicking on the attribute name, either in the relation data area or in the key attributes area. * Synchronization: The key area is synchronized with the data area both in vertical scrolling (recall that it cannot scroll horizontally) and in tuple selection: You can select tuples in either area, and the other area is automatically updated.