Skip to content

Yana P.#2

Open
YanaP1312 wants to merge 4 commits into
HackYourAssignment:mainfrom
YanaP1312:main
Open

Yana P.#2
YanaP1312 wants to merge 4 commits into
HackYourAssignment:mainfrom
YanaP1312:main

Conversation

@YanaP1312

Copy link
Copy Markdown

Implemented Task 1 and Task 2 for the Library Management System module.

Task 1

  • Created PostgreSQL database schema with all required tables and relationships.
  • Added primary keys, foreign keys, constraints, and validation rules.
  • Ensured correct data types, UNIQUE, NOT NULL constraints, and CHECK conditions.

Task 2

  • Added JDBC connection setup and basic application structure.
  • Implemented insertData() using PreparedStatement and RETURNING to fetch generated IDs.
  • Inserted demo data into all tables (publishers, authors, tags, shelves, books, copies, cards, members, borrows, book_authors, book_tags).
  • Implemented fetchData() with a JOIN query to retrieve and display borrow records.
  • Verified successful database interaction and console output.

@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.

Nice work that is not only technically correct, but also done with care and a good eye for detail. The schema is well structured, the table relationships are clear, and the use of keys, constraints, and indexes shows a strong understanding of database design.

Comment thread task-1/docker-compose.yml

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bonus points for this docker compose file. It helps a lot to be able to validate the work in this PR.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

DBeaver is a very good tool choice.

Comment thread task-1/README.MD

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Solid Readme.md.

Comment thread task-1/schema.sql



-

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This - makes that some tables are missing after running this script due to a syntax error. Deleting the - fixed the problem, so not really a big deal. Running it second time was a bit of a challenge using CREATE TABLE IF NOT EXISTS to make the script a bit more idempotent.

Comment thread task-1/schema.sql
card_number TEXT UNIQUE NOT NULL,
card_issued_on DATE NOT NULL,
card_expires_on DATE NOT NULL,
CHECK (card_expires_on > card_issued_on)

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 date check!

Comment thread task-1/schema.sql
member_address TEXT NOT NULL,
CONSTRAINT fk_card_id
FOREIGN KEY (card_id)
REFERENCES cards (card_id) ON DELETE CASCADE

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should members whose card is deleted be deleted as well? Or is using ON DELETE SET NULL also an option?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using a .gitignore file with a line "target/" could be helpful to prevent build output to end up under version control.

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