Database Reference
In-Depth Information
As long as a user is familiar with the relationships among the tables in the database,
he can access data in an almost unlimited number of ways. He can access data from
tables that are directly related and from tables that are indirectly related. Consider the
Agents database in Figure 1.5 . Although the CLIENTS table is indirectly related to the
ENGAGEMENTS table, the user can produce a list of clients and the entertainers who
haveperformedforthem.(Ofcourse,itreallydependsonhowthetablesareactuallystruc-
tured, but I digress. This example serves our purpose for now.) He can do this easily be-
cause CLIENTS is directly related to ENGAGEMENTS and ENGAGEMENTS is directly
related to ENTERTAINERS.
Retrieving Data
Youretrievedatainarelationaldatabasebyusing Structured Query Language ( SQL ) .SQL
is the standard language used to create, modify, maintain, and query relational databases.
The following shows a sample SQL query statement you can use to produce a list of all
clients in the city of El Paso:
Click here to view code image
SELECT ClientLastName, ClientFirstName, ClientPhoneNumber
FROM Clients
WHERE City = "El Paso"
ORDER BY ClientLastName, ClientFirstName
The three components of a basic SQL query are the SELECT...FROM statement, the WHERE
clause, and the ORDER BY clause. You use the SELECT clause to indicate the fields you want
to use in the query and the FROM clause to indicate the table(s) to which the fields belong.
You can filter the records the query returns by imposing criteria against one or more fields
with the WHERE clause, and then sort the results in ascending or descending order with the
ORDER BY clause.
Most of today's major relational database software programs incorporate various forms of
SQL implementations, ranging from windows in which users can manually enter “raw”
SQL statements to tools that allow users to build queries using various graphic elements.
For example, a user working with R:BASE Technologies' R:BASE can opt to build and
execute SQLquerystatements directly fromacommandprompt,whilesomeoneusingMi-
crosoft SQL Server may find it easier to build queries using SQL Server's graphical query
builder. Regardless of how the queries are built, the user can save them for future use.
It's not always necessary for you to know SQL in order to work with a database. If your
database software provides a graphical query builder or you're using a custom-built ap-
plication to work with the data in your database, you'll never need to write a single SQL
statement. It's a good idea, however, for you to gain a basic understanding of SQL. It will
Search WWH ::




Custom Search