Learn Java for Web Development

(Tina Meador) #1

20 CHAPTER 1: Introducing Java Web Development


Data Model for the Bookstore Application


This section introduces a simple data model that will be used for the bookstore web application
throughout this book. I will expand the model progressively with each chapter, as the need arises.
The model is a simple book database that consists of three tables.


   The Category table stores the different categories of books; categories include
Java, Scala, and so on.
 The Book table stores the book details such as titles.
 The Author table stores the details of the authors.

Each category can have zero or more books. For instance, there could be zero or more books in
the Java category in the bookstore. In other words, there is a one-to-many relationship between
the Category and Book tables. Similarly, each book can have one or more authors. In other words,
there is a one-to-many relationship between the Book and Author tables. The entity-relationship (ER)
diagram in Figure 1-12 illustrates this relationship.


Figure 1-12. Entity-relationship diagram of the data model


This data model is not production-ready because you can have a many-to-many relationship
between Category and Book, and you can have a many-to-many relationship between Book and
Author. I have kept the data model simple so that the complexity of the data model does not get in
the way of learning the mechanics of building a web application. However, you can, for example,
model a many-to-many relationship between Book and Author, as illustrated in Figure 1-13.

Free download pdf