time-based operators for relational algebra query languages

16
Comput. Lang. Vol. 19, No. 4, pp. 261-276, 1993 0096-0551/93 $6.00+ 0.00 Printed in Great Britain. All rights reserved Copyright © 1993 Pergamon Press Ltd TIME-BASED OPERATORS FOR RELATIONAL ALGEBRA QUERY LANGUAGES M. A. BASSIOUNI, M. J. LLEWELLYN and A. MUKHERJEE Department of Computer Science, Universityof Central Florida, Orlando, FL 32816, U.S.A. (Received 28 October 1992; revision received 30 August 1993) Abstract--We present a new approach for historical relational algebra languages based upon generalized logic for Boolean and comparison operators and a temporal modification of the standard relational algebra operators. Historical versions of standard (snapshot) relational algebra operators based upon this generalized logic are presented. The temporal modification employs a logic that operates on sets of value/time-interval pairs and which can be applied to snapshot as well as historical databases. Our emphasis is that the generalized operators can be used to enrich existing historical query languages and to provide an easier and more natural time-based interface. Using the generalized operators, users can express their queries more naturally, succinctly and elegantly. Examples are presented which illustrate that the modified operators offer a good degree of flexibility in expressing different temporal requirements. historical databases query languages snapshot databases relational algebra relational calculus boolean operators 1. INTRODUCTION Temporal/historical databases [1-18] are designed to capture not only the present state of the modeled real world, but also its previous history. This is done through a non-deletion policy; once a tuple is entered into the system, it can never be deleted (except to correct for input errors, in an historical database). In Ref. [5], Tansel presents an extended relational algebra that includes the standard relational algebra operators in addition to five extra operators to handle temporal requirements. In Ref. [4], we presented a temporal relational query language based upon the tuple calculus which generally resembled the languages QUEL and GEM [19]. Algorithms for the management of historical views were presented in Ref. [8]. In this paper, we present a new approach for historical relational algebra obtained through modification of the standard relational algebra operators. Several historical/temporal query languages have been proposed [1, 2, 5, 7, 12, 13, 16, 18]. In this paper, we have embedded the temporal domain in the existing well-known algebraic operators by extending the Boolean and comparison operators into the time domain. This approach can be used to enhance existing or new historical/temporal algebras (e.g. Tansel's algebra). Section 5 provides several examples to illustrate how historical queries are expressed using the modified operators. For the purpose of this paper, we shall consider an historical relational database in which each relation is viewed as a collection of related attributes some of which are invariant with time while others vary with time. For those attributes whose value varies with time, the temporal component maintained in an historical database represents valid time i.e. the time during which the recorded value was/is valid. In the following discussion, we shall assume that time (valid time) is represented by (encoded as) integer values and that the symbol NOW represents the current value of time. We adopt the notion of time-independent key (TIK) as introduced in [12], i.e. every relation has a key that consists of a collection of attributes (one or more) which are invariant with time. Time-varying attributes are double time-stamped as done in Refs [3-5, 7, 17, 18]. This means that every time-varying attribute in a tuple is a set of triplets of the form (value,(start,end)). The time interval components consists of a double time-stamp, i.e. a time-stamp with two time values corresponding to the lower and upper bounds of the time interval. Thus the triple (a, (2,4)) indicates that the value of "a" has been continuously valid from time 2 to time 4 inclusive (i.e. both the time points 2 and 4 are included in the interval). Thus all time intervals arc considered !~ h," .-1,~. ! ,~n h~th 261

Upload: ma-bassiouni

Post on 25-Aug-2016

217 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Time-based operators for relational algebra query languages

Comput. Lang. Vol. 19, No. 4, pp. 261-276, 1993 0096-0551/93 $6.00 + 0.00 Printed in Great Britain. All rights reserved Copyright © 1993 Pergamon Press Ltd

T I M E - B A S E D O P E R A T O R S F O R R E L A T I O N A L

A L G E B R A Q U E R Y L A N G U A G E S

M. A. BASSIOUNI, M. J. LLEWELLYN and A. MUKHERJEE Department of Computer Science, University of Central Florida, Orlando, FL 32816, U.S.A.

(Received 28 October 1992; revision received 30 August 1993)

Abstract--We present a new approach for historical relational algebra languages based upon generalized logic for Boolean and comparison operators and a temporal modification of the standard relational algebra operators. Historical versions of standard (snapshot) relational algebra operators based upon this generalized logic are presented. The temporal modification employs a logic that operates on sets of value/time-interval pairs and which can be applied to snapshot as well as historical databases. Our emphasis is that the generalized operators can be used to enrich existing historical query languages and to provide an easier and more natural time-based interface. Using the generalized operators, users can express their queries more naturally, succinctly and elegantly. Examples are presented which illustrate that the modified operators offer a good degree of flexibility in expressing different temporal requirements.

historical databases query languages snapshot databases relational algebra relational calculus boolean operators

1. INTRODUCTION

Temporal/historical databases [1-18] are designed to capture not only the present state of the modeled real world, but also its previous history. This is done through a non-deletion policy; once a tuple is entered into the system, it can never be deleted (except to correct for input errors, in an historical database). In Ref. [5], Tansel presents an extended relational algebra that includes the standard relational algebra operators in addition to five extra operators to handle temporal requirements. In Ref. [4], we presented a temporal relational query language based upon the tuple calculus which generally resembled the languages QUEL and GEM [19]. Algorithms for the management of historical views were presented in Ref. [8]. In this paper, we present a new approach for historical relational algebra obtained through modification of the standard relational algebra operators.

Several historical/temporal query languages have been proposed [1, 2, 5, 7, 12, 13, 16, 18]. In this paper, we have embedded the temporal domain in the existing well-known algebraic operators by extending the Boolean and comparison operators into the time domain. This approach can be used to enhance existing or new historical/temporal algebras (e.g. Tansel's algebra). Section 5 provides several examples to illustrate how historical queries are expressed using the modified operators.

For the purpose of this paper, we shall consider an historical relational database in which each relation is viewed as a collection of related attributes some of which are invariant with time while others vary with time. For those attributes whose value varies with time, the temporal component maintained in an historical database represents valid time i.e. the time during which the recorded value was/is valid. In the following discussion, we shall assume that time (valid time) is represented by (encoded as) integer values and that the symbol NOW represents the current value of time. We adopt the notion of time-independent key (TIK) as introduced in [12], i.e. every relation has a key that consists of a collection of attributes (one or more) which are invariant with time. Time-varying attributes are double time-stamped as done in Refs [3-5, 7, 17, 18]. This means that every time-varying attribute in a tuple is a set of triplets of the form (value,(start,end)). The time interval components consists of a double time-stamp, i.e. a time-stamp with two time values corresponding to the lower and upper bounds of the time interval. Thus the triple (a, (2,4)) indicates that the value of "a" has been continuously valid from time 2 to time 4 inclusive (i.e. both the time points 2 and 4 are included in the interval). Thus all time intervals arc considered !~ h," .-1,~. ! ,~n h~th

261

Page 2: Time-based operators for relational algebra query languages

262 M.A. BASSIOUNI et al.

Table 1. An example relation

Name School Residence

Brian (UCF, (1974, 1981)) (Orlando, (1974, 1976)) (USF, (1982,1985)) (Oviedo, (1977,1981)) (UF, (1985, NOW)) (Tampa, (1982,1985))

(Gainesville, ( 1985, NOW))

(Miami, (1975,1980)) (W.P., (1981 , 1982))

(Orlando, (1983, NOW))

Smart (FAU, (1975,1980)) (UCF, (1981, NOW))

ends. Double timestamping is also synonym to "interval timestamping", i.e. an interval (rather than a time point) is used for timestamping. We assume that the values of the two endpoints of each timestamp are fully known; null (unknown) timestamps are not considered in this paper. To extract the value portion of a triple t the operation VALUE(t) is employed. To extract the time interval portion of a triple t the operation WHEN(t) is employed. Table 1 is an example of an historical relation that records the school and city of residence for employees of the State University of Florida.

Attribute "name" is assumed to be the TIK of the relation in Table 1. In the first tuple, attribute "school" is a set of three triplets giving the names of the schools and the periods during which Brian was (is) employed. Thus, Brian worked at UCF from 1974 to 1981. During that interval (1974 to 1981), Brian lived in two cities: Orlando (from 1974 to 1976) and Oviedo (from 1977 to 1981) as indicated by the first two triplets in the "residence" attribute. Notice that the relation shown in Table 1 is not in First Normal Form (N1NF relation). The advantages of N1NF structures have been recognized and N1NF schemes have been adopted in many previous historical/temporal models [e.g. 5, 17, 6, 7, 3] as well as in some snapshot systems that allow attributes to be set-valued (e.g. as in the language GEM [19]).

In the next sections, we present modified versions of the snapshot relational algebra operators.

2. A GENERALIZED BOOLEAN AND COMPARISON LOGIC FOR HISTORICAL OPERATIONS

The modification of the relational algebra operators presented in the next section is based upon a generalized Boolean and comparison logic. In this section we summarize this generalized logic. The generalized Boolean operators are ANDr, ORr and NOTr, which operate on triples or sets of triples. The generalized comparison operators are presented later in this section.

Consider the following historical relation

STUDENT(name, gpa , major, advisor, city) name :constant attribute gpa , major, city, advisor, : temporal attribute;

The following extended Boolean expression

(gpa > 3.5) ANDr (major = M A T H )

requires that the (selected) student maintained a grade point average better than 3.5 while (i.e. at the same time when) enrolled in the "MATH" department. It is important to note the distinction between the expression above and the following standard Boolean expression

(gpa > 3.5) AND (major = M A T H )

which requires only that the (selected) student maintained a grade point average better than 3.5 and was enrolled in the "MATH" department. Note that the extended expression requires, for the selected student, the two conditions occur and do so simultaneously. The standard expression requires, for the two selected student, only that both conditions have occurred, not necessarily simultaneously. The new operator ANDr (temporal AND) operates on sets of time intervals and returns a set of time intervals (possibly empty). For example, assume that the evaluation of the

Page 3: Time-based operators for relational algebra query languages

Time-based operators for relational algebra query languages 263

operand gpa > 3.5 returned the set:

{ (3.54, (3, 4)) , (3.6, (6, 8)) , (3.58, (12, NOW)) }

and that the evaluation of major = MATH produced the set

{ (MATH, (7, 8)) , (MATH, (10, 15)) }

Then the condition of the above expression is satisfied for that student, and the operator ANDr will return the two intervals (7, 8) and (12, 15). These are exactly the intervals in which the student had a gpa of better than 3.5 while enrolling as a "MATH" major.

Definition: if St and $2 are two sets of time intervals, then the expression St ANDr S 2 returns the value NIL (empty set) if the two sets contain no overlapping time intervals. Otherwise ANDr returns the time intervals that are contained in the intervals of both St and $2 (i.e. their overlapping).

Similar temporal extensions can be defined for the operatores NOT and OR. The unary operator NOTr returns the set of intervals which is the complement of its operand (with respect to the universal interval (0 , NOW)). For example, the expression

NOTr {(2,2), (6 ,8) , (7,9)}

returns the set {(0,1), (3 ,5) , (IO,NOW)}. The operator NOTr can be very useful in expressing temporal conditions. For example,

the following expression gives the set of time intervals during which the student has not lived in Miami.

NOTr (city = Miami)

Definition: if St is a set of time intervals, then the expression NOTr St returns the value NIL (empty set) if the set St is the universal interval. Otherwise NOTr St returns the set of time intervals or time points, within the realm of (0, NOW), which are not present in the set St (i.e. the complement of St).

Similarly, the operator ORr returns NIL if both of its operands are NIL. Otherwise, it returns the union of the intervals of its operands.

For example, the expression

city = Tampa ORr city = Miami

returns the time intervals during which the student has lived in either Tampa or Miami. Definition: if St and S: are two sets of time intervals, then the expression St ORr $2 returns the

value NIL (empty set) if the two sets St and $2 are both empty. Otherwise ORr returns all of the time intervals that are contained in either St or $2.

We now present the definition of set-valued comparison operators. There are six set-valued temporal comparison operators:

= r > r < r ~>r ~<r # r

As an example, let city t and city 2 represent the "city" attribute of two students. The following expression

cityl =r city2

requires that both students have lived in the same city at the same time (i.e. the corresponding time intervals must overlap). Thus set-valued temporal comparison operators can only compare values that belong to the same time (i.e. values that have overlapping time intervals). If the comparison condition is not met, a value NIL is returned. Otherwise, the value returned by temporal comparison operators would be the set of time intervals during which the comparison condition is satisfied.

The rule for handling operands that are constants or nontemporal attributes is simple: such operands are automatically given the universal interal (0, NOW). Thus the comparison 7 > r 5 returns the universal interval, the comparison 5 > r 7 returns NIL, and the composite comparison (5 > r 7) =r NIL returns the universal interval.

Page 4: Time-based operators for relational algebra query languages

264 M.A. BA~IOUNI et al.

Since the temporal operators ANDr, ORr and NOTr, are set-valued operators, the standard TRUE/FALSE operators AND, OR and NOT should also be extended to become set-valued operators (we call these operators the logical operators AND, OR and NOT). This can easily be done by treating any empty operand as an operand having the value FALSE and any non-empty set as an operand having the value TRUE. For the output (result) returned by the standard Boolean operators, the value FALSE is replaced by NIL (the empty set) and the value TRUE is replaced by the universal interval (O,NOW). Similar extensions are adopted for the standard (non- temporal) comparison operators. Thus the operator " = " returns either the universal interval or NIL and performs comparison on values without regard to their time intervals.

It is easy to see that the generalized Boolean operators ANDr, ORr and NOTr also satisfy the basic properties of the normal Boolean logic (e.g. DeMorgan's Law, Distributivity, Associativity, etc.). For example, if E 1, E2 and E3 are sets of time intervals, then the following equivalences are satisfied.

a. NOTr(E1 ANDRE2) = (NOTRE1) ORr(NOTrE2)

b. NOTr(E10RrE2) = (NOTrE1)ANDr(NOTrE2)

c. E 1 ANDr (E20Rr E3) = (E 10Rr E2) ANDr (E 10Rr E3)

d. E10Rr(E2 ANDRE3) = (El ORrE2) ANDr(E10RrE3)

The proof for the above properties is straightforward, and will not be given in this paper.

3. MODIFIED ALGEBRA OPERATORS

Modifications to the standard relational algebra operators are presented in this section. An important feature of the modified operators is that they are a generalization of the standard operators, i.e. if their operands are snapshot (nontemporal) relations, the modified operators reduce to their corresponding operators in the standard relational algebra. This results from our technique for handling constant valued attributes which was discussed in Section 2, namely, nonhistorical attributes are assumed to be valid over the universal interval (0, now). Thus the extended operators will correctly operate on both historical and snapshot relations. The generalized Boolean operators presented in Section 2 will be primarily utilized in the selection relational algebra operator. Before discussing this important operator, we first cover the union, intersection and difference operators.

3.1. Temporal Union Compatibility

The standard relational operators of union, intersection and difference require that the operand relations be union compatible. Basically this requires that the operand relations have the same number of attributes which, in a one-to-one correspondence, are defined over the same underlying domains. Generalizing the standard relational operators to handle historical relations requires that the definition of union compatibility also be generalized. To this end we define temporal union compatibility as follows:

Let R(AI . . . . ,Ak, B I , . . . , B m ) and S(A~,.. . ,Ak, C I . . . . . Cn) be two historical (temporal) relations with a common key: A~, A2 . . . . . Ak. R and S are "temporally union compatible" if:

(1) R[TIK] = S[TIK], that is dom(R[A,]) = dom(S[Ai]), i ~< i ~< k (2) m = n

and (3) dom(VALUE(R[Bi])) = dom(VALUE(S[C~])), I ~< i ~< m

Each Bi and Ct is an historical attibute and is therefore a triple of the form (value, (start,end)). Both of the points in the time interval (start,end) are defined over the universal interval (0, NO W). The temporal portion of an historical attribute can be extracted from the triple through the use of the WHEN operator, i.e. WHEN(R[Bi]). Given an historical attribute "B", we emphasize that "B" represents a set of triples, while VALUE(B) represents a set of values, and finally, WHEN(B) represents a set of time intervals. A single triple of an historical attribute B will be

Page 5: Time-based operators for relational algebra query languages

Time-based operators for relational algebra query languages 265

denoted by "b". In this case, VALUE(b) represents a single value and WHEN(b) represents a single time interval.

3.2. The Historical Union Operation

The Historical Union operation is a binary operator which requires the operand relations to have temporal union compatibility. The Historical Union operation is performed based on the time-independent key of its operands. The definition of the Historical Union operator is given by:

R u t S = {tuples tR[tR¢ R, and not3 ts~ S such that tR['rIK ] = ts[TIK ] }

UNION/* normal set union */

{ tuples tslts6S, and not3 tR¢R such that ts[TIK] - tR[TIK] }

U N I O N / * normal set union */

{ tuples tlt(A~,.. . , Ak, DI . . . . . Din), tR ~ R, and ts 6 S such that tR[TIK ] = ts[TIK] = t[TIK] and for all i such that 1 ~< i ~< m t[Dj] = { triples di[ triples bi ~ Bt and c~ ~ C~

if VALUE(tR(b~) ) = VALUE(ts(G)) then begin

VALUE(t(d,)) = VALUE(t R (b,)) WHEN(t(d~)) = WHEN(ta(b;)) ORr

WHEN(ts(C,)) e n d

elseif not3 G ~ S such that VALUE(tR(b~)) = VALUE(ts(C~)) then d, = bi

elseif not3 b, ~ R such that VALUE(tR(bi)) = VALUE(ts(C~)) then d~ = c;

endif }

}

For the purpose of illustrations, we shall use two union-compatible relations R and S which have a time-independent key (TIK) named K and two temporal attributes: A and B, illustrated by Tables 2 and 3. An historical attribute may have no value or may have multiple values during specific intervals (or points) of valid time.

Notice that multiple values for a given attribute during a specific time are allowed as was shown in Table 3. The two values bl and b2 are assigned to attribute B of tuple K3 in the same time interval.

Table 4 shows the result of the Historical Union operation when applied to relations R and S (Tables 2 and 3). Notice that in attribute B of the tuple for K1, the triplet (b I , (2,7)) is formed by merging together the first triplet of Table 2 and 3 as follows:

( b l , ( 2 , 5 ) ) w r ( b l , ( 4 , 7 ) ) = (b l , ( 2 , 7 ) )

Table 2. Relation R

K A B

KI (al, O , 3>) (bl, (2,5)) (a2, (4,7)) (b2, (8,9))

(bl, (10, NOW))

K2 (al, (2,5)) (b3, (2, S)) (a3, (6,8))

Table 3. Relation S

K A B

KI (al, ( I , 3)) (bl, (4,7)) (a3, (8, NOW)) (b2, (8,9))

(b3, (4,6))

K3 (a4, (2, NOW)) (bl, O , 5)) (b2, (6, NOW))

Page 6: Time-based operators for relational algebra query languages

266 M.A. Bxsslour~i et al.

3.3. The Historical Intersection Operator

The Historical Intersection operation is a binary operator which requires temporal union compatibility between the operand relations. The Historical Intersection operation is performed based on the TIK of the two relations. The definition of the Historical Intersection operator is given by:

R n r S = { tuples t I t(A~ . . . . . Ak, D~ . . . . . Din), tR ~ R, and ts ~ S such that tR[TIK] = ts[TIK] = t[TIK] and for all i such that 1 ~< i ~< m t[D~] = { triples d~ltriples b~e Bi and c ~ C~ if VALUE(t~(b,.))= VALUE(ts(C~)) and WHEN(/R(bi)) ANDr

WHEN(ts(bi)) ~ NIL then begin

VALUE(t (di))= VALUE(tR (b,)) WHEN(t(d~)) = WHEN(t~(b,)) ANDr WHEN(ts(C,))

end }

}

Table 5 gives the result of applying the Historical Intersection operation on relations R and S (Tables 2 and 3). Notice that the triplet (b 1, (4,5)) in attribute B of Table 7 is obtained as a result of applying the Historical Intersection operation on the first triplet in attribute B of the two relations as follows

( b l , ( 2 , 5 ) ) n r ( b l , ( 4 , 7 ) ) = ( b l , ( 4 , 5 ) )

3.4. The Historical Difference Operator

The Historical Difference operator is also a binary operator that requires that operand relations be temporally union compatible. The defintion of the Historical Difference operator is given by:

R - rS = { tuples tR[ tR e R and not3 ts e S such that tR[TIK] = ts[TIK] }

U N I O N / * normal set union */

{ tuples t lt(A~ . . . . . Ak, D ~ , . . . , Din), tRe R, and ts E S such that tR[TIK] = ts[TIK] = t[TIK] and for all i, 1 ~< i ~< m t[D~] = { triples d~l triples b~ ~ B~ and c~ ~ Ci

if VALUE(tR(b~)) = VALUE(ts(C~)) then begin VALUE(t(d~)) = VALUE(tR(bi)) TEMP = WHEN(t R (b,)) for all cj~ t,[Ct] such that

VALUE(tR(b~)) = VALUE(ts(Ci)) do

TEMP = TEMP AND r (NOTr WHEN(ts(C,))) endfor WHEN(t(d~)) = TEMP end

elseif not3 c~ such that VALUE(tR(b,)) = VALUE(ts(C~)) then d~ = b; endif

} }

The difference operator is applied based on the time-independent key of the two relations. If there is a tuple in each relation with the same TIK value, then the resulting tuple in the output is obtained

Page 7: Time-based operators for relational algebra query languages

Time-based operators for relational algebra query languages 267

Table 4. Relation RutS Table 5. Relation Rc>rS K A B K A B

KI ( a l , ( 1 , 3 ) ) (b1 , (2 ,7) ) KI (al , ( I , 3 ) ) (b1 , (4 ,5) ) (a2, (4 ,7)) (b2, (8 ,9)) (b2, (S, 9))

(a3, (8, NOW)) (b3, (4,6)) (bl , (10, NOW))

K2 (al , (2 ,5 ) ) (b3, (2 ,8)) (a3, (6 ,8))

K3 (a4, (2, NOW)) (bl, <l, 5>) (b2, (6, NOW>)

by applying the difference on the sets of triplets of every pair of corresponding attributes of the two relations.

Table 6 gives the result of R - r S. Notice that the tuple for K2 in the result is exactly the same as that of relation R (since there is no tuple with TIK = K2 in relation S). Notice also that the triplet (b 1, (2,3)) in attribute B of tuple KI (Table 6) is produced as a result of applying the difference operation on the first tuple in R and S as follows

(b l , (2 ,5 ) ) - r ( b l , ( 4 , 7 ) ) = (b l , (2 ,3 ) )

When applying the difference on two triplets having the same value and overlapping time intervals, the result is either a single triplet as shown above, or a pair of triplets as we now discuss. A given time interval in overlapping with another time interval may generate at most two time intervals which are not included in the overlapping period. As an example, consider the following situation: Change the first tuple of B in relation R from (b 1, (2 ,5 ) ) to (b 1, (2 ,9)) , and call this modified relation R'. Table 7 shows the result of R ' - r S.

The two triplets (b 1, ( 2 ,3 ) ) and (b 1, (8 ,9 ) ) of attribute B of tuple KI are produced as a result of applying the difference operator on the first tuple of R and S as follows

( b 1 , ( 2 , 9 ) ) - r ( b l , (4 ,7 ) ) = {(bl, ( 2 , 3 ) ) , ( b 1 , ( 8 , 9 ) ) } .

It is easy to see that the extended historical operations presented thus far, satisfy the basic properties of the standard relational algebra operators. For example, if R, S and T are three temporally union-compatible relations, then the modified operators defined above satisfy the following equivalences:

1. R u r ( S c ~ r T) = ( R u r S ) n r ( R u r T) 2. RC~r(Swr T) = ( R C 3 r S ) u r ( R n r T) 3. R n r ( S c ~ r T ) = ( R ~ r S ) n r T 4. R u r ( S u r T ) = ( R w r S ) u r T 5. R ~ T S = R - T(R - rS )

the above properties is straightforward, and will not be given in this Again, the proof for paper.

3.5. The Historical Selection Operation

The modified selection operator has the form

aQ(V) [by Specs]

where the square brackets are used to indicate optional syntax. In the above expression, the symbol V represents the name of the relation (the operand of a), Q is a qualification used to decide whether

Table 6. Relation R - r S Table 7. Relation R" - r S

K A B K A B

K1 (a2, (4 ,7) ) (bl, (2 ,3)) KI (a2, (4 ,7)) (bl, (2 ,3)) (bl , (10, NOW)) (bl, (8 ,9))

K2 (al, (2 ,5)) (b3, (2 ,8)) (bl , (10, NOW)) (a3, (6 ,8)) K2 (al, (2 ,5)) (b3, (2,8))

(a3, (6 ,8))

CL 19/4---E

Page 8: Time-based operators for relational algebra query languages

268 M.A. BASSIOUNI et al.

a tuple is selected in the result, and "Specs" is used to specify the method (form) in which the temporal attributes of the selected tuples are stored in the result. We shall shortly give detailed description of each component of the selection statement. But first, we present a simple example to illustrate the purpose of Q and Specs.

Consider the following selection operation

~ = a3 (R)

Simply this operation selects the second tuple (TIK = K2) in relation R (Table 2). The output of the above selection is therefore given by

K A B

K2 (al , ( 2 , 5 ) ) (b3, ( 2 , 8 ) ) (a3, ( 6 , 8 ) )

On the other hand, the expression

OA=a3(R) by A inside (1,4)

produces the relation

K A B

K2 (a l , ( 2 , 4 ) ) (b3, ( 2 , 8 ) )

Notice that the specification "A inside (1,4)" indicates that attribute A of the selected tuple is to be time-sliced by the interval (1,4). Attribute B is not affected by this time-slicing and will therefore have the default specification, ie., attribute B is given the same triplets as those found in the source relation R. Now the expression

trA =a3(R) by A inside SELECT ; B before 5

will give the result

K A B

K2 (a3, ( 6 , 8 ) ) (b3, ( 2 , 4 ) )

The condition A = a3 is the selection qualification that is used to determine which tuples get selected. Once a tuple is selected, [by Specs] is used to determine how each temporal attribute is output in the result. In the above case, the specification "A inside SELECT" indicates that attribute A is to be time-sliced by the interval(s) returned by the selection qualification A = a3 (details about how the selection qualification is evaluated are given later). For relation R, the value returned by the qualification A = a3 is the interval (6,8) (see Table 2). On the other hand, the specification "B before 5" has the effect of time-slicing attribute B by the interval (0,4), and hence gives only the values of B before time 5.

3.5.1. The selection qualification

The selection qualification is a generalized condition which utilizes the extended logic presented in Section 2 and returns a set of time intervals (rather than the Boolean value True or False).

As indicated in Section 3.5, the "Specs" part of the Select operator is used to indicate how each temporal attribute in the selected tuple is output in the result. First, the following notation is used in both the qualification and specification parts of the Select operator. Let A be a temporal attribute, then

The symbol "A" indicates the set of triplets (value/interval pairs) of A. The symbol "A.INTERV" indicates the set of intervals of A, i.e. the same as WHEN(A). The symbol "A.VAL" indicates the set of values of A, i.e. the same as VALUE(A).

Page 9: Time-based operators for relational algebra query languages

Time-based operators for relational algebra query languages 269

The symbol "A.START" indicates the set of starting points of the intervals of A. The symbol "A.FINISH" indicates the set of finishing points of the intervals of A.

The following keywords are used in the Specs part. Inside, outside: The expression "A inside I" indicates that the triplets of attribute A are to be

time-sliced by the intervals of I. The expression "A outside I" indicates that the triplets of attributes A are to be time-sliced by the intervals contained in the complement of I with respect to the universal interval (0, NOW).

at, before, after: The expression "A at P" indicates that the triplets of attribute A are to be time-sliced by the degenerate interval (P,P). The expression "A before P" indicates that the triplets of attribute A are to be time-sliced by the interval ( 0 , P - 1). The keyword "after" is defined analogously, i.e. (P + 1,now). We now give an example to illustrate the selection operator.

Consider the expression

aQ(R) by A inside (2,5) ; B.VAL inside SELECT

where Q is the qualification A = ral ANDrB = rbl . The selection qualification returns the set of intervals during which attribute A has the value

al and attribute B has the value bl. For tuple K1 of Table 2, the evaluation of the expression A = ral returns the interval (1,3) while the evaluation of B = rbl returns the set of intervals {(2,5), (IO,NOW)}. The ANDr operation then returns the interval (2,3) which becomes the result of the selection qualification for tuple K1. Similarly, the evaluation of the selection qualification for tuple K2 returns the empty set NIL. Thus only Tuple K1 is selected for output. Next, the "Specs" part indicates that attribute A in the output should be time-sliced by the interval (2,5). Attribute B should be time-sliced by the intervals returned by the selection qualification, i.e. by the interval (2,3) for tuple K1. Furthermore, the symbol B.VAL indicates that only values of attribute B (and not triplets) are to be collected in the output. Therefore the result of the above selection is given below (attribute B is no longer an historical attribute).

K A B

K1 (al , ( 2 , 3 ) ) bl (a2, ( 4 , 5 ) )

4. OTHER HISTORICAL OPERATORS

4.1. The projection operation

The definition for this operator is the same as in the standard relational algebra. Since this operator is not modified, we use the standard projection symbol without a subscript for historical extension. For example, the expression

IIx,A(R)

will simply return the first two columns of relation R, (Table 2).

4.2. The product operator

As with the Projection operator, the cartesian product in our model has the same definition as in the snapshot relational algebra. Again this operator will not carry the historical operator subscript. Thus the expression R × S means that every tuple in R is combined with every tuple in S. We use the notation R.A and S.A to reference attribute A of R and attribute A of S, respectively, in the relation R × S.

4.3. The historical theta-join operator

The historical theta-join operator is a redundant operator which is defined in terms of the cartesian product and historical selection operations. The expression: R joint(Q)[by Specs] S will be our notation for the theta-join operator. The historical theta-join operation is a cartesian product followed by a selection based upon the specified predicate Q with an optional [by Specs]

Page 10: Time-based operators for relational algebra query languages

270 M.A. BAssloum et al.

part. Note that the selection is exactly the operation defined in Section 3.5. The historical theta-join operator is defined as:

R joinr(Q) [by Specs] S -= aQ(R x S)[bySpecs]

The relation shown below is the result of the expression Rjoinr (R.A = r S.A)S, where R and S are as shown in Tables 2 and 3. Notice that the tuples from R and S are combined only if the evaluation of R.A = r S.A returns a nonempty set of intervals.

R.K R.A R.B S.K S.A S.B

K1 (al,(1,3)) (b1,(2,5)) K1 (al,(1,3)) (b1,(4,7)) (b2,(8,9)) (b2,(8,9))

(bl,(10,now)) (b3,(4,6))

K2 (a1,(2,5)) (b3,(2,8)) K1 (al , ( l ,3)) (b1,(4,7)) (a3,(6,8)) (a3,(8,now)) (b2,(8,9))

(b3,(4,6))

4.4. The historical natural join operator

The historical natural join operator is a redundant operator which is defined in terms of the cartesian product, projection and historical selection operations. The expression: R joinTS will be our notation for the the natural join operator. The historical natural join of two relations R and S is the projection onto at t r (R)uat t r (S) (attr(R) is the set of attributes of relation R) of a theta-join where the predicate requires that R.A = S.A for every constant valued attribute A in attr(R)c~attr(S). In addition it is required that R.B = r S.B is nonempty for every common temporal attribute B in attr(R)c~attr(S). The historical natural join operator is defined as:

Let attr(R)nattr(S) = {A~, -42 . . . . . Am, BI, BE, . . . , Bn}

i.e. R and S have m common constant attributes and n common historical attributes and let Qc be the qualification (R.A~ = S.A~)AND.. . AND(R.-4m = S.-4m).

Then the value of R joint S is given by the result produced by the following code.

TEMP..=trec (R x S) for i.-= 1 to n do

TEMP:=trRB,=rsB ~ (TEMP) by R.B~ inside SELECT end for RESULT,=I-la#~R)~,att~s~ ( T E M P )

where the projection in the last step is used to remove the attributes in S that are common to R.

If we rename attribute B in Table 3 for relation S, to attribute C for purposes of an example, then the relation below would be the result of the natural join of R and S.

K A R.B S.C

K1 (al,(1,3)) (b1,(2,5)) (b1,(4,7)) (b2,(8,9)) (b2,(8,9))

(bl,(10,now)) (b3,(4,6))

5. EXAMPLES

We now present some examples of relational queries using the proposed generalized operators and the STUDENT relation defined in Section 2.

Page 11: Time-based operators for relational algebra query languages

Time-based operators for relational algebra query languages 271

Example 1

The following query gives the grade point average at time 10 of any student who, while living in Miami, enrolled in the MATH department and maintained a gpa higher than 3.5.

TEMP..=trQ(STUDENT) by gpa.VAL at 10 where Q is (city = r Miami A N D r major = r M A T H A N D r gpa > r3.5)

R E S U L T .'= H ..... Spa ( T E M P )

Notice that the selection qualification (which follows the a operator) is used to determine whether the given student is a candidate for output (the selection qualification must evaluate to non-NIL for such a student). The specification part (which follows the "by" keyword) is used to extract the gpa values at time l0 for each selected student.

Example 2

For every student that was advised by "Fred" while enrolling as a MATH major, print his "gpa" history at that time and his current city.

T E M P , = a o ( S T U D E N T ) by spa inside S E L E C T ; c i t y . VAL at N O W where Q is (advisor = r FRED A N D r major = r M A T H )

R E S U L T =:H . . . . spa,city ( T E M P )

The selection qualification returns the set of time intervals during which the student was advised by Fred while enrolling in the MATH department. This set of intervals replaces the keyword SELECT in the specification part. Thus the result in the above query gives the "gpa" triplets when the student was (is) enrolled as a MATH major and advised by Fred.

The previous examples dealt with only one relation. Dealing with multiple relations follows the same approach. For the purpose of the next example, we define the following relation.

M A J O R (major, college, chair) major, college : constant attribute; chair : temporal attribute;

Example 3

When did John and Ronald enroll together in a department chaired by Dr Lam? Notice that "major" is a temporal attribute in relation STUDENT and is a nontemporal attribute in relation MAJOR.

T E M P , = S T U D E N T x M A J O R

TI ' .=aQ(TEMP) by S .major . INTERV inside S E L E C T where Q is (name = r John A N D r S.major = r M.major A N D r chair = r Lam)

J'= H M.ma¢or.S.major ( T1)

T2,=tro(TEMP) by S .major . INTERV inside S E L E C T where Q is (name = r Ronald AND r S.major = r M.major ANDT chair = r Lam)

R :=HM.m,,jor,S.m,,jo,.(T2)

R E S U L T ' . = J n r R

In example 3, the notation S.major and M.major are used as abbreviation for STUDENT.major and MAJOR.major, respectively. Relation Tl contains the (student) tuple of John concatenated with tuples form relation MAJOR in which the chair was(is) Lain at the same time when John enrolled in that major. Relation J contains two attributes: a constant attribute MAJOR.major and a set attribute containing the intervals contained from STUDENT.major. Relations T2 and R are similarly constructed for Ronald.

Page 12: Time-based operators for relational algebra query languages

272 M.A. BA~IOUN1 et al.

Example 4

List the names of the students who have never been advised by the chair of their major.

S__ALL,= II~,~ (STUDENT)

S _ C H A I R , = H , , ~ ( a Q ( S T U D E N T × MAJOR) ) where Q is S.major = r M.major ANDr M.chair = r S.advisor

RESUL T,=S__ALL - S _ C H A I R

Notice that relation S_CHAIR contains the names of students who have been advised by the chair of their major.

6. COMPARISON WITH OTHER LANGUAGES

The main contribution of the proposed generalized operators is that they provide a natural extension of the snapshot relational algebra for historical databases. This is accomplished by using relational algebra operators that are based upon extensions of Boolean and comparison operators which handle sets of time intervals. Our paper has concentrated on the basic snapshot relational algebra operators and proposed an extended logic to enhance their retrieval capability. The extended logic would be very beneficial to existing or newly proposed historical algebras. Using this extended logic, many queries can be formulated using the familiar snapshot relational algebra syntax, without the need to use non-snapshot operators. It is important to emphasize that the generalized operators discussed in this paper do not entirely eliminate the need for non-snapshot operators. These latter operators are still necessary to make the retrieval power of the language complete. For example, if we make a minor change to Tansel's algebra in that we only replace the standard Selection operator by our extended Selection operator, then many time-based queries can be expressed in an easier, more succinct and elegant way than with the original Tansel's algebra. To illustrate this point, notice that almost all queries expressed in Tansel's algebra [5] will require the use of some of the new (non-snapshot) operators: Pack, Unpack, Triple_Decompose, Triple_Form, and Slice (denoted by P, U, T, T_DEC, T_FORM, and SLICE respectively). The following examples illustrates this point.

Example 5

List the name of any student whose gpa fell below 2.0 while majoring in Math. The following is the solution of the above query using our proposed algebra:

H.~,,~ (a o (STUDENT)) where Q is gpa < r 2.0 AND r major = r Math

using Tansel's algebra the solution would be:

l"Iname (¢~Q ( T-.DEC~jor ( T-DECepa (SLICEgra.m~yo, (Um~jo, (Uspa (STUDENT))))))) where Q is gap < 2.0 AND major = Math

The query expression using Tansel's algebra can be explained as follows. Relation STUDENT is first unpacked on attributes "gpa" and "major". The Unpack operator transforms each tuple (having a set of triplets in the given attribute) into a collection of tuples each of which has a single triple. A time slice operation on attribute "gpa" using attribute "major" is then performed. The Slice operator checks the interval portions of the two triplets of attributes "gpa" and "major" and keeps only those tuples where there is an overlap between these two intervals. Next a triplet decomposition is performed on attributes "gpa" and "major". The T_DEC operator splits the temporal attribute "gpa" into three attributes: attribute "gpa" contains the value portion, attribute "L_gpa" contains the lower (start) time of the interval and attribute "U_gpa" contains the upper (finish) time of the interval. A similar transformation occurs to attribute "major". The relation has now been transformed into First Normal Form. The selection operation is applied using standard Boolean qualification.

Page 13: Time-based operators for relational algebra query languages

Time-based operators for relational algebra query languages 273

In the above example, our extended logic enabled us to perform the required operators and comparisons directly on the historical schema without the need to transform it to First Normal Form. Without this extended logic, one has to use the non-snapshot operators to obtain an intermediate result in First Normal Form and then apply the normal selection and comparison operators. This should not be interpreted to mean that the extended logic has the capability to transform any historical schema to First National Form. Rather, the need for such transformation may be avoided in many queries due to the feasibility of applying the extended operators to N1NF relations. Thus with the extended logic, Tansel's algebra becomes a much more attractive language that has at least the same expressive power of the original algebra (notice that Tansel's algebra is equivalent to a temporal calculus [10]). Similar benefits could be obtained by adapting the extended logic to other algebras. Gadia's algebra is also equivalent to a temporal calculus [10]. Notice, however, that the original model of Gadia [6, 10] imposes the restriction of temporal homogeneity on all the attributes of a tuple. Multiple tuples would be needed if multiple values of the attribute occur at the same time (for a concise but clear discussion on Gadia's homogeneity property, the reader is referred to the explanation and example given in Section 1.2.8 of Ref. [10]). Applying this model to Table 1, each of the two tuples in that table will be decomposed into several homogeneous tuples, i.e. each new tuple will have the same time intervals for the three attributes. Furthermore, our logic handles constant (non-temporal) attributes in an easier and more natural way. In essence, the homogeneity property of Gadia's original model (i.e. the requirement that all attribute values in a tuple be functions on the same temporal element) does not support static attributes as explained in the comparative study by McKenzie and Snodgrass [10] (p. 532, criterion 21). Our extended operators smoothly operate on constant valued attributes by attaching the universal interval as their timestamp. Static, temporal attributes with homogeneous time intervals, and temporal attributes with non-homogeneous intervals can all be interchangeably used as operands to our extended operators without restriction.

The proposed logic uses extended Boolean and comparison operators which is applied to sets of time intervals (rather than the standard True/False values). This has enabled us, for example, to construct a selection relational algebra operator that is more effective than the typical selection operator used in other historical models. To see this, notice that the standard selection operator restricts the qualification F to use the standard TRUE/FALSE logic. This is obviously subsumed by our extended logic which allows F to be a set-valued expression. The standard selection operator is obviously a special ease of our extended selection counterpart.

Our emphasis is that the generalized operators can be used to enrich existing historical query languages and to provide an easier and more natural time-based interface. Using the generalized operators, users can express their queries more naturally, succinctly and elegantly. Notice that according to Ref. [10], a historical algebra should provide, as a minimum, a time-oriented counterparts of the basic operators that define the snapshot algebra. We have concentrated primarily on these basic snapshot operators and proposed an extended logic to enhance their retrieval capability. If this logic is incorporated into other historical algebras (retaining their additional operators or modifying them as appropriate), the result will be a better and more user friendly system.

7. CONCLUSION

In this paper, we have presented a new approach for historical relational algebra that is based on generalized Boolean logic and modified versions of the standard relational algebra operators. The haodified operators can be applied to both snapshot as well as historical relational databases. Our emphasis is that the generalized operators can be used to enrich existing historical query languages and to provide an easier and more natural time-based interface. Using the generalized operators, users can express their queries more naturally, succinctly and elegantly. Examples have illustrated the model language's flexibility in expressing different temporal requirements. We are currently investigating high-speed implementations of the proposed historical operators. Appendix II presents an efficient approach that can be used as the basis for both software and hardware implementations of the extended operators.

Page 14: Time-based operators for relational algebra query languages

274 M.A. BASSXOUNI et aL

R E F E R E N C E S

I. Ahn, I. Towards an implementation of Database management systems with temporal support. Proc. IEEE Conf. Data Engng 374-381; 1986.

2. Ariav, G. A temporally oriented data model. ACM Trans. Database System 11: 499-527; 1986. 3. Bassiouni, M. A logic for handling time in temporal databases. Proc. IEEE COMPSAC Conf. 345-352; 1988. 4. Bassiouni, M. and Llewellyn, M. A relational-calculus query language for historical data bases. Comput. Lang. 17:

185-197; 1992 (preliminary version of this paper was published in Proc. IEEE Intl. Conf. Computer Languages, ICCL, 1988, pp. 128-134).

5. Clifford, J. and Tansel, A. On an algebra for historical relational databases: two views. Proc. ACM SIGMOD Int. Conf. Management Data, 247-265; 1985.

6. Gadia, S. and Vaishnav, J. A query language for a homogeneous temporal database. Proc. ACM Symp. Principles Database Systems 51-56; 1985.

7. Gadia, S. Towards a multihomogeneous model for a temporal database. Proc. IEEE Int. Conf. Data Engineering 390-397; 1986.

8. Llewellyn, M. and Bassiouni, M. Historical database views. J. Inform. Software Techn. 33: 113-120; 1991. 9. McKenzie, E. and Snodgrass, R. Extending the relational algebra to support transaction time. Proc. ACM SIGMOD

Conf. Management Data 467-478; 1987. 10. McKenzie, E. and Snodgrass, R. Evaluation of relational algebras incorporating the time dimension in databases. ACM

Comput. Surveys 23: 501-543; 1991. 11. Navathe, S. and Ahmed, R. TSQL--A language interface for temporal databases. Proc. Conf. Temporal Aspects of

Information Systems, AFCET, France, May 1987, pp. 113-128. Amsterdam: North-Holland; 1987. 12. Navathe, S. and Ahmed, R. A temporal relational model and a query language. Int. J. Inform. Sci.: 147-175; 1989. 13. Sarda, N. Extension to SQL for Historical Databases. 1EEE Trans. Knowledge Data Engng 2: 220-230; 1990. 14. Segev, A. and Shoshani, A. Logical modeling of temporal data. Proc. ACM S1GMOD Conf. Management Data 454-466;

1987. 15. Snodgrass, R. and Ahn, I. Temporal databases. Comput. 19: 35-42; 1986. 16. Snodgrass, R. The temporal query language TQUEL. ACM Trans. Database Systems 12: 247-298; 1987. 17. Tansel, A. and Arkun, M. HQUEL: A query language for historical relational databases. Proc. 3rd Int. Workshop

Statistical Scientific Databases; 1986. 18. Tansel, A., Arkun, M. and Ozsoyoglu, G. Time-by-example query language for historical databases. IEEE Trans.

Software Engng 15: 464-478; 1989. 19. Zaniolo, C. The database language GEM. Proc. ACM SIGMOD Int. Conf. Management Data 207-218; 1983.

APPENDIX I

BNF Specification for the Modified Operators This appendix gives a formal description of the syntax of the basic operators of the historical relational algebra proposed in this paper. Since the historical relational algebra basically uses the notation of standard relational algebra, we limit our specifications to the new (historical) aspects of the algebra, and do not formally define obvious nonterminals (such as (attr_names), (relation_names), (constant), (time intervals), etc.).

(RA expression):=(union compatible expr) I (product expr) ] (projection expr) J (select expr) [ (RA primary)

(RA primary):,="(" (RA expression) ")" ](relation name)

(union compatible expr)::=(RA primary) (union compatible op) (RA primary)

(union compatible op): ,="u" ] "~" I "-"

(product expr):,=(RA primary)" x" (RA primary)

(projection expr)::=Fl<a.rlis, > "(" (RA primary) ")"

(attr list):.'=(attr list) (attr names) I (attr name)

(select expr):,=(select body) (select tail) I (select body)

(select body):,=O(temroratexp 0 "(" (RA primary) ")"

(temporal expr):,=(temporal expr) ORr(temporal term) I (temporal term)

(temporal term):,=(temporal term)AND r (temporal factor) [ (temporal factor)

(temporal factor):,=NOTr (temporal primary) I (temporal primary)

(temporal primary):,="(" (temporal expr) ")" [ (temporal comp expr)

Page 15: Time-based operators for relational algebra query languages

Time-based operators for relational algebra query languages

(temporal comp expr):,=(comp operand) (temporal comp op) (comp operand)

(temporal comp op):,=" = r" I " "~ r" [ "~< r" I "/> r" I " < r" I " > r"

(comp operand)::=(attr name) I (constant) I (built-in function)

(select tail)::="by" (select spec)

(select spec):,=(select spec) ";" (attr spec) I (attr spec)

(attr spec)::=(attr form) (attr spec body)

(attr form)::=(attr name) I (anr name) "." (attr delim)

(attr delim):,=INTERV I VAL I START I FINISH

(attr spec body):~=(interval spec) I (point spec)

(interval spec)::=(interval op) (interval set) I (interval op) SELECT

(interval op):,="inside" [ "outside"

(point spec)::=(point op) (integer value)

(point op)::="at" I "before" [ "after"

(interval set)::="{" (interval list)"}"

(interval list)::=(interval list) "," (time interval) I (time interval)

275

A P P E N D I X II

High Speed Implementation of the Extended Operators

The extended Boolean operators defined in this paper have been found to be amenable to efficient software and hardware implementations. In this appendix, we discuss a bitwise design approach suitable for the high-speed implementation of the generalized Boolean operators. The approach is particularly suitable for the implementation of these operators on machines that support fast bitwise vector operations. Alternatively, the approach can be used as the basis for the design of VLSI chips that are capable of yielding very high speeds. Details of the VLSI circuit design of these chips are beyond the scope of this paper. We shall illustrate our approach by discussing the implementation of the temporal AND operator. Only minor extensions will be needed to apply this approach to other operators.

Consider the expression

S AND r T

where S and T are two sets of time intervals. We shall illustrate, with an example, the computation of the value of the above expression when each of the two operands, S and T, consists of mutually disjoint intervals that are ordered in increasing time value. The solution of the general problem is also based on the approach described below but will not be covered in this appendix.

Consider the two sets

S : { (3,8), (15,20), (28,41), (44,45) }

T = { (2 ,3) , (7 ,10) , (18,22), (40,44) }

First, sort all the time points of these two sets into one master sequence, deleting any repeated elements. Let us denote the resulting sequence by Y.

Y = { 2 , 3 , 7 , 8 , 1 0 , 1 5 , 1 8 , 2 0 , 2 2 , 2 8 , 4 0 , 4 1 , 4 4 , 4 5 }

Next, if the finish point of one interval in S (or T) and the start point of the next interval in S (or T) appear adjacent to each other in Y, then separate them by inserting into Y the special symbol # . This means that we need to insert the symbol # between 41 and 44 since these two points appear adjacent to each other in Y and they are the finish point and start point, respectively, of two consecutive intervals in S. Similarly, the symbol # is inserted between 3 and 7 since these two points are adjacent in Y and they are the finish point and start point, respectively, of two consecutive intervals in T. The modified sequence Y and the corresponding indices of its elements are given by

Y = 2 , 3, # , 7 , 8 , 10, 15, 18, 20, 22, 28, 40, 41, # , 4 4 , 4 5

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

The sets S and T are then transformed into new sets S' and T', respectively, by mapping each time value to its index in the sequence Y.

S' = { (2,5), (7,9), (11,13), (15,16) } T ' = { ( 1 , 2 ) , ( 4 , 6 ) , ( 8 , 1 0 ) ,(12,15)}

The values in the above sets represent integer indices and are no longer time values. The two sets S' and T' are next transformed into two binary strings S" and T", of length 16 bits each. The j th bit in S" has the value 1 only if there is

Page 16: Time-based operators for relational algebra query languages

276 M.A. BA~IOUN! et al.

an interval (a ,b) in S' such that a ~<j ~< b. Similarly, the kth bit in T ~ has the value 1 only if there is an interval (c,d) in T' such that c ~< k ~< d, This transformation gives the following two 16-bit binary strings

S " = " 0 1 1 1 1 0 1 ! I 0 1 i I 0 1 1"

T " = " I 1 0 1 1 1 0 11 1 0 1 11 1 0"

The interval (2,5) in S', for example, generates four l's, occupying positions 2 through 5 in S". A logic bitwise AND operation is then performed on the two binary strings S" and T". In other words, the temporal AND operator can now be implemented by simply performing the logical bit-wise AND operation on S" and T". In our example, this operation produces the following 16-bit binary vector

V = " 0 1 0 1 1 0 0 1 1 0 0 1 1 0 l 0"

The vector V is next transformed into a set of intervals, say R, using the inverse of the previous logic. Translating the above string back into intervals (i.e. reversing the logic of the earlier steps), we get

R = { (2 ,2) , (4 ,5) , (8 ,9) , (12,13), (15,15) }

Finally, using the integer values in the set R as indices to the sequence Y (i.e. applying the inverse of the transformation used earlier), the set R is mapped to the following set of time-intervals.

Answer = { (3 ,3) , (7 ,8) , 0 8 , 2 0 ) , (40,41), (44,44) }

These intervals are the correct result of S ANDz T. The bitwise operation and all the transformations used in the above example can be efficiently implemented in

VLSI. The time complexity of this method is O(n + m), where n and ra are the number of intervals in the sets S and T, respectively.

About the Author--MoSTAF^ A. BASSIOUNI received his Ph.D. degree in Computer Science from the Pennsylvania State University in 1982. He is currently an Associate Professor of Computer Science at the University of Central Florida, Orlando. He has been actively involved in research on computer networks, distributed systems, concurrency control and relational databases. Dr Bassiouni is a member of IEEE and the IEEE Computer and Communications Societies, the Association for Computing Machinery, and the American Society for information Science.

About tim AUflmr--MARK J. LLEWELLYN received a B.A. degree in Political Science and a B.S. degree in Computer Science from one Indiana State University in 1981. He is currently a Ph.D. candidate in Computer Science at the University of Central Florida. His main area of research is database systems.

About the Amlor--AMA~ MuKl-mitmE (formerly Amar Mukhopadhyay) received a D. Phil. degree from the University of Calcutta in 1963. He is currently a Professor of Computer Science at the University of Central Florida, Orlando. He is a senior member of IEEE and has served as Associate Editor of IEEE Transactions on Computers. His research interests include VLSI design, hardware algorithms, parallel processing and cellular logic.