Geography Reference
In-Depth Information
Getting Information from a Relational Database: Queries
Relational databases are designed to give you information. You can obtain the information by selecting
a subset of records from the total set by writing an expression that is a mixture of attribute names,
arithmetic and logical operators, and values. 23 For a trivial example, suppose that research has found that
gray cars that weigh less than 2500 pounds put their occupants in greater risk than average. You want to
select those records from the statewide automobile database. You might first get all the records of the cars
that are gray.
SELECT: COLOR = 'Gray'
Given that subset, you might then write
SELECT: WEIGHT < 2500
Given this sub-subset of records, you could perhaps write letters to the owners of those cars, making
them aware of the danger they face.
Languages to get subsets of records can provide flexibility and efficiency. For example, to do both of the
preceding operations with one expression, you might write
SELECT: COLOR = 'Gray' AND WEIGHT < 2500
Suppose also that the research study showed increased danger to those occupying cars that were built in
1985 or before, regardless of color or weight. You might add to the preceding selection by saying
ADDSELECT: YEAR <= 1985
(ADDSELECT means add to the current set of selected records.)
Or you may use a single query to select all the records you want at once:
SELECT: (COLOR = 'Gray' AND WEIGHT < 2500) OR YEAR <=1985
Note the use of parentheses to indicate the order in which operations are done.
Economies in Relational Databases
In theory, the information in a relational database system could reside in a single table. This isn't the best
policy and in reality may not even be possible. A relational database usually consists of a set of tables that
relate to one another—thus, the word “relational.”
Each relational database table must contain a column that has a unique identifier for each record in the
table. This is known as the key field . If the relational database references people, the key might be Social
23 There are many relational database software products and several different languages used to query them. What is
shown in the following is not a specific query language but rather a generic representation of such a language. ArcGIS
may be used with several relational database products, each with a somewhat different query language.
 
Search WWH ::




Custom Search