Latest Posts

Constraints on Attributes and Tuples

We have seen key constraints, which compel certain attributes to have distinct values among all the tuples of a relation, and we have seen foreign-key constraints, which enforce referential integrity between attributes of two relations. Now, we shall see a third important kind of

Deferring the Checking of Constraints

Suppose the situation of "Declaring Foreign-Key Constraints" Example 1, where presC# in Studio is a foreign key referencing cert# of MovieExec. Bill Clinton decides, after his national presidency, to found a movie studio, called Redlight Studios, of which he will naturally be the

Maintaining Referential Integrity

We have studied how to declare a foreign key, and we learned that this declaration implies that any set of values for the attributes of the foreign key, none of which are NULL, must also appear in the corresponding attribute(s) of the referenced relation. But how is this constraint

Declaring Foreign-Key Constraints

A second important kind of constraint on a database schema is that values for certain attributes must make sense. That is, an attribute like presC# of relation Studio is expected to refer to a particular movie executive. The implied "referential integrity" constraint is that if a studio's

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: