Database Reference
In-Depth Information
3
THE RELATIONAL MODEL 2: SQL
CHAPTER
LEARNING OBJECTIVES
￿ Introduce Structured Query Language (SQL)
￿ Use simple and compound conditions in SQL
￿ Use computed fields in SQL
￿ Use built-in SQL functions
￿ Use subqueries in SQL
￿ Group records in SQL
￿ Join tables using SQL
￿ Perform union operations in SQL
￿ Use SQL to update database data
￿ Use an SQL query to create a table in a database
INTRODUCTION
In this chapter, you will examine the language called
. Like Access and Query-
By-Example (QBE), SQL provides users with the capability of querying a relational database. However, in SQL, you must
enter
SQL (Structured Query Language)
to obtain the desired results rather than complete an on-screen form as you do in Access and QBE.
SQL uses commands to create and update tables and to retrieve data from tables. The commands used to retrieve table
data are usually called queries.
SQL was developed under the name SEQUEL at the IBM San Jose research facilities as the data manipulation lan-
guage for IBM's prototype relational DBMS, System R, in the mid-1970s. In 1980, it was renamed SQL (but still pro-
nounced “sequel,” although the equally popular pronunciation of “S-Q-L” [“ess-cue-ell”] is used in this text) to avoid
confusion with an unrelated hardware product called SEQUEL. Most relational DBMSs use a version of SQL as a data
manipulation language. SQL is the standard language for relational database manipulation. The SQL version used in the
examples in this chapter is Microsoft Access 2010. Although the various versions of SQL are not identical, the differences
are relatively minor. After you have mastered one version of SQL, you can apply your skills to learn another version of
SQL.
You will begin studying SQL by examining how to use it to create a table. You will examine simple retrieval methods
and compound conditions. You will use computed fields in SQL and learn how to sort data. You will then learn how to use
built-in functions, subqueries, and grouping. You will learn how to join tables and use the UNION operator. Finally, you will
use SQL to update data in a database. The end of this chapter includes generic versions of all the SQL commands pre-
sented in the chapter.
commands
GETTING STARTED WITH SQL
In this chapter, you will be reading the material and examining the figures to understand how to use SQL to
manipulate a relational database. You might also be using a DBMS to practice database manipulation at the
same time. If you are completing the work in this chapter using Microsoft Office Access 2007, Microsoft
Access 2010, or MySQL version 4.1 or higher, you should read the following information about your DBMS to
learn more about how to start SQL and to learn specific details about differences you might encounter as you
complete your work.
Search WWH ::




Custom Search