In this article, we will build a Library Database Management System using MySQL. The database for library management system will include tables that store and organize information about books, users, and transactions. Imagine that you go to the library, take a book, and just enter that book into the computer rather than entering your details and book details in a register. Isn’t it easy and convenient? Here comes the library database management system. This system is handy for people going to the library and searching for their desired book and for the librarian to guide them and take care of these things. It ensures that everything works in systematic order, given that each person taking or returning books needs to enter the record in the system. In this article, you will get insights about the library database management system project and also understand about the library management system SQL project with these projects you will able to clear your doubts on library management system.
This article was published as a part of the Data Science Blogathon.
The Library Database Management System is a comprehensive system that shows all available books and their count, as well as books taken by people, the date they borrowed a particular book, the expected return date, late fees, membership details, and more. Using a database for library management system ensures that everything is crystal clear, with no ambiguity. This clarity is beneficial for both students and librarians.
This system is very efficient and cost-effective. Implementing a database for library management system saves a lot of time for both librarians and students. With this system, manual work is significantly reduced, requiring less staff and maintenance. Additionally, the system is user-friendly and very easy to use.
Firstly we need to take every user perspective; user means not only customers but also staff in the library. What are all the features each user requires?
We will start with features required by library staff
Next going to features required by a student
In the following code, we will be using MYSQL and the names of some books so that they would be easy to understand.
So our first step is to create tables. Let us create a database as db_LibraryManagement and then create all the required tables inside it.
CREATE PROC dbo.LibraryManagementSystemProcedure
AS CREATE DATABASE db_LibraryManagement
GO
CREATE TABLE table_publisher (
PublisherName VARCHAR(50) PRIMARY KEY NOT NULL,
PublisherAddress VARCHAR(100) NOT NULL,
PublisherPhone VARCHAR(20) NOT NULL,
);
Now let’s create a table for a book.
CREATE TABLE table_book (
BookID INT PRIMARY KEY NOT NULL IDENTITY (1,1),
Book_Title VARCHAR(100) NOT NULL,
PublisherName VARCHAR(100) NOT NULL
);
Similarly, create a table for the library branch.
CREATE TABLE table_library_branch (
library_branch_BranchID INT PRIMARY KEY NOT NULL IDENTITY (
library branch BranchName VARCHAR(100) NOT NULL, library_branch_BranchAddress VARCHAR(200) NOT NULL,
);
View the library branch table.
SELECT FROM table_library_branch
CREATE TABLE table_borrower (
CardNo INT PRIMARY KEY NOT NULL IDENTITY (100,1),
BorrowerName VARCHAR(100) NOT NULL,
BorrowerAddress VARCHAR(200) NOT NULL,
BorrowerPhone VARCHAR(50) NOT MILL,
);
Create a table to store the book copies.
CREATE TABLE table_book_copies (
book_copies CopiesID INT PRIMARY KEY NOT NULL
book_copies BookID INT NOT NULL
book_copies BranchID INT NOT NULL
book_copies No Of Copies INT NOT NULL,
);
Create one more table for storing book authors
SELECT FROM table_book_copies CREATE TABLE table_book_authors (
book_authors AuthorID INT PRIMARY KEY NOT NULL IDENTITY (1,1),
book_authors BookID INT NOT NULL CONSTRAINT fk_book_id3 FOREIGN KEY REFERENCES table_book(book_BookID) ON UPDATE CASCADE ON DELETE CASCADE, table_book(book_BookID) ON UPDATE CASCADE,
book authors AuthorName VARCHAR(50) NOT NULL,
);
SELECT FROM table_book_authors
Next is having some data inserted into the tables. Let’s do it now.
-- Table structure for table `book`
CREATE TABLE IF NOT EXISTS `book` (
`isbn` char(13) NOT NULL,
`title` varchar(80) NOT NULL,
`author` varchar(80) NOT NULL,
`category` varchar(80) NOT NULL,
`price` int(4) unsigned NOT NULL,
`copies` int(10) unsigned NOT NULL
);
Adding data into the table book.
INSERT INTO `book` (`isbn`, `title`, `author`, `category`, `price`, `copies`) VALUES
('9788654552277', 'X-Men: God Loves, Man Kills', 'Chris', 'Comics', 98, 39),
('0964161484100', 'Mike Tyson : Undisputed Truth', 'Larry Sloman, Mike Tyson', 'Sports', 654, 79),
('6901142585540', 'V for Vendetta', 'Alan Moore', 'Comics', 600, 23),
('9094996245442', 'When Breath Becomes Air', 'Paul Kalanithi', 'Medical', 500, 94),
('8653491200700', 'The Great Gatsby', 'F. Scott Fitzgerald', 'Fiction', 432, 120);
Structure of the table for book issue.
CREATE TABLE IF NOT EXISTS `book_issue` (
`issue_id` int(11) NOT NULL,
`member` varchar(20) NOT NULL,
`book_isbn` varchar(13) NOT NULL,
`due_date` date NOT NULL,
`last_reminded` date DEFAULT NULL
) ;
CREATE TRIGGER `issue_book` BEFORE INSERT ON `book_issue`
FOR EACH ROW BEGIN
SET NEW.due_date = DATE_ADD(CURRENT_DATE, INTERVAL 20 DAY);
UPDATE member SET balance = balance - (SELECT price FROM book WHERE
isbn = NEW.book_isbn) WHERE username = NEW.member;
UPDATE book SET copies = copies - 1 WHERE isbn = NEW.book_isbn;
DELETE FROM pending_book_requests WHERE member = NEW.member AND book_isbn = NEW.book_isbn;
END
CREATE TRIGGER `return_book` BEFORE DELETE ON `book_issue`
FOR EACH ROW BEGIN
UPDATE member SET balance = balance + (SELECT price FROM book WHERE isbn = OLD.book_isbn) WHERE username = OLD.member;
UPDATE book SET copies = copies + 1 WHERE isbn = OLD.book_isbn;
END
Structure of librarian table.
CREATE TABLE IF NOT EXISTS `librarian` (
`id` int(11) NOT NULL,
`username` varchar(20) NOT NULL,
`password` char(40) NOT NULL
) ;
Adding details of the librarian.
INSERT INTO `librarian` (`id`, `username`, `password`) VALUES
(1, 'Vani', 'xthds97@3h$yfc*jrk0%dfg
Structure of table for the member.
CREATE TABLE IF NOT EXISTS `member` (
`id` int(11) NOT NULL,
`username` varchar(20) NOT NULL,
`password` char(40) NOT NULL,
`name` varchar(80) NOT NULL,
`email` varchar(80) NOT NULL,
`balance` int(4) NOT NULL
);
CREATE TRIGGER `add_member` AFTER INSERT ON `member`
FOR EACH ROW DELETE FROM pending_registrations WHERE username = NEW.username
CREATE TRIGGER `remove_member` AFTER DELETE ON `member`
FOR EACH ROW DELETE FROM pending_book_requests WHERE member = OLD.username
Structured table for pending book requests
CREATE TABLE IF NOT EXISTS `pending_book_requests` (
`request_id` int(11) NOT NULL,
`member` varchar(20) NOT NULL,
`book_isbn` varchar(13) NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
);
Structure of table for pending registrations.
CREATE TABLE IF NOT EXISTS `pending_registrations` (
`username` varchar(30) NOT NULL,
`password` char(20) NOT NULL,
`name` varchar(40) NOT NULL,
`email` varchar(20) NOT NULL,
`balance` int(10),
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
);
Add data for pending registrations table.
INSERT INTO `pending_registrations`
(`username`, `password`, `name`, `email`, `balance`, `time`)
VALUES
('Robin200', '7t6hg$56y^', 'Robin', '[email protected]', 200, '2021-03-21 08:59:00'),
('Aadhya100', 'Ujgf(76G5$#f@df', 'Aadhya', '[email protected]', 1500, '2021-03-21 2:14:53');
Now let’s add primary keys to these tables.
ALTER TABLE `book`
ADD PRIMARY KEY (`isbn`);
ALTER TABLE `book_issue`
ADD PRIMARY KEY (`issue_id`);
ALTER TABLE `librarian`
ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `username` (`username`);
ALTER TABLE `member`
ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `username` (`username`), ADD UNIQUE KEY `email` (`email`);
ALTER TABLE `pending_book_requests`
ADD PRIMARY KEY (`request_id`);
ALTER TABLE `pending_registrations`
ADD PRIMARY KEY (`username`);
Now it’s time to test our database. The below code is to test whether we are getting the correct output. We are getting to know the number of books named The Lost Tribe present in the library Sharpstown.
CREATE PROC dbo.bookCopiesAtAllSharpstown
AS
SELECT copies.book_copies_BranchID AS [Branch ID], branch.library_branch_BranchName AS [Branch Name],
copies.book_copies_No_Of_Copies AS [Number of Copies],
book.book_Title AS [Book Title]
FROM table_book_copies AS copies
INNER JOIN table_book AS book ON copies.book_copies_BookID = book.book_BookID
INNER JOIN table_library_branch AS branch ON book_copies_BranchID = branch.library_branch_BranchID
WHERE book.book_Title = @bookTitle AND branch.library_branch_BranchName = @branchName
GO
EXEC dbo.bookCopiesAtAllSharpstown
(@bookTitle varchar(70) = 'The Lost Tribe', @branchName varchar(70) = 'Sharpstown')
);
To create a Library Management System (LMS) project, you can follow a structured approach that encompasses planning, development, and implementation. Below are the key steps involved in this process, derived from various resources.
Define the core functionalities needed, such as user registration, book management, and borrowing/returning books.Gather input from potential users to understand their needs.
Create use case diagrams and an entity-relationship (ER) model to outline system architecture.
Choose a suitable technology stack (e.g., HTML/CSS/JavaScript for frontend, Node.js/PHP for backend, MySQL/MongoDB for the database).
Implement the system by coding the core modules: user authentication, book management, and transaction tracking.
Use version control (like Git) to manage your codebase.
Conduct various testing phases, including unit testing and user acceptance testing, to identify and fix bugs.
Ensure the system meets the specified requirements and is user-friendly.
Deploy the LMS on a web server or cloud platform for access by users.
Create user manuals and technical documentation to assist users and future developers.
By following these streamlined steps, you can effectively develop and launch a Library Management System.
The library management system is essential for colleges, schools, and many other institutions these days. A lot of manual work can be reduced with this system. Implementing a library management system project in SQL minimizes errors such as wrong borrow dates and miscalculations of fine amounts. Since it is a computer-managed system, these glitches are avoided, ensuring accuracy and reliability.
Hope you like the article, and now you clear your understanding about the library management system projects. And How to create library management system project.
Moreover, the library management system project in SQL is efficient and cost-effective. It stores comprehensive details of books and user information, making it easier to manage and access records. This system is a significant upgrade from traditional methods, enhancing the management and operational aspects of libraries. Hope you like the article and get understanding about the library database management system project. You will get to know about all the concept and installation of library database management.
The media shown in this article is not owned by Analytics Vidhya and is used at the Author’s discretion.
A. A library management system is crucial for efficiently organizing and managing the vast collection of resources (books, journals, multimedia, etc.) in a library. It streamlines operations, enhances accessibility, and improves resource tracking and utilization.
A. The primary objectives of a library management system are to automate and simplify library operations, provide efficient search and retrieval of resources, maintain accurate records of holdings and circulation, and enhance the overall user experience.
A. The key functionalities of a library management system include cataloging and classification of resources, acquisition and circulation management, serials management, patron management (registration, borrowing history, overdue notifications), reporting and analytics, and integration with digital resources and online catalogs.
A. There is no one-size-fits-all “best” library management system, as the choice depends on factors such as the size and type of library, specific requirements, budget, and desired features. Some popular and widely used systems include Koha (open-source), LibraryWorld, Follett Destiny, Alexandria, and proprietary solutions from vendors like Ex Libris, SirsiDynix, and Innovative Interfaces.