https://github.com/anurag-ghosh-12/library_management_system_sql
This project showcases the development of a comprehensive Library Management System utilizing Structured Query Language (SQL). It demonstrates a practical application of relational database principles to efficiently manage library resources, member information, and borrowing/returning transactions.
https://github.com/anurag-ghosh-12/library_management_system_sql
data-analysis data-visualisation dbms-project sql
Last synced: 5 months ago
JSON representation
This project showcases the development of a comprehensive Library Management System utilizing Structured Query Language (SQL). It demonstrates a practical application of relational database principles to efficiently manage library resources, member information, and borrowing/returning transactions.
- Host: GitHub
- URL: https://github.com/anurag-ghosh-12/library_management_system_sql
- Owner: Anurag-ghosh-12
- Created: 2025-03-08T11:06:08.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-08T11:38:50.000Z (over 1 year ago)
- Last Synced: 2025-05-31T14:21:50.986Z (about 1 year ago)
- Topics: data-analysis, data-visualisation, dbms-project, sql
- Homepage:
- Size: 282 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# đ Library Management System (SQL) đ
Author: Anurag Ghosh
This project demonstrates the power of SQL in building a robust Library Management System (LMS). We'll explore database design, CRUD operations, advanced queries, and how SQL transforms traditional bookkeeping. Let's dive in! đâ¨
## đī¸ Database Schema

The system consists of the following tables, designed to efficiently manage library resources:
- **đĸ LibraryBranch:** Stores branch details (branch ID, manager ID, address, contact).
- **đ§âđŧ Staff:** Stores staff information (staff ID, name, position, salary, branch ID).
- **đĨ LibraryMembers:** Stores member details (member ID, name, address, registration date).
- **đ Books:** Stores book information (ISBN, title, category, rental price, status, author, publisher).
- **đ IssueStatus:** Tracks book borrowing (issue ID, member ID, book ISBN, issue date, staff ID).
- **âŠī¸ ReturnStatus:** Tracks book returns (return ID, issue ID, return date).
## đ Setup Instructions
1. **đž Database Creation:**
- Create a database named `library_system`.
- Execute the SQL script (`Library_main_script.sql`) to create tables and insert sample data.
2. **âļī¸ SQL Script Execution:**
- Use a SQL client (e.g., MySQL Workbench, pgAdmin, SQL Server Management Studio).
- Run the script to build your library database.
## đĄ SQL Queries and Functionalities
### đ What is a Relational Database?
A relational database organizes data into tables with rows and columns. Relationships between tables are established using keys, ensuring data integrity and reducing redundancy. SQL (Structured Query Language) is the standard language for managing relational databases.
### đ ī¸ CRUD Operations
CRUD (Create, Read, Update, Delete) operations are fundamental to database management.
- **đ Create (INSERT):**
```sql
INSERT INTO LibraryMembers (member_id, member_name, member_address, reg_date)
VALUES ('2022CSB14STU', 'New Member', 'New Address', '2024-04-01');
```
- **đ Read (SELECT):**
```sql
SELECT book_title, author FROM Books WHERE category = 'Computer Science';
```
- **đ Update (UPDATE):**
```sql
UPDATE Books SET rental_price = 9.99 WHERE isbn = '978-1-593-27082-7';
```
- **đī¸ Delete (DELETE):**
```sql
DELETE FROM LibraryMembers WHERE member_id = '2022CSB14STU';
```
### đ Data Analysis and Reporting
- **đ Counting Books by Category:**
```sql
SELECT category, COUNT(*) AS book_count FROM Books GROUP BY category ORDER BY book_count DESC;
```

- Book issued and Books of different publisher report:
Books by publishers via a piechart:
Books issued report:
Publisher report
- **đ° Finding Total Rental Income:**
```sql
SELECT category, SUM(rental_price) AS total_rental_income FROM Books GROUP BY category;
```
- **âŗ Finding Overdue Books:**
```sql
SELECT ist.issued_member_id,
m.member_name,
bk.book_title,
ist.issued_date,
CURRENT_DATE - ist.issued_date AS overdue_days
FROM issued_status ist JOIN members m ON m.member_id = ist.issued_member_id
JOIN books bk ON bk.isbn = ist.issued_book_isbn
LEFT JOIN return_status rs ON rs.issued_id = ist.issued_id
WHERE rs.return_date IS NULL AND (CURRENT_DATE - ist.issued_date) > 30
ORDER BY overdue_days DESC;
```
### đĸ Branch-wise Reports
- **đ Generating Branch Reports:**
```sql
SELECT lb.branch_id, COUNT(DISTINCT iss.issued_id)
AS total_books_issued,
COUNT(DISTINCT ret.return_id) AS total_books_returned,
COALESCE(SUM(b.rental_price), 0) AS total_revenue
FROM LibraryBranch lb LEFT JOIN Staff s ON lb.branch_id = s.branch_id
LEFT JOIN IssueStatus iss ON s.staff_id = iss.issued_staff_id
LEFT JOIN ReturnStatus ret ON iss.issued_id = ret.issued_id
LEFT JOIN Books b ON iss.issued_book_isbn = b.isbn
GROUP BY lb.branch_id
ORDER BY total_books_issued DESC;
```
The visual representation:

## đ Motivation: From Traditional Bookkeeping to SQL
**Traditional Bookkeeping:** Imagine a library where records are maintained manually in ledgers. Finding a book's status, calculating overdue fines, or generating reports would be time-consuming and prone to errors.
**SQL Transformation:** SQL automates these tasks, making them fast and accurate. With SQL, I can:
- **đ Instantly find any book or member.**
- **⥠Generate real-time reports.**
- **â
Maintain data integrity and consistency.**
- **đ Analyze library data to improve operations.**
I love how SQL transforms complex data management into simple, efficient queries. It's like having a super-powered assistant that handles all the tedious tasks, allowing me to focus on what matters most. đ
## đ ī¸ Technologies Used
- SQL (PostgreSQL)
## đ Potential Enhancements
- đ Implement a web-based user interface.
- đą Integrate barcode scanning for efficient check-in/check-out.
- đ Add user authentication and authorization.
- đ Implement automated overdue notifications.
- đ Create advanced analytics dashboards.
## đ¤ How to Contribute
Contributions are welcome! Feel free to submit pull requests or open issues. Let's make this LMS even better! đâ¨