Database App Assignment: Storing Shipment Info with Oracle & PostgreSQL APIs, Assignments of Principles of Database Management

This assignment asks you to build a small database application using oracle and postgresql apis for storing information about shipments being made by a packaging delivery company. The goal is to gain experience in using application programming interfaces and learn the required details such as linking libraries and makefiles. The submission should produce two executable files.

Typology: Assignments

Pre 2010

Uploaded on 02/13/2009

koofers-user-v0s
koofers-user-v0s 🇺🇸

5

(1)

7 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CMSC 424{0101 Fall 2001 PHW02 (100 pts) Due Tue, 18 Sep 2001
c
Sudarshan S. Chawathe 2001
Name:
Submission le name:
(Fill in the above information on a hardcopy of this document and submit it at the beginning
of class on the due date. See below for details.)
This assignment asks you to build a small (toy) database application for storing infor-
mation about shipments being made by a package delivery company (e.g., UPS). The goal
is to gain experience using an application programming interface (API) to Oracle and Post-
greSQL. Transforming the following specication into an application and learning all the
required details (e.g., linking libraries, Makeles) are important parts of this assignment.
As described in detail in the packaging instructions below, your submission should pro-
duce two executable les. The rst, called
shipperO
should implement this application using
Oracle to store data. The second, called
shipperP
, should be identical in behavior to ship-
perO; however, it should use PostgreSQL to store data. You may use either the C/C++
interface described in Chapter 3 of the Oracle8 textbook, or a Javainterface (JDBC or
SQLJ). You may also use any other interface of your choice (e.g., Perl DBI); however, you'll
have to install any additional software you need yourself. Reminder: Please start working
on this assignment early; use the newsgroup for questions and clarications.
Since wehaven't studied schema design methods yet, we will, for now, store all the
necessary information in a single table called
Shipments
. This table should have one column
for each of the following attributes: sender's name, sender's address, sender's phone number,
sender's accountnumber, recepient's name, recepient's address, recepient's phone number,
recepient's accountnumber, pickup date and time, promised delivery date and time, action
code, and weight (in pounds). The action code is a short string that may contain values such
as \forward to station MD103" and \undeliverable; return to sender." The semantics for
the other columns should be evident from their names. Pick suitable types for each column.
Note that the pickup date and time is a single attribute, as is the promised delivery date
and time. The types you choose should be neither too restrictive nor too p ermissive. For
example, do not assume that phone numbers are in U.S. standard form; they maybeany
alphanumeric string (e.g., 1-800-GET-RICH, 1.91.22.555.HELP). On the other hand, do not
store dates and times as strings.
You must implementyour application program as a Unix command-line program that
reads from standard input and writes to standard output. This application must implement
the user functions described below. When the work (both internal processing and output to
user) for each function is done, your application should write (to standard output) ve dashes
(
-----
) followed by a single newline character. We will refer to this string of ve dashes
followed by a newlne as the
function termination string
. The following description also refers
to a
separator string
, which consists of the three character sequence space-colon-space.
These functions will be invoked from standard input by listing the function name followed
by its arguments, one per line. For example, the
connect
function described below takes two
1
pf3
pf4
pf5

Partial preview of the text

Download Database App Assignment: Storing Shipment Info with Oracle & PostgreSQL APIs and more Assignments Principles of Database Management in PDF only on Docsity!

CMSC 424{0101 Fall 2001 PHW02 (100 pts) Due Tue, 18 Sep 2001 c (^) Sudarshan S. Chawathe 2001

Name:

Submission le name: (Fill in the ab ove information on a hardcopy of this do cument and submit it at the b eginning of class on the due date. See b elow for details.) This assignment asks you to build a small (toy) database application for storing infor- mation ab out shipments b eing made by a package delivery company (e.g., UPS). The goal is to gain exp erience using an application programming interface (API) to Oracle and Post- greSQL. Transforming the following sp eci cation into an application and learning all the required details (e.g., linking libraries, Make les) are imp ortant parts of this assignment. As describ ed in detail in the packaging instructions b elow, your submission should pro- duce two executable les. The rst, called shipperO should implement this application using Oracle to store data. The second, called shipperP, should b e identical in b ehavior to ship- p erO; however, it should use PostgreSQL to store data. You may use either the C/C++ interface describ ed in Chapter 3 of the Oracle8 textb o ok, or a Java interface (JDBC or SQLJ). You may also use any other interface of your choice (e.g., Perl DBI); however, you'll have to install any additional software you need yourself. Reminder: Please start working on this assignment early; use the newsgroup for questions and clari cations. Since we haven't studied schema design metho ds yet, we will, for now, store all the necessary information in a single table called Shipments. This table should have one column for each of the following attributes: sender's name, sender's address, sender's phone numb er, sender's account numb er, recepient's name, recepient's address, recepient's phone numb er, recepient's account numb er, pickup date and time, promised delivery date and time, action co de, and weight (in p ounds). The action co de is a short string that may contain values such as \forward to station MD103" and \undeliverable; return to sender." The semantics for the other columns should b e evident from their names. Pick suitable typ es for each column. Note that the pickup date and time is a single attribute, as is the promised delivery date and time. The typ es you cho ose should b e neither to o restrictive nor to o p ermissive. For example, do not assume that phone numb ers are in U.S. standard form; they may b e any alphanumeric string (e.g., 1-800-GET-RICH, 1.91.22.555.HELP). On the other hand, do not store dates and times as strings. You must implement your application program as a Unix command-line program that reads from standard input and writes to standard output. This application must implement the user functions describ ed b elow. When the work (b oth internal pro cessing and output to user) for each function is done, your application should write (to standard output) ve dashes (-----) followed by a single newline character. We will refer to this string of ve dashes followed by a newlne as the function termination string. The following description also refers to a separator string, which consists of the three character sequence space-colon-space. These functions will b e invoked from standard input by listing the function name followed by its arguments, one p er line. For example, the connect function describ ed b elow takes two

arguments and may b e invoked as follows (using example values for the arguments):

connect sc xyzzy

String arguments will b e listed verbatim, with no quotes or other demarcation. You may assume that function arguments do not contain any newline characters. Numeric data will b e listed in a format 123.45. (That is, numb ers are rounded to two places after the decimal p oint and there are as many digits b efore the decimal p oint as are needed, with no 0-padding.) You may assume that all numb ers are in the range [ 10 ; 000 : : : 10 ; 000], with at most two digits after the decimal p oint. Date-time values are in the format YYYY-MM-DD HH-MM-SS. For example, 2001-05-0 4 14-01-03 denotes three seconds past 2:01pm on the 4th of May,

The input will contain, in general, several function calls in the ab ove format, listed one after the other. Your program should ignore lines with # (p ound sign) as the rst character. It should also ignore blank lines, but blank lines separating function invo cations are not required. Since you know the numb er of arguments each function takes, there is no need for such separation. (Note that the function termination string is used only for output, not in the input.) Your application should read and pro cess the functions in the order in which they app ear in the input and should terminate gracefully (e.g., by closing op en database connections) when the end of input is reached. There is no sp ecial end-of-input marker.

connect(fo o, bar): This function will b e the rst one invoked in any test run, and it will b e invoked exactly once p er run. In resp onse, your application should p erform all necessary initialization and connect to the Oracle server as user foo using password bar. We will test your program using a temp orary account foo that is not your class account. You may assume that the database for account fo o initially contains no user tables. Make sure you do not assume anything sp eci c to your own class account. For example, you cannot rely on any initialization you have in your .login or .tcshrc les, since these les will not b e the same for the test account. Please b e sure to understand the implications of this requirement. Creating co de that can b e easily run by someone else is an imp ortant part of this homework. For testing, you should use your own account name and password in place of foo and bar. (Hint: You should test your submission by temp orarily replacing your customized account les, if any, with the default ones that came with your account.)

createTable() This function should result in the creation of the Shipments table describ ed ab ove. This function will b e called b efore any of the functions b elow.

destroyTable() This function should result in the Shipments table and all its contents b eing destroyed. The database should now b e in its initial pristine state (with no user tables). You may assume that after this function is called, a call to createTable will precede a call to any of the functions describ ed b elow.

consisting of the matching phone numb er and the corresp onding SID. The output records should b e sorted in ascending lexicographic order by phone.

searchBySenderAcct(fo o): This function should search for records with sender account numb ers that have fo o as a pre x (case insensitive). For each match, there should b e a line of output consisting of the matching account numb er and the corresp onding SID. The output records should b e sorted in ascending lexicographic order by account numb er.

searchByRecepient... You should implement four more functions, searchByRecepi- entName, searchbyRecepientAddr, searchByRecepientPhone, and searchByRe- cepientAcct, with semantics analogous to searchBySenderName, searchbySenderAddr, search- BySenderPhone, and searchBySenderAcct, resp ectively.

searchByPickupRange(fo o, bar): This function searches for records with pickup date- times no earlier than fo o and no earlier than bar. The arguments fo o and bar are date-time sp eci cations in the format describ ed earlier. For each matching record, there should b e a line of output that lists the matching pickup date-time and the SID of the corresp onding record.

searchByPickupExpr(fo o) This function p erforms a wildcard-based matching on the pickup date-time eld. The search parameter (fo o) will b e of the form YYYY-MM-DD HH-MM-SS, which is the format we've describ ed earlier for date-time elds. However, in this function zero or more of the comp onents (YYYY, MM, DD, HH, MM, and SS) may b e the sp ecial wildcard *, denoting a \don't care." Thus, searching for -01-2001 -- should list records with a pickup date-time that is b etween 2:00:00pm and 2:59:59pm (inclusive) on som day in January

searchByDeliveryRange and searchByDeliveryExpr: These two functions are analo- gous to searchByPickupRange and searchByPickupExpr, resp ectively, searching the promised delivery date-time eld instead of the pickup date-time eld.

up dateActionCo de(fo o, bar): This function should assign the action co de bar to the record with SID fo o. If such a record do es not exist, the function should not p erform any up date (but not ag an error). This function should pro duce no output other than the function termination string.

deleteRecord(fo o) This function should delete the record with SID fo o. If such a record do es not exist, the function should not p erform any database mo di cations (but not ag an error). This function should pro duce no output other than the function termination string.

Submission: The submission pro cedure (including le naming convention) is similar to the one used for the rst homework, PHW01.

Packaging You must submit a gzipp ed tar le containing the source les (not ob ject les or machine co de) required to compile and run your program. The le should b e named foo.tar.gz (where fo o is replaced with something like HendrixJM-1101, as describ ed in PHW01). Unzipping and untarring fo o.tar.gz should result in the creation of a single di- rectory (in the current working directory) called phw02. Typing make at the Unix shell prompt in the phw02 directory should result in the complete compilation of your program, pro ducing two executable les (machine co de, shell script, Perl script, etc.) called shipperO and shipperP, for the Oracle and PostgreSQL implementations, resp ectively. Obviously, you will need to include a Make le in the phw02 directory. You should also include a short README le describing the les in your submission. This README le is a fallback. If your program do es not work p erfectly, we will lo ok at the README le and if it is wel l written and includes some special instructions we will try to get your program working by following these instructions. Please test very carefully that this unpacking and compilation pro cedure works with your submission. Your score will su er greatly if it do es not, or if your submission contains ob ject les or machine co de. (If you use Java, submit the .java les, not the .class les; your make le should b e designed to pro duce the .class les. The make pro cedure should also result in a executable les that run the Oracle and PostgreSQL versions of the application, p erhaps by calling \java classname.") Recap: The sequence of commands gunzip foo.tar.gz; tar xf foo.tar; cd phw02; make should result in the nal executables shipperO and shipperP.

Test Input You may wish to use this sample input to test your program by replacing dummyAcct and dummyPassword with your own account name and password. (You should test your work thoroughly by generating test inputs that exercise all the functions ab ove.) Note that spaces are signi cant in string arguments (e.g., passwords, comments) and should not b e ignored or mo di ed. For clarity, the following uses to denote the space character. There is a newline character at the end of each input line.

connect dummyAccount

This line should be ignored

dummyPassword createTable

We may destroy and create the table repeatedly...

destroyTable createTable

The above blank line and the one following add should be ignored.

add

Jane Q. Public 1600 K St NW, Suite 1 01, Washington, DC. 202.111.23 23 DC01X29a