With the preceding configuration, the database will be created for you because of the parameter on
the JDBC URL: create=true . You should remove this for production, however. For your book shop
application, you need a place to store the data. You'll create a simple database to manage books and
The entity relational (ER) diagram for the tables looks like Figure 4-1.
Figure 4-1. BOOK_STOCK describes how many given BOOKs exist.
Now, let's create the SQL for the preceding model. You'll use the ij tool that ships with Derby.
On a command line, proceed to the directory where Derby is installed (usually just where you unzipped
it when you downloaded it.). Descend to the bin directory. If Derby's not already started, run
startNetworkServer (or startNetworkServer.bat on Windows). Now you need to log in and execute the
SQL DDL. Background the Derby Server process or open up a second shell and return to the same bin
directory in the Derby installation directory. Execute ij . In the shell, execute the following:
connect jdbc: derby://localhost:1527/bookshop; create=true ;
Paste the following SQL into the shell and verify its success:
CREATE TABLE BOOK (
ISBN VARCHAR(50) NOT NULL,
BOOK_NAME VARCHAR(100) NOT NULL,
PRIMARY KEY (ISBN)