Introduction to Redbase-spatial

                    +----------------------------------------+
                    |            Query Language              | 
                    +----------------------------------------+
                    |           System Management            |
                    +-------------------+--------------------+
                    |     Indexes       |  Record Management |
                    +-------------------+--------------------+
                    |              Paged File                |
                    +----------------------------------------+

Redbase is a stripped down relational DBMS, that implements the Stanford Redbase interfaces. It is assumed that the queries are input directly to the database command line and no separate clients are available. The system is organized into five major components:

  • Paged File - The PF component provides facilities for higher-level client components to perform file I/O in terms of pages. In the PF component, methods are provided to create, destroy, open, and close paged files, to scan through the pages of a given file, to read a specific page of a given file, to add and delete pages of a given file, and to obtain and release pages for scratch use. It also implements the buffer pool for use by the other components. The interface for this layer is composed of 3 classes: PF_Manager, PF_FileHandle and PF_PageHandle.

    • The PF_Manager class provides the functions for creating, deleting, opening and closing paged files

      class PF_Manager
      {
      public:
      PF_Manager    ();                           // Constructor
      ~PF_Manager   ();                           // Destructor
      RC CreateFile    (const char *fileName);       // Create a new file
      RC DestroyFile   (const char *fileName);       // Destroy a file
      RC OpenFile      (const char *fileName, PF_FileHandle &fileHandle);  
                                                  // Open a file
      RC CloseFile     (PF_FileHandle &fileHandle);  // Close a file
      RC AllocateBlock (char *&buffer);              // Allocate a new scratch page in buffer
      RC DisposeBlock  (char *buffer);               // Dispose of a scratch page
      };
      
    • The PF_FileHandler contains functions that are used to access pages of an open file

      class PF_FileHandle {
      public:
      PF_FileHandle  ();                                  // Default constructor
      ~PF_FileHandle ();                                  // Destructor
      PF_FileHandle  (const PF_FileHandle &fileHandle);   // Copy constructor
      PF_FileHandle& operator= (const PF_FileHandle &fileHandle);
                                                          // Overload =
      RC GetFirstPage   (PF_PageHandle &pageHandle) const;   // Get the first page
      RC GetLastPage    (PF_PageHandle &pageHandle) const;   // Get the last page
      
      RC GetNextPage    (PageNum current, PF_PageHandle &pageHandle) const; 
                                                          // Get the next page
      RC GetPrevPage    (PageNum current, PF_PageHandle &pageHandle) const;
                                                          // Get the previous page
      RC GetThisPage    (PageNum pageNum, PF_PageHandle &pageHandle) const;  
                                                          // Get a specific page
      RC AllocatePage   (PF_PageHandle &pageHandle);         // Allocate a new page
      RC DisposePage    (PageNum pageNum);                   // Dispose of a page 
      RC MarkDirty      (PageNum pageNum) const;             // Mark a page as dirty
      RC UnpinPage      (PageNum pageNum) const;             // Unpin a page
      RC ForcePages     (PageNum pageNum = ALL_PAGES) const; // Write dirty page(s)
                                                          //   to disk
      };
      
    • The PF_PageHandler class contains functions that access the contents of a single page stored in the file.

      class PF_PageHandle {
      public:
      PF_PageHandle  ();                          // Default constructor
      ~PF_PageHandle ();                          // Destructor
      PF_PageHandle  (const PF_PageHandle &pageHandle); 
                                                  // Copy constructor
      PF_PageHandle& operator= (const PF_PageHandle &pageHandle);
                                                  // Overload =
      RC GetData        (char *&pData) const;        // Set pData to point to
                                                  //   the page contents
      RC GetPageNum     (PageNum &pageNum) const;    // Return the page number
      };
      
  • Record Management – The RM component is built on top of the PF Layer and provides classes and methods for managing files of unordered records. The interface of this layer is similar to the PF Layer, and contains RM_Manager, RM_FileHandle, RM_Record classes. In addition, the RM component also provides an RM_FileScan class, that allows the above layers to scan over the RM_Record objects stored in the file.

  • Indexing - The IX component provides classes and methods for managing persistent indexes over unordered data records stored in paged files. The indexes ultimately will be used to speed up processing of relational selections, joins, and condition-based update and delete operations. Like the data records themselves, the indexes are stored in paged files. The API for this component is specified here. We shall be implementing this layer.

  • System Management - The SM compoment provides the following functions:

    • Unix command line utilities - for creating and destroying RedBase databases, invoking the system.
    • Data definition language (DDL) commands - for creating and dropping relations, creating and dropping indexes.
    • System utilities - for bulk loading, help, printing relations and setting parameters.
    • Metadata management - for maintaining system catalogs containing table names and schema.
  • Query Language - The QL component implements the language RQL (for “RedBase Query Language”). RQL’s data retrieval command is a restricted version of the SQL Select statement. RQL’s data modification commands are restricted versions of SQL’s Insert, Delete, and Update statements. The QL component uses classes and methods from the IX, RM, and SM components.

The complete Redbase specification can be found here