Week 5 - Database design

Relational Databases

Primary Keys and Foreign Keys

Constraints

Database normalization

PostgreSQL setup

Joins

Java and databases

Practice

Assignment

Back end Track

Week 5 Assignment — Library database (Normalization → DDL → Java CRUD)

For this assignment, you will build a small library database from a messy export. On top of it, you’ll write a small application showing you can interact with the database using the JDBC. You will:

  1. Normalize the data (1NF → 3NF)
  2. Design relations (1:1, 1:N, N:M) + bridge tables
  3. Add constraints (PK/FK/UNIQUE/NOT NULL/CHECK)
  4. Write PostgreSQL DDL and create the database
  5. Connect to the database with Java and JDBC CRUD

Task 1 — Normalize a library database

You are given a single export table called borrowings_export (imagine it came from a spreadsheet).

Columns:

Here’s the full file:

library_loans.csv

Or you can find it on Github

Example rows:

member_email member_name member_phone member_address card_number card_issued_on card_expires_on book_isbn book_title publisher_name author_names tag_names copy_barcode shelf_code borrowed_at due_date returned_at fine_eur
[email protected] Tom +31645678901 Biltstraat 88, Utrecht C-1004 2023-11-20 2026-11-20 9780134685991 Effective Java Addison-Wesley Joshua Bloch java; best-practices BC-0001 A-01 2026-03-09 03:18 2026-03-30 03:18 2026-03-28 03:18 0.00
[email protected] Sam +31612345678 Oudegracht 10, Utrecht C-1001 2024-01-10 2027-01-10 9780596009205 Head First Java O'Reilly Kathy Sierra; Bert Bates java; beginners BC-0006 B-03 2025-12-09 09:08 2025-12-30 09:08 2026-01-04 09:08 1.25
[email protected] Lena +31656789012 Voorstraat 3, Utrecht C-1005 2024-04-05 2027-04-05 9780596009205 Head First Java O'Reilly Kathy Sierra; Bert Bates java; beginners BC-0007 B-03 2026-01-13 22:56 2026-02-03 22:56 2026-02-10 22:56 1.75

Write DDL and create the database (deliverables: schema.sql)

From the export above, design a normalized schema in 3NF. Write PostgreSQL DDL to create your schema.

Must include:

Include:

Then:

  1. Create a database (e.g. library_db)
  2. Run schema.sql

Task 2 — Java JDBC CRUD (deliverable: a minimal console demo)

Create a small Java program that demonstrates using JDBC to connect to the database and run few commands.

Requirements:

Submission

Follow the Assignment submission guide to submit


The HackYourFuture curriculum is licensed under CC BY-NC-SA 4.0 *https://hackyourfuture.net/*

CC BY-NC-SA 4.0 Icons

Built with ❤️ by the HackYourFuture community · Thank you, contributors

Found a mistake or have a suggestion? Let us know in the feedback form.