Persistence
In the context of the online shopping project, we are going to create a simple data model with only two tables—the cart and product tables. The product represents what we would like to sell. It has a name, a code, a description, and a price.
The cart what a customer is about to buy. It has an ID, which is autoincremented for any new cart created, and a user, representing the user identification. For the purpose of this book, we are going to use the username sent during the login process. The cart also has a quantity and a code, representing a link to the product table.
The following diagram is a representation of our model:
For the purposes of this book, we will choose a database that requires no administration, is fast, with a small footprint, and can be deployed quickly and smoothly. The H2 database fulfills all of these requirements.
To access our data, we would like to take advantage of the Scala language to statically check our code at compile time. The Slick library is perfect...