6.893 Architecture of Database Systems
Term Project
Ben Leong
benleong@mit.edu
The Problem - Abstract Data Type Exercise
Implement an abstract data type in POSTGRES that supports "Wall Street
Trading Date" (WSTD). This data type is represented externally as a
pair (year, integer); for example, (2002, 3) represents the third
trading day of 2002 (which I believe is Jan 4th). When, year is not
specified, the default is the current year, so 3 represents January 4,
2002. Choose some reasonable internal representation for the WSTD data
type and implement the following operations:
- Same_year (WSTD-1, WSTD-2) returns Boolean; this returns true if the
values are in the same year.
- Same_day_of_week (WSTD-1, WSTD-2) returns Boolean; this returns true if
the two values are the same day of the week.
- Distance (WSTD-1, WSTD-2) returns integer; this returns the number of
trading days between the two WSTDs.
- Mon (WSTD), Tues (WSTD), Wed (WTD), Thu (WSTD),
Fri (WSTD) returns Boolean; these have the obvious interpretation.
- DJIA (WSTD) returns float; returns the Dow Jones Industrial Average on
this date
- Date (WSTD) returns Date; returns the calendar date of the given WSTD.
- Greater_than (WSTD-1, WSTD-2) returns Boolean
- Less_than (WSTD-1, WSTD-2) returns Boolean
- Greater_Equal (WSTD-1, WSTD-2) returns Boolean
- Less_Equal (WSTD-1, WSTD-2) returns Boolean
- Equals (WSTD-1, WSTD-2) returns Boolean
In addition, POSTGRES should be taught how to construct B-tree indexes
on the WSTD type and the optimizer should be taught how to utilize the
resulting indexes.
My Solution
I have completed the above project using PostgreSQL 7.1.3 running on a RedHat
7.2 Linux system with kernel version 2.4.9-6. Please click
here to see my solution. Have a nice day!