Minirel Catalog & Utilities Report

Minirel Catalog & Utilities Report

Prepared by Peter Feakins (feakins@cs) and Bill Kimmel (Kimmel@cs) May 13 ,1995


This part of the Minirel project involved two aspects: 1) implementing a catalog to maintain information on relations, attributes and indexes; and, 2) implementing utility functions to load, insert, and delete records.

The catalog is implemented through four classes:
The Catalog class provides the external interface to catalog services. The RelCatalog, AttrCatalog and IndexCatalogs maintain descriptions of relations, attributes and indexes.
The Catalog class provides an external interface to the catalog for such functions as:

In addition, the Catalog class also wraps the above functions in transactions so that changes to the database are performed atomically. The Catalog class invokes functions from the RelCatalog, AttrCatalog and IndexCatalog classes to provide the actual services.

RelCatalog, AttrCatalog, and IndexCatalog are implemented as heapfiles, and are responsible for maintaining information on relations, attributes and indexes respectively. Functions which change the database are implemented as private members. Functions which return catalog information are implemented as public members. The designation of methods as public members is an accomodation for the utility functions which need access to catalog information.

Three utilities are provided:

The load utility inserts a designated file of records into the database. The utility inserts records into the specified relation and also inserts key,RID pairs into each index. The entire utility is wrapped in transaction so that all updates either commit or abort atomically.

The insert utility inserts a record into the database. The utility inserts the record in to the specified relation (heapfile) and also inserts key,RID pairs into each index. The entire utility is wrapped in a transaction so that all updates either commit or abort atomically.

The delete utility deletes a record(s) from the database. Currently the utility deletes records based on a single matching predicate (attribute = value). Any attribute may be used in the predicate. The utility deletes each record from the specified relation for which the predicate holds. Each index entry is deleted. The utility is wrapped in a transaction so that all deletions are performed atomically.


The Catalog class provides a public interface to catalog services. Each method of the Catalog is performed as an atomic transaction. The Catalog methods invoke methods from the RelCatalog, AttrCatalog and IndexCatalog to carry out the actual work.

  • Catalog Header File
    class Catalog   {
     friend RelCatalog;
     friend AttrCatalog;
     friend IndexCatalog;   
      // open relation catalog (creates or finds )
      Catalog(Status &status);
      // get rid of catalog (invokes destructors for each catalog)
      // get catalog entry for a relation
      Status getRelationInfo(char* relation, RelDesc& record);
      // create a new relation
      Status createRel(char* relation, int attrCnt, attrInfo attrList[]);
      // destroy a relation
      Status destroyRel(char* relation);
      // add a index to a relation
      Status addIndex(char* relation, char* attrname, IndexType accessType,
    			       int buckets);
      // drop an index from a relation
      Status dropIndex(char* relation, char* attrname, IndexType accessType);
      // get a catalog entry for an attribute
      Status getAttributeInfo(char *relation, char *attrName, AttrDesc &record);
      // get catalog entries for all attributes of a relation
      Status getRelAttributes(char *relation, int &attrCnt, AttrDesc *&attrs);
      // get catalog entries for all indexes for a relation
      Status getRelIndexes(char* relation, int &indexCnt, IndexDesc *&indexes);
      // get catalog entries for all indexes on an attribute 
      Status getAttrIndexes(char* relation, char *attrName, int &indexCnt,
    				IndexDesc *&indexes);
      // get catalog entry on an index
      Status getIndexInfo(char* relation, char* attrName, IndexType accessType,
    			     IndexDesc &record);
      // dump catalogs to a disk file for optimizer
      Status dumpCatalog();
      // Runs stats on the database.
      Status runStats(const char* filename);
      Status listRelations();

  • Catalog Class External Interfaces
  • Utility Header File
    // utility header file
      char * attrName;
      char * attrValue;
     } typedef attrNode;
     Status deleteRecordUT(char *relation, attrNode item);
     Status deleteRecUT(char *relation, attrNode item);
     Status deleteRecIndexesUT(char* relation, RID rid, Tuple* &tuple);
     Status insertRecordUT(char *relation, int attrCnt, attrNode attrList[]);
     Status insertRecUT(char *relation, int attrCnt, attrNode attrList[]);
     Status loadUT(char *relation, char *fileName);
     Status loadRecordsUT(char *relation, char *fileName);
     Status loadIndexesUT(Tuple *&tuple, const int attrCnt, const int indexCnt,
         const AttrDesc *&attrs, const IndexDesc *&indexes, void **&iFiles, const RID &rid );
  • Utility External Interfaces


    The methods of the RelCatalog, AttrCatalog and IndexCatalog classes are responsible for maintaining and retrieving catalog information. They are invoked by Catalog class methods and utility functions.

  • RelCatalog
  • AttrCatalog
  • IndexCatalog:
    Entries in these catalogs are not currently indexed. As a result, any catalog access involves a sequential scan of the underlying heapfile.

    Fields for relevant statistics are included in each record type. These values are currently set to default values. Functions to calculate these statistics do not currently exist.

    The index catalog currently only supports indexes on single attributes. A future enhancement would be to extend the catalog to support indexes on multiple attributes (ie GRID files etc).

    Index names are calculated rather than stored by IndexCatalog:buildIndexName.

    The function attrCatalog::getTupleStructure provides the attrType and string size arrays needed to support the Tuple class. This could be simplified if the Tuple class used a size array or all attributes rather than just strings. The function AttrCatalog::getRelInfo does return an array of attribute descriptions (AttrDesc) in positional order. This supports the getTupleStructure function.