Skip to content

Dagim H.#1

Open
Unlock7 wants to merge 6 commits into
HackYourAssignment:mainfrom
Unlock7:main
Open

Dagim H.#1
Unlock7 wants to merge 6 commits into
HackYourAssignment:mainfrom
Unlock7:main

Conversation

@Unlock7

@Unlock7 Unlock7 commented Jun 3, 2026

Copy link
Copy Markdown

complete:
task‑1: Normalized the raw library export into a clean 3NF schema. Designed tables, relationships (1:1, 1:N, N:M), added all required constraints, and successfully executed schema.sql to create and run the library_db.
task‑2: Implemented a JDBC-based console application for the library database. Added insertData() to populate tables with sample rows and fetchData() using a JOIN query to retrieve borrowing records.
Fully tested database connection and CRUD operations.

@composix composix left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like how focused and minimal this PR is. By only including the necessary files, the solution is easy to review and the intent is immediately clear. This is a great example of the KISS principle in practice: simple, purposeful, and without unnecessary noise. It takes confidence to keep things this lean, and I think that deserves recognition.


// Publisher 2 rows
PreparedStatement pub = conn.prepareStatement(
"INSERT INTO publishers (name) VALUES (?) ON CONFLICT (name) DO NOTHING"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that you try to avoid duplicate insert errors using ON CONFLICT DO NOTHING. That makes the seed data easier to rerun during development. One thing to watch out for is that the code still uses hardcoded IDs afterwards. For example, if the publisher already exists with a different publisher_id, then using 1 as the hardcoded publisher_id can cause problems later on.

One way to avoid this is to return the actual ID from the database:

INSERT INTO publishers (name)
VALUES (?)
ON CONFLICT (name)
DO UPDATE SET name = EXCLUDED.name
RETURNING publisher_id;

Then you can use the publisher_id returned by the query to set the foreign keys later on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants