Joe Celko's Data and Databases: Concepts in Practice
By Joe Celko
Chapter 8: Logic and Databases
Chapter 8: Logic and Databases
Overview
Logic in Western thought started with Aristotle and pretty much stayed there until the 1800s. Logic was considered a branch of philosophy until George Boole wrote his book An Investigation of the Laws of Thought in 1854 and introduced the idea of ?mathematical logic? as opposed to ?philosophical logic.? In the Dewey decimal system, logic still appears under philosophy, although virtually no philosophical logic books have been written in over a century. In this chapter, we will look at several different systems of logic that can be used with a database.
Although most programmers think that they know formal logic from writing program control structures (i.e., IF-THEN-ELSE , WHILE-DO , and so forth) in procedural languages, their logic skills are really pretty weak, and they do not realize how much they depend on the temporal aspect of their languages to hide what would have to be complex declarative statements.
This is the big difference: logic in an SQL database is declarative, while logic in a procedural programming language is for sequential control. That is, SQL?s logic makes a general descriptive statement about the state of the data, while logic in a procedural programming language makes decisions about actions to be taken on one unit of data at a time, not a whole set.
In theory, anything that can be written in a procedural language (i.e., finite deterministic automata) can be written in a nonprocedural language (i.e., primitive recursive functions). I will give...
Copyright Morgan Kauffmann Publishers 1999 under license agreement with Books24x7