Chapter 22. Relational Databases
CHAPTER GOALS
To understand how relational databases store information
To learn how to query a database with the Structured Query Language (SQL)
To connect to a database with Java Database Connectivity (JDBC)
To write database programs that insert, update, and query data in a relational database
In Chapter 19 you saw how to store data in a file. When you store data, you will want to be able to add more data items, remove data, change data items, and find items that match certain criteria. However, if you have a lot of data, it can be difficult to carry out these operations quickly and efficiently. Because data storage is such a common task, special database management systems (DBMS) have been invented that let the programmer think in terms of the data rather than file storage. In this chapter you will learn how to use SQL, the Structured Query Language, to query and update information in a relational database, and how to access database information from Java programs.
Organizing Database Information
Database Tables
A relational database stores information in tables. Figure 1 shows a typical table. As you can see, each row in this table corresponds to a product. The column headerscorrespond to attributes of the product: the product code, description, and unit price. Note that all items in a particular column have the same type: product codes and descriptions are strings, unit prices are floating-point numbers. The allowable column types differ somewhat from ...
Get Big Java, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.