In June 1970, E.F. Ted Codd presented to the world his concept of how data should be stored. His article, A Relational Model of Data for Large Shared Data Banks, was published in the Communications of the ACM, and you can read it on the Web at www1.acm.org:81/classics/nov95/toc.html if youd like. In the early 1980s, a full 10 years later, RDBMSs began to appear, and, by the late 1980s, the transition was more or less complete. The old network, hierarchical, and inverted-list database management systems were history.
I remember reading an article during the middle 80s about another person who broke ranks with Codd and Chris J. Date (another RDBMS proponent). This associate, whose name Ive forgotten, remarked to the press that Codd and Date had sold the world on a model that was too simple for solving real-world problems. Although Ive forgotten his name, Ive never forgotten his complaint. As much as I like relational database management systems, I agree that they are not appropriate for some types of data storage. Ive been watching since then to see what other types of database models would be invented and what types of applications they would prove useful for.
Lotus Notes is one such database model that provides an alternative to the RDBMS. In this article, I compare and contrast Notes to DB2/400. I cant make an exhaustive comparison in so few words, but I hope you will at least get an idea of what Notes is about and how it differs from the RPG/CL/DDS world AS/400 programmers are so familiar with.
Structural Differences
The first thing an AS/400 programmer or manager needs to understand about Notes is that it is not an RDBMS. An RDBMS stores data in tables, or (as AS/400 programmers call them) physical files. Each table contains a set of similar entities. Data is organized into rows (records) and columns (fields). A database, in relational terms, is a collection of tables. A Notes database, on the other hand, is a collection of documents, which consist of fields. Notice that there are four levels of organization in an RDBMS but only three in Notes.
The difference in structure exists because of the difference in purpose. Notes databases are not intended to store transactional data. A purchasing agent, for example, creates a transaction called a purchase order when placing an order with a supplier. In a relational database, all purchase orders are stored in one or more tables (physical files),
which would adhere to the RDBMS rules of normalization. Although you can use Notes to create a purchase-order application, an RDBMS would most likely be more appropriate because of the transactional nature of the application. But you can use Notes to supplement an RDBMS application by automating its work flow requirements.
Notes was designed to automate work flow, and it can be used to automate the purchase-order process. Suppose a purchasing agent must get approval from other people in certain circumstances, such as spending more than a certain amount of money. Instead of passing around a piece of paper on which managers sign off, the purchasing agent could use a Notes application to get approval.
Notes was also designed with distribution of documents in mind. The replication feature allows an entire database or a subset to be copied from one machine to another and synchronizes the changes users make. For example, a Notes application might automatically send a manager (via replication) the purchase-order request documents that await his approval. When the manager changes a request document, the servers and managers replicas no longer agree with one another. When the manager next replicates, Notes copies his changes to the server and the server and workstation are once again in sync.
Yet another difference between Notes and RDBMS is in the way sets relate to one another. One of the fundamental tenets of RDBMS is the join process. For example, a purchase-order master file contains a vendor number. To find that vendors name, the programmer joins the purchase-order master file to the vendor master file. The system matches the data based on common vendor account numbers. Notes has no such capability. That is not to say that Notes database documents cannot reference one another. They can but not in this way.
The Creation Process
The AS/400 has a command-line interface, which may be supplemented with menus. To create a library, a programmer types CRTLIB, presses the F4 key, fills in the blanks, and presses Enter. Lotus Notes is a visual environment. A Notes database is created interactively. The Notes programmer points and clicks, typing as necessary, to build a database.
An AS/400 physical file is created in a batch process. A programmer keys DDS for a physical file into a source physical file member. When the programmer executes the Create Physical File (CRTPF) command, a program reads the DDS and creates a physical file. The Notes programmer interactively creates a form, in which all the fields to be contained in documents are defined. The Notes form defines the structure of the data and provides a GUI screen that can be used for editing and presenting the Notes documents in the database. Figure 1 shows a form used in a job postings database.
When CRTPF finishes, the programmer has an empty physical file in which to store data but no processing logic or infrastructure. That is, the file has no environment in which to reside. The AS/400 programmer still must create menus and write programs before users can be productive with the database.
The Notes programmer has a database in which users can store documents as well as a form by which users can maintain and query that database. It is as if CRTPF generated a work with program as part of the file-creation process.
Notes provides an infrastructure in the form of a desktop, from which users can open databases and work with them. As an alternative, Notes databases can also be accessed through a Web browser. In fact, using browsers to access Notes databases is becoming more and more common. This is where the power of Lotus Domino server comes into the picture. Domino not only serves Notes applications to Notes clients but also can dynamically translate Notes applications to HTML for use with browser clients.
The term field is commonly used in reference to DB2/400 and Notes. Like a field in a physical file, a Notes field contains only one piece of information (one datum, if you
prefer) about a document. However, this datum can be quite different from the datum in an RDBMS. Notes fields can store numbers and character strings, as one would expect, but a Notes field can also store such things as graphical data, file attachments, and OLE objects
(i.e., spreadsheets). Users can change the contents of a Notes field by keying into a form, but fields may also be computed. To get an idea of how this works, imagine that DDS had a keyword that you could use at the field level. This keyword would specify a program name. Whenever a record was written to the database or updated in the database, this program would run and the fields value would be computed. The closest DB2/400 feature is the trigger program, which works at the file level rather than at the field level.
Notes Views
A Notes view, also known as an index, is a row-and-column list of the documents in a database. It is similar to a logical file in two important ways. First, views provide different sort sequences over the documents. Figures 2 and 3 show two different views of the job postings database. In Figure 2, the documents are listed one per line and are sorted by job title. In Figure 3, documents are listed in a hierarchical view, sorted by department name. Second, a view can be made to display only selected documents. The Open Jobs view (Figure 3) shows only open postings.
When you create a database, Notes creates one view, which is organized by document number (a sequential number Notes assigns to a document when the document is created). This is similar to using Query/400 to view a physical file in relative record number order.
When you create a view, you must tell Notes how many columns the view should have and how each one gets its value. A columns values may come from a simple action (a predefined function), another document field, or a formula (similar to a macro expression in a spreadsheet).
You may sort the view on one or more columns. Sorting may be in ascending or descending order, and character sorting may be case-sensitive or not. As shown in Figure 2, you may also allow users to dynamically choose sort sequences by column within a view. The user can change the sort sequence by clicking on a column heading.
Programming Notes
To many of you who have been in this business for a while, programming is synonymous with source code. Notes supports five basic modes of programming: simple actions, formulas, LotusScript, Java, and JavaScript. A set of C APIs is also available.
RPG programmers may be interested to know that they can reference the C APIs through ILE RPG if theyre running Domino on an AS/400. IBM Rochester has posted some sample code on the Web to illustrate how this is done. If youre interested in this, point your Web browser to www.as400.ibm.com/snippets, choose Download Savefiles, and download the save file of the library called RNHLIB. FTP the downloaded file to a save file on your AS/400, then use the RSTLIB command to unpack it. Be aware that RPG IV programming will not transfer to other Notes platforms.
But I have digressed. I was about to tell you about the three basic modes of programmingsimple actions, formulas, and LotusScript.
Simple actions are predefined routines that carry out various tasks. For instance, the Copy to database function copies a document to another database. The Send document function sends a document to someone by email.
Formulas are interpreted routines that are much like macros in spreadsheets. However, formulas can execute more than one command and can contain local variables.
LotusScript is an object-based programming language that is much like Visual Basic (VB). Unlike simple actions and functions, LotusScript gives you power over all of Notes. You can write structured code, incorporating the iteration and sequencing constructs
common to modern programming languages. Through predefined classes, you can control databases, documents, and fields.
Notes is not the only software product that uses LotusScript. Most Lotus products, as well as some third-party products, also support Lotus-Script. This means that a programmer who knows LotusScript can develop software to integrate different software products. LotusScript is actually a subset of VB, so much of the syntax and language functions you learn to use in LotusScript can be used in Microsoft VB-based development.
Notes provides an Integrated Development Environment (IDE) with which you can develop and debug LotusScript routines. This IDE provides three panes: the Design pane, the Debug window, and the Utility pane. The Design pane is the one in which you type LotusScript source code. The other two are visible only when you are debugging.
Programming can be placed behind many different types of components. For example, you might attach a formula to a field of a form to tell Notes to capitalize everything keyed into the field. If a user typed hr, Notes would change it to HR. Or you might place a button on a form. When the user clicks on the button, Notes saves and closes the document.
Agents and Actions
As you learn more about Notes programming, you will run into agents and actions. These are miniprograms that are more or less identical in structure but different in purpose. Both actions and agents support simple actions, agents, and scripts.
Actions are confusing because Notes uses the term action in two different ways. I alluded earlier to simple actions, predefined routines that you can take advantage of. Actions (without the adjective simple) are something else. Actions can run simple actions. This is called a simple action action. Have I confused you?
The main difference between actions and agents is this: Actions are usually executed on a client machine at a users request (e.g., by clicking a button). On the other hand, agents most often run on a server machine in response to an event, such as creating a document or clicking an Action button.
On the AS/400, security is based on user profiles. System administrators create user profiles and tell the system which objects each user can or cant use. Notes uses a similar scheme but uses the term user ID. The user ID is stored in a file, which must be on an available disk when Notes is started. If your user ID is SMITH, Notes will look for a file called SMITH.ID. If it cant find the file, Notes presents a window that asks you to specify the file to be used for the current user ID. Its probably most convenient for you to keep your user ID on your workstation, but, for added security, you might prefer to keep it on a diskette, which you can store in a safe place when you arent using Notes. The user ID file contains a lot of information, including information about the user, public and private encryption keys, and certificates (electronic stamps that give you access to Notes servers).
Security is further defined via the Access Control List (ACL), which specifies which users can do which tasks. Some tasks that the ACL can control are creating, deleting, reading, and writing documents; creating agents and views; and creating agents in LotusScript or Java. Each database has its own ACL.
Security can also be further defined at the form and even the field level.
Notes Does the Job
I have been a user of Notes for a few years (weve been using Notes at Midrange Computing to manage articles as they work their way through the editorial process). Notes does a good job, and I would hate to try to use RPG to duplicate what Notes does for us.
I hope this whirlwind tour of Lotus Notes has been helpful to you. As I have begun to learn to develop Notes applications, Ive learned what I already knew: Most everything
Security
is just new ways to do the same old things. I know several RPG programmers who have learned to develop in Notes. If they can do it, so can you and I.
REFERENCES AND RELATED MATERIALS
A Relational Model of Data for Large Shared Data Banks, E.F. Codd, Communications of the ACM, June 1970. Reprinted in Communications of the ACM (Web Edition), November 1995, ww1.acm.org:81/classics/nov95/toc.html.
IBM Code Snippets Web site: www.as400.ibm.com/snippets
Figure 1: Notes documents are defined though their data entry forms.
Figure 2: Views are similar in concept to logical files.
LATEST COMMENTS
MC Press Online