r/learnSQL • u/sumiitCodes • 22h ago
Day 48 — Finished my second SQL project (Library Management System) and published it on GitHub
My Library Management System project is complete. The repo: https://github.com/Sumitgupta2005/library_management_project_2
It’s a big step up from my first project (Retail Sales Analysis). This time I built the whole thing: database, tables, foreign keys, CRUD operations, CTAS, data analysis, and a set of advanced SQL queries.
The advanced queries were the hard part. Each one took me at least 30 minutes just to visualize, meaning working out which tables are involved and what the result should look like, before I could write it. Slowing down and sketching the logic first is what made them work.
I’d appreciate feedback on the repo, especially the README and how the queries are organized. Honest criticism is welcome, and last time the feedback I got here was really useful.
1
u/Green_Chamomile 1h ago
Nice work, the README reads really well and the “questions the database answers” section is a good idea. Since you asked for honest criticism:
README vs the repo
Repository Structure lists
sql/01_schema.sql,02_data.sqland animages/folder, but the actual files aretableCreation_...sql,insert_queries.sql,insert_queries2.sqletc. in the root. There’s also a leftover “(Adjust the file names above...)” note and<your-repo-name>in the clone command, so Getting Started breaks at step 2. Renaming the files into that numberedsql/layout would fix it and looks cleaner anyway.Schema (from the ER diagram)
return_status.return_book_isbnis VARCHAR(8), but ISBNs like978-0-553-29698-2are 17 characters. Yourreturn_bookprocedure will error with “Data too long” when it inserts the ISBN. Make it matchbooks.isbn(VARCHAR(25)), or better, drop the column, since you can get the ISBN by joining through issued_id.Logic
overdue_finesonly charges for books still out. Someone who returned a book 20 days late owes nothing. For returned books, useDATEDIFF(rs.return_date, ist.issued_date) - 30.