Conditionals - sql, PL-SQL Programming

Conditionals - SQL

At first sight SQL does not appear to have a single operator for expressing logical implication. In this respect it would be in common with most programming languages, including Tutorial D. However, standard SQL defines a partial ordering for its three truth values, under which false is deemed to precede true. Thus, the comparisons p < q, p > q, p <= q, and p >= q are all supported in standard SQL (in addition to p = q, of course).

it is noted that in 2VL p → q is equivalent to ¬ p ∨ q. Study of Figure 3.5 reveals that ¬ p ∨ q does indeed equate to p → q when neither operand is unknown, and the same is true of p <= q! (It is the pronunciation, "is less than or equal to", rather than "implies", that led to my observation that SQL appears to include direct support for a 3VL form of implication by accident.)

1570_Conditionals - SQL.png

Figure: The SQL Truth Tables for ¬ p∨ q and p <= q

Note, however, that p <= q is not equivalent to ¬ p ∨ q. Intuitively, we understand that "p implies q" is true whenever q is true. This holds for ¬ p ∨ q but not for p <= q, as the row for p = U and q = T shows. The U in the last column for that row arises from SQL's general rule that whenever an operand of a comparison is NULL, the result is unknown-and NULL, when it is the result of evaluating a Boolean expression, is considered synonymous with unknown. In fact, Figure gives a demonstration of the fact that SQL is not always faithful to its own concept, that NULL represents "a value exists here but we don't know which value". What U really means when it appears in the column for p <= q is that <= is undefined for that particular pair of truth values.

Posted Date: 1/18/2013 4:16:23 AM | Location : United States







Related Discussions:- Conditionals - sql, Assignment Help, Ask Question on Conditionals - sql, Get Answer, Expert's Help, Conditionals - sql Discussions

Write discussion on Conditionals - sql
Your posts are moderated
Related Questions
Oracle 11 G new features associated with this release:- Enhanced ILM  - Information Lifecycle Management (ILM) has been around for the almost 10 years, but Oracle has made

Use of Table Comparisons - SQL Table comparisons where it is noted that although table expressions cannot be compared, we have TABLE (t) to convert a table expression t into

Initializing Objects: Till you initialize an object by calling the constructor for its object type, the object is automatically null. That is, the object itself is null, not me

Example of EXCEPT Operator - SQL Example, like its counterpart in the theory book, illustrates the convenience of allowing any table expression to be the source for an INSERT

Predefined Exceptions The internal exception is raised implicitly whenever your PL/SQL program exceeds a system-dependent limit or violates an Oracle rule. Each & every Oracle

PL SQL Code Review HEADER ELEMENTS File Name Clear, meaningful and descriptive about main objective of the file. Multiple words are joined using underscores which adh

Using DEFAULT You can use the keyword DEFAULT rather than that of the assignment operator to initialize the variables. For e.g. the declaration blood_type CHAR := ’O’; it can b

Implicit Cursors The Oracle implicitly opens a cursor to process each SQL statement not related with an explicitly declared cursor. The PL/SQL lets you refer to the most recen

1. a. Write a trigger that fires when a part's price is updated. The trigger will write a record into a table called PriceUpdates. The record should contain the information of

Perform the following queries on the Hospital1.DB using SQL Anywhere (START EARLY!). a. Which patients have purchased the drug "Tylenol"? List the names and addresses. Arrange the