A JDBC driver doesn t absolutely have to be SQL-92 compliant. The JDBC specification states the following: In order to pass JDBC compliance tests and to be called JDBC compliant, we require that a driver support at least ANSI SQL-92 Entry Level. This requirement is clearly not possible with drivers for legacy database management systems (DBMS). The driver in these cases will not implement all of the functions of a compliant driver. In Chapter 10, Writing JDBC Drivers, we develop the basics of a JDBC driver that implements only some of the features of SQL, but is a JDBC driver nonetheless. We ll start our exploration of SQL by discussing the relational model, the basis for SQL. Then we ll cover the essentials of building data tables using SQL. Finally, we ll go into the manipulation and extraction of the data from a datasource. The Relational Model And SQL Although SQL is based on the relational model, it is not a rigid implementation of it. In this section, we ll discuss the relational model as it pertains to SQL so we do not obfuscate our discussion of this standard, which is central to the JDBC specification. As part of its specification, the SQL-92 standard includes the definition of data types. We ll cover these data types, and how to map to Java, in Chapter 6, SQL Data Types in Java and the ORM. Understanding The Basics The basic units in SQL are tables, columns, and rows. So where does the relational model fit into the SQL units? Strictly speaking, in terms of the relation model, the relation is mapped in the table: It provides a way to relate the data contained within the table in a simple manner. A column represents a data element present in a table, while a row represents an instance of a record, or entry, in a table. Each row contains one specific value for each of the columns; a value can be blank or undefined and still be considered valid. The table can be visualized, you guessed it, as a matrix, with the columns being the vertical fields and the rows being the horizontal fields. Figure 2.1 shows an example table that can be used to store information about a company s employees. Figure 2.1 An SQL table. Before we push on, there are some syntax rules you need to be aware of: SQL is not whitespace sensitive. Carriage returns, tabs, and spaces don t have any special meaning when executing queries. Keywords and tokens are delimited by commas, when applicable, and parentheses are used for grouping. When performing multiple queries at one time, you must use semicolons to separate distinct queries. Queries are not case sensitive.
We feature a web hosting shopping cart and live support solution. Just try our web hosting shopping cartwhich provides a secure way of obtaining payments through your website.