A. Hunter*
R.I. Ferguson
S. Hedges
Swoop is a software package designed to support the generation and maintenance of WWW information systems which store information in an ORACLE database. In these hybrid systems (which we refer to as hyperbases), information from a relational database is merged into hypertext documents for presentation.
The World Wide Web has facilities which make the provision of hyperbases possible. The basic capability of WWW is to download text files via hypertext links. Dynamic documents [1] are programs which can be invoked in place of a document download, and generate the text as output; a suitable program can hence extract information from a database and present it as HTML. The Forms interface, available using CGI [2] , allows Web-pages to be built which include user-interface elements such as fields, buttons and check-boxes: this can be used to provide user-input to dynamic-document pages.
Hyperbase programs may be presented to the user in two ways. First, the user may browse what appear to be normal web pages, with no Forms interface, although the pages are actually being dynamically constructed from the database. Second, the user may be presented with Forms which generate input: for example, to specify key-words to be used in searches. Forms could also be used to present output, although this is rarely done: most hyperbase programs present the results of searches as simple hypertext.
The biggest problem with hyperbases is that they require a sophisticated program to interpret Forms, query appropriate databases, and merge information into Hypertext. There is a clear need for application-generator tools which allow hyperbase programs to be constructed with minimal expertise on the part of the designer.
Swoop supports the construction of hyperbases using an ORACLE database as a back-end. Information is presented to the user as simple hypertext pages; these pages are specified using a simple augmented HTML syntax. It also has facilities to aid in maintenance and specification of the database. Swoop provides a single, integrated solution to the generation of hyperbase systems.
Swoop has the following major components:
Swoopgen. This is an application generator which produces dynamic page programs from special augmented HTML files called swoop-files. Swoop files can include embedded pieces of SQL, the standard language for accessing Relational Databases [3]. The SQL inserts in swoop-files corresponds to points where information extracted from the database should be merged into the page. A tool called swoopgen translates these special swoop-files into PRO*C programs (PRO*C is ORACLE's pre-compiler to support embedded SQL statements within the C programming language), which when compiled act as dynamic page programs which will extract information from the database and present it merged into hypertext, as specified by the swoopfile. Thus, the system-designer using swoop needs only a rudimentary knowledge of ORACLE and HTML.
swoopform. Whereas swoopgen tool provides the facility needed to support browsing of the merged HTML/ORACLE pages, swoopform supports database maintenance. It provides a Forms-based interface which allows information to be Queried, Added, Updated and Deleted from tables in the Swoop database. It is provided primarily for the use of the system-maintainer, rather than system users, although in practice it has also been found useful for supporting limited user-input. swoopform can automatically produce a form for any Swoop table.
Figure 1: Major Swoop system components
This section discusses the format of swoop-files, and how they can be used to produce interlinked sets of Web pages.
To illustrate the discussion, a simple case study will be used: a system to track members of staff at an academic institution. It includes:
Table: staff
code name dept tel additional GK Khan CIS 0225 Not to be argued with. AH Hunter CIS 2778 Likes writing <i>software</i>! SG Garrick ENG 3425 Hands-on worker. CP Porter ART 2345Table: dept
code name head CIS Computing GK ENG Engineering ATHFigure 2: Departmental database
Figure 3: HTML required to present staff telephone listing.
Figure 4: Swoop-file source for tellist
In the example above, the name and telno columns are required, so swoopgen will construct the following SQL statement: select name, telno from staff order by name;
The values retrieved from the database by the program will be inserted in place of the sql variables at run-time.
$repeat$ ... $endrepeat$ statements can be used to produce repeated sections of HTML if the SELECT statement is expected to return more than a single row of information (as is the case here). If an sql variable is encountered outside $repeat$ ... $endrepeat$ statements, then it is assumed that only a single value will be returned, and only the first value returned is shown.
Swoop file for homepage:
$sql staff where code = arg-0 $
$sql staff s, dept d where s.code = arg-0 and s.dept = d.code$
<title>Home Page for $name:0$</title>
<h1>Home page for $name:0$</h1>
<hr>
<i>Code number:</i> $code:0$<p>
<i>Department:</i> <a href="dept?$d.code$">$d.name:1$<p>
<hr>
<h2>Additional information</h2>
$additional:0$
<hr>
Sample HTML output by homepage:
<title>Home Page for Hunter</title>
<h1>Home page for Hunter</h1>
<hr>
<i>Code number:</i> AH<p>
<i>Department:</i> <a href="CIS">Computing<p>
<hr>
<h2>Additional information</h2>
Likes writing <i>software</i>!
<hr>
Figure 5: Using arguments in Swoop-files.
To access the individual home pages from the telephone list, we can modify tellist to include URLs which invoke homepage, passing the staff code as a parameter. Figure 6 shows an updated version of the tellist swoop-file, and resulting HTML output, which contains links to each home page.
Swoop-file:
$sql staff order by name$
<h1>Telephone Listing</title><hr>
$repeat$
<a href="homepage?$code:0$">$name:0$</a>, $telno:0$<p>
$endrepeat$
HTML generated:
<title>Telephone Listing</title>
<h1>Telephone Listing</title><hr>
<a href="homepage?AH">Hunter</a>, 2778<p>
<a href="homepage?SG">Garrick</a>, 3425<p>
<a href="homepage?GK">Khan</a>, 0225<p>
<a href="homepage?CP">Porter</a>, 2345<p>
Figure 6: Swoop-file with hypertext links
The second select statement in the homepage swoop-file (see Figure 5) is used to get information about the user's department (specifically, its name rather than its code) from the department table, using a JOIN condition to ensure that the department corresponding to this particular person is located. In the case of Porter, this statement will not find any information, since Porter's department (ART) is missing. Swoop will simply leave the department blank in this case. The department is also further hyper-linked to the dept page, which is listed in Figure 7.
Swoop-file for dept dynamic page.
$sql dept where code = arg-0 $
$sql staff s, dept d where d.code = arg-0 and s.dept = d.code and
s.code = d.head $
$sql staff where dept = arg-0 order by name$
<title>Department: $name:0$</title>
<h1>Department: $name:1$ ($arg-0$)</h1>
<hr>
<i>Head of department:</i> $s.name:1$<hr>
<h2>Staff</h2>
$repeat$
<a href="homepage?$code:2$">$name:2$<p>
$endrepeat$
<hr>
Sample HTML output:
<title>Department: Computing</title>
<h1>Department: Computing (CIS)</h1>
<hr>
<i>Head of department:</i> Khan<hr>
<h2>Staff</h2>
<a href="homepage?AH">Hunter<p>
<a href="homepage?GK">Khan<p>
<hr>
Figure 7: dept swoop-file and output
The interlinking of pages in this fashion is typical of Swoop, which can thus implement interfaces to quite complex database structures with minimal effort. Many hyperbase programs tend to concentrate on a particular, simple approach to structuring the search space, in order to reduce programming complexity. Swoop reduces that complexity to a level no worse than that encountered in any database system design problem.
Swoop also provides a facility to support table maintenance via WWW: swoopform. Swoopform is a program which generates a CGI Form containing fields for each column in a table. The form may be used to create new rows, to update or delete existing ones, and to search for existing rows using a query. The table to be queried is passed as a parameter when swoopform is invoked. Since all the tables known to swoop are themselves described in a special table, it is a trivial matter to produce a swoop-file for swoopgen which generates a list of all tables, with hypertext links to swoopform for each - such a swoop-file is provided with the Swoop system. Thus, the maintainer automatically has access to Forms-based facilities to maintain all Swoop tables. The downside of this powerful automatic facility, is that swoopform is not configurable - it always presents a Form in the same fashion, which can be used solely to update a single table.
Swoopform has the following features:
Although ORACLE maintains a great deal of information about individual tables, not all of it is easily retrieved, and there are some additional pieces of information (for example, the prompts used for fields on swoopform) which ORACLE doesn't support. Swoop therefore maintains two auxiliary tables in the database: SWOOPTABLES and SWOOPCOLUMNS. The information in these two tables must correspond to the profile of the tables accessed by Swoop. To make this correspondence simple to maintain, the Swoop distribution includes two scripts which create and delete swoop tables. The createhtmltable script takes as an argument a file name; the file may include a number of Swoop Create statements, which are essentially augmented SQL Create statements. The deletehtmltable script takes as an argument a table name, and deletes both the table and any references to it in the Swoop auxiliary tables.
Further details on the Swoop maintenance utilities can be found in the Swoop source distribution.
It is sometimes difficult, on first reading, to tell the exact purpose of an SQL statement (because it is effectively scattered through the swoop file).
If complex compound variables are to be fetched (e.g. SUBSTR(NAME,0,1) to extract an initial from a forename) then these must be included as variable tags, and are difficult to read.
The DISTINCT clause, which comes at the beginning of the SQL statement, necessitates an additional tag $sql_distinct ...$.
The approach taken was adopted because it precludes any need to parse the SQL statement: the construction of a prefix is relatively easy. A better approach would be to augment the SQL SELECT statement with tag names, and to remove these using a parser if necessary:
$sql select distinct d.name, substr(s.name,0,1) into dept, init from dept d, staff s where d.code = s.dept$
-
is translated into the SELECT statement:
select distinct d.name, substr(s.name,0,1) from dept d, staff s where d.code = s.dept;
- and the tag variables $dept:0$ and $init:0$ refer to the first and second columns fetched respectively.
<sql select="<select statement>">
<sql repeat>
<sql endrepeat>
<sql variable="<variable name>">
If you need anonymous ftp to download it, you have no use for it anyway!
1. Ford, A. Spinning the Web, International Thompson, p.143.
2. McCool. Web document, http://hoohoo.ncsa.uiuc.edu/cgi/index.html
3. Sturner, G. ORACLE 7: A User and Developers Guide, Van Nostrand Reinhold.
4. OWWWIK. The Oracle World Wide Web Interface Kit, http://dozer.us.oracle.com:8080/index.html
5. WOW. The WOW Gateway, http://dozer.us.oracle.com:8080/sdk10/wow/
6. Decoux. The Decoux Gateway, http://dozer.us.oracle.com:8080/sdk10/decoux/
7. Ocrainets. The WORA Gateway http://dozer.us.oracle.com:8080/sdk10/wora/
Dr. Andrew Hunter
cs0ahu@sunderland.ac.uk
http://osiris.sunderland.ac.uk/ahu/home.html
Department of Computing and Information Systems, University of Sunderland, England.
Andrew Hunter is a Senior Lecturer, with interests in Genetic Algorithms,
Neural Networks, and Interactive Software. He produces the
http://osiris.sunderland.ac.uk/rif/welcome.html
Department of Computing and Information Systems, University of Sunderland, England.
Ian Ferguson is a Senior Lecturer with interests in Object Oriented software and the Internet.
Mr. Steven Hedges.
steve@maxx.co.uk
http://www.iisl.co.uk/
Internet Information Services, Ltd, 498 Dereham Road, Norwich, NR5 8TU,
England.
Steven Hedges runs IISL, a WWW training and consultancy service.