Latest Posts

Disambiguating Attributes

Sometimes we ask a query involving many relations, and among these relations are two or more attributes with the same name. If so, we need a way to indicate which of these attributes is meant by a use of their shared name. SQL solves this problem by allowing us to place a

Queries Involving More Than One Relation

Much of the power of relational algebra comes from its ability to combine two or more relations through joins, products, unions, intersections, and differences. We get all of these operations in SQL. The set-theoretic operations - union, intersection, and difference - appear directly in

The Truth-Value UNKNOWN

In Selection in SQL we assumed that the result of a comparison was either TRUE or FALSE, and these truth-values were combined in the obvious way using the logical operators AND, OR and NOT. We have just seen that when NULL values occur, comparisons can yield a third

Null Values and Comparisons Involving NULL

SQL allows attributes to have a special value NULL, which is called the null value. There are many different interpretations that can be put on null values. Here are some of the most common:

Dates and Times

Implementations of SQL normally support dates and times as special data types. These values are often representable in a variety of formats such as 5/14/1948 or 14 May 1948. Here we shall explain only the SQL standard notation, which is very specific about format.

Comparison of Strings

Two strings are equal if they are the same sequence of characters. SQL allows declarations of different types of strings, for instance fixed-length arrays of characters and variable-length lists of characters. If so, we can expect reasonable

Tags : strings, arrays, sql
Selection in SQL

The selection operator of relational algebra, and much more, is available through the WHERE clause of SQL. The expressions that may follow WHERE contain conditional expressions like those found in common languages such as C or Java.

Projection in SQL

We can, if we wish, remove some of the components of the selected tuples; that is, we can project the relation created by an SQL query onto some of its attributes. In place of the * of the SELECT clause, we may list some of the attributes of the relation mentioned in the FROM

The Database Language SQL

The most frequently used relational DBMSs query and modify the database through a language called SQL (often pronounced sequel). SQL stands for "Structured Query Language". The portion of SQL that supports queries has capabilities very close to that of relational algebra, as

Additional Constraint Examples

The same constraint notation permits us to express far more than referential integrity. For instance, we can express any functional dependency as an algebraic constraint, although the notation is more awkward than the FD notation introduced in Functional Dependencies.