Java Reference
In-Depth Information
Display 19.9
Relationships between JDBC, Embedded Derby, and SQL
Java Application
1. Application constructs SQL
query and sends it to JDBC
3. Result
of the
SQL query
returned
by JDBC
to the
application
JDBC
2. Database engine
processes the query
Data
Files
Embedded Derby
SQL
SQL is pronounced either by saying the letters or by saying the word “sequel.” SQL is a
language for formulating queries for a relational database. SQL is not part of Java, but
JDBC allows you to embed SQL commands in your Java code.
SQL works with relational databases. As an example, suppose we were organizing a
catalog of topics and authors. A relational database can be thought of as a collection of
named tables with rows and columns, such as those shown in Display 19.10. In this
case, we have created a table with author information (author name, unique author ID,
and URL), a table with book information (title and ISBN), and a table that identifies
which author has written which book (unique author ID and ISBN).
In this brief introduction, we will not go into the details of the constraints on
tables. However, to see that there are some constraints, note that in the three tables in
Display 19.10, no relationship is repeated. If we had one entry for each book with all
the information—title, author, ISBN number, 1 and author's URL—then there would
be two entries giving Dan Simmons' URL, because he has two topics in our database.
To manipulate the database, we issue SQL commands, also known as SQL queries,
to the database. The following is a sample SQL command:
SELECT Titles.Title, Titles.ISBN, BooksAuthors.Author_ID
FROM Titles, BooksAuthors
WHERE Titles.ISBN = BooksAuthors.ISBN
1 The ISBN number is a unique identification number assigned to (almost) every book published.
 
 
Search WWH ::




Custom Search