Latest Posts

Keys Declared With UNIQUE

One more way to declare a key is to use the keyword UNIQUE. This word can appear exactly where PRIMARY KEY can appear: either following an attribute and its type or as a separate item within a CREATE TABLE statement. The meaning of a UNIQUE declaration is nearly the

Constraints and Triggers

In this section we shall study those aspects of SQL that let us create "active" elements. An active element is an expression or statement that we write once, store in the database, and expect the element to execute at appropriate times. The time of action might be when a certain

Interpreting Queries Involving Views

We can get a good idea of what view queries mean by following the way a query involving a view would be processed. The matter is taken up in more generality in "Algebraic Laws for Improving Query Plans", when we study query processing in general.

Modifying Views

In limited conditions it is possible to carry out an insertion, deletion, or update to a view. In the beginning, this idea makes no sense at all, since the view does not exist the way a base table (stored relation) does. What could it mean, say, to insert a new tuple into a view? Where

View Definitions

Relations that are defined with a CREATE TABLE statement in fact exist in the database. That is an SQL system stores tables in some physical organization. They are persistent, in the sense that they can be expected to exist indefinitely and not to change unless they are clearly told to

Introduction to Selection of Indexes

Selection of indexes requires a trade-off by the database designer, and in fact, this choice is one of the principal factors that influence whether a database design is acceptable. Two important factors to examine are:

Default Values / Indexes

When we create or change tuples, we sometimes do not have values for all components. For instance, we mentioned in "Simple Table Declarations" Example 2 that when we add a column to a relation schema, the existing tuples do not have a known value, and it was

Simple Table Declarations

The simplest form of declaration of a relation schema comprises the keywords CREATE TABLE followed by the name of the relation and a parenthesized list of the attribute names and their types.

Defining a Relation Schema in SQL

Now we shall begin a discussion of data definition, the portions of SQL that involve explaining the structure of information in the database. On the contrary, the aspects of SQL discussed previously - queries and modifications - are often called data manipulation.

Deletion / Updates

A deletion statement consists of: 1. The keywords DELETE FROM, 2. The name of a relation, say R, 3. The keyword WHERE, and 4. A condition. That is, the form of a deletion is DELETE FROM R WHERE ; The effect of executing this statement is that every tuple satisfying the condition (4) will be deleted from relation R.