Application Data Model

We’re now ready to start working on creating the application we outlined earlier. Since defining the data model is a prerequisite for all the following tasks, we’ll tackle it first.

Configuring the Database

Let’s create a new schema called gallery in the database. In PostgreSQL, create an admin user with the password set to admin, then run the following command to add the schema for our application.

 
CREATE​ ​DATABASE​ GALLERY OWNER admin;

Now that our database is ready to use, let’s look at how to connect to it. We can use clojure.java.jdbc to set up the Java Database Connectivity connection.

We’ll create a db namespace under models and set up our database connection there. For simplicity, let’s use the first method ...

Get Web Development with Clojure 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.