Database Reference
In-Depth Information
VIEW DEFINITION:
Define a view relation v1 containing order numbers, order dates, and order
amounts for customer “Bill Jones” with order amount greater than $1,000
V1 (A, B) : = ORDER (A, B, C, “Bill Jones”), C > 1000
QUERY
Retrieve order numbers, order dates, order amounts for customer “Bill Jones”
? V1 (A, B) :
=
ORDER (A, B, C, “Bill Jones”)
QUERY
Retrieve order numbers, order dates, order amounts for order with amounts less
than $ 150"
? V1 (A, B) : = ORDER (A, B, C), C < 150
Figure 13-7
Datalog view and query.
or from file-oriented data systems may select an initial relational DBMS. As the
organizations gain experience and desire to move forward to another, more robust
relational DBMS, SQL makes the transition possible.
SQL is a command-driven, declarative, nonprocedural language serving as DDL,
DML, and DCL. With SQL you can define database objects, manipulate data, and
exercise data control. You can write SQL code as free-form text. The structure of
the commands consists of standard English words such as CREATE, SELECT,
FROM, WHERE, DROP, and so on. The language may be used by DBAs, analysts,
programmers, and even end users with equal ease—a language easy to learn, but
perhaps not so easy to master.
Let us now begin an in-depth discussion of SQL—its features, history and evo-
lution, major commands, and usefulness. You will learn how to use facilities in SQL
to define data structures, manipulate data, compose queries, provide data control,
and manage data. You will also study examples of simple and complex queries
written in SQL. Nevertheless, this coverage of SQL is not meant to be a detailed
reference guide. You are encouraged to continue your study of SQL with the aid of
topics specifically intended for that purpose.
Overall Features
SQL is a comprehensive database or model implementation language mostly based
on tuple relational calculus. The language also includes some relational algebra
operations. It combines features and functions both for definition of data structures
and for usage of data in the database. The widespread use and acceptance of SQL
enables it to evolve and become more robust.
Because the underlying construct is based on relational calculus, a nonprocedural
language, there is no sequencing of the commands in SQL. An SQL query is simply
written as a solution statement declaring the outcome desired from execution of the
query. How the result is formatted and presented to the user is left outside of SQL.
In SQL you find only definitional and manipulative commands. You do not have
flow of control commands—no if-then-else navigation within SQL code. Therefore,
SQL has to be embedded in a host language to provide flow of control. The host
Search WWH ::




Custom Search