By ERIC SHERMAN*

 

Data are disorganized pieces of information. A database is created so data can be collected, placed within a logical framework, preserved, and then easily modified, manipulated and retrieved. The key to effective information management is the structure within which it is recorded. Relationships among data must be understood and information then stored to reflect those relationships.

Traditionally, data have been recorded in an inflexible and impractical manner. Design changes are needed to capture new kinds of data, records are processed one at a time, keying errors occur due to multiple entry, and synchronizing changes is difficult because records are often stored in multiple locations. Data are trapped in the computer until a programmer creates a report to release them.

Oracle employs a relational model that provides structural stability, uses programs that work with sets of data, and allows programmers and business managers to work together to produce applications that closely match the needs and work habits of a company. With Oracle, information is instantly accessible simply by typing an English query.

Oracle stores data in tables containing columns and rows, as you would see on the back of a baseball card or in the weather report published in a newspaper. Consider the following table:

WEATHER

City

Athens
Chicago
Madras
Manchester
Paris
Sydney

Temperature

87
67
75
67
81
29

Humidity

72
94
71
98
62
48

Condition

sunny
rain
cloudy
fog
sunny
snow

If you were asked to select the city from the weather table where the humidity is 71 you would respond "Madras." If asked to list alphabetically those cities where it is sunny, you would respond "Athens and Paris." Oracle employs a language called structured query (SQL) that can answer these questions in the same way. The sql statement

select City from WEATHER where Humidity = 71 would yield the result: Madras.

Similarly, the statement

select City from WEATHER where Condition = sunny would produce: Athens Paris.

These statements are very simple examples of a methodology that can become quite powerful as layers of complexity are added.

A good way to understand relational theory is to apply it to the issue of table organization. Three questions are raised in this context:

1) what data will be collected and how will they be organized, i.e., what columns and rows will be placed in which tables?

2) what can be used to uniquely identify each row of data within a table? [Without this, location and retrieval is impossible.]

3) how can data be retrieved most efficiently?

 

The central issue in any database system is, "what questions or changes concern you," i.e., what information do you want to retrieve or alter? An answer may at first appear to be rather obvious, but this process is often approached haphazardly, without proper attention to the relationships among data. Every industry, market and individual company has characteristics which should be taken into account in a database design. This is a major strength and demand of a relational system - it permits and requires careful planning to achieve optimal results.

Tables in a relational database must be "normalized." This means first that logically connected data must be grouped together and second, that a "primary key" upon which all data in the table are solely dependent must be established. A primary key is a column (or set of columns) that distinguishes each row in a table. Every row in a table has a value in the primary key that is different from that of every other row in the table. Typical examples of primary keys are social security numbers and product or customer identification numbers - using names is risky because of possible duplication. In many cases, a table's primary key consists simply of a series of sequentially assigned meaningless numbers. Values in a primary key act as "handles" by which you can locate and act upon data.

In order to speed up data retrieval, sql uses indices. Indices typically are listings of keywords accompanied by locations of information on a subject. For example, if you wanted to examine a topic dealt with in a book, you would find it more quickly by looking it up in an alphabetical index than by reading the entire text. Sql indices work in the same way. Let's say your database contains international weather reports for dozens of cities recorded daily over a period of years. If you wanted to select the cities that most frequently met a specified set of criteria (e.g., sunny with temperatures between 70 and 80 degrees and humidity below 70% (hey, quit daydreaming!), it would require a considerable amount of processing time for your computer to search all the records required to make this determination. By indexing your tables, you allow your computer to find what it's looking for much more quickly. In this example, it would focus on those cities that frequently came close to meeting the established criteria, just as you would move to your desired topic in an alphabetical index.

Indices are most useful on large tables and on columns with a significant amount of variety in their data. Unless a column has differing values present in many of its rows, read minimization (time saved) is inadequate. For a large weather table, columns like city, temperature and humidity should be indexed, condition probably not. If you wanted to create an index for the condition column, you would need to introduce two things - greater differentiation and some logical means of relating conditions, e.g., a scale from 1 to 30, where 1 represents idyllic sunshine and 30 represents a category five hurricane. (Columns containing Boolean data, e.g., yes/no, true/false, male/female, should never be indexed.)

To summarize, Oracle offers an easy and effective means of collecting, organizing and recording data which can then be acted upon, e.g., mathematically "computed." In the next section, the sql commands and other elements used to accomplish these tasks will be discussed. This is followed by a quick review of the Oracle extension (sqlplus) used to format output into presentable reports and compile programming code. Finally, after an exercise demonstrating the use of these techniques, the programming language (pl/sql) developed by Oracle to offer greater control of computing processes will be examined.


 
*This document attempts to summarize material published by Oracle and is not represented as original thought.