Homework 6: Object-Relational Database Systems - SQL:1999 (SQL3) Abstract Data Types (ADT's) *
|
-
Define a "PC" abstract data type whose objects represent personal
computers, including processor speed, RAM, hard-disk drive, CD speed,
and price.
- Write the following functions for your ADT above, using the
extended SQL for internal functions:
-
A constructor function called newPC that takes values for the five
attributes of the PC ADT and returns a new object of that type. Use
the built-in constructor PC() to define this function.
-
A function value that takes a PC object as argument and returns an
"evaluation" of the PC, which is a real number telling how "good" the
PC is. The formula for the "value" of the PC is the processor speed
plus 4 times the RAM (in megabytes), plus 40 times the hard disk (in
gigabytes), and 10 times the speed of the CD.
-
A function better that takes a PC object as argument and returns another PC
object with twice the processor speed, RAM, hard disk, and CD speed,
and the same price. You may use the constructor newPC from part (a).
-
A function equalPC that serves as the
equality for
objects. This function reports two PC's are "equal" if they have
the same speed, same RAM and hard disk size, regardless of the value of the
other components.
-
A function ltPC that serves as the
less-than function for the ADT PC. This
function finds
p1 < p2 if the "value"
of PC p1
is less than that of PC p2, where "value" is as defined
in part (b). You may use the function value defined in part (b).
(*) Adapted from Ullman & Widom, A First Course in Database Systems,
Prentice-Hall, 1997, pp. 456-457.
D. S. Kerr
February 18, 2002