0% found this document useful (0 votes)
35 views

DBMS Report

The document describes the design and implementation of an automated booking system for college libraries. The proposed system aims to streamline the borrowing process, enhance user experience, and optimize resource utilization through the integration of modern technology. It addresses common challenges like long queues, manual book tracking, and difficulty managing reservations by allowing users to browse, reserve, and track book availability online in real-time.

Uploaded by

bashantr29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

DBMS Report

The document describes the design and implementation of an automated booking system for college libraries. The proposed system aims to streamline the borrowing process, enhance user experience, and optimize resource utilization through the integration of modern technology. It addresses common challenges like long queues, manual book tracking, and difficulty managing reservations by allowing users to browse, reserve, and track book availability online in real-time.

Uploaded by

bashantr29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

“JNANA SANGAMA”, BELGAUM-590014, KARNATAKA

A Mini Project Report on

“Smart Library Booking System”


Submitted in partial fulfilment of the requirement for the V semester course of
BACHELOR OF ENGINEERING In
COMPUTER SCIENCE AND ENGINEERING
Submitted By
Abhinav Naik 1AP21CS001
Basha E 1AP21CS009
Alfiya Hassan 1AP21CS006
Gnanesh V S 1AP21CS019

Under the guidance of


Prof. Sowmya George Prof. Astha Tiwari
Assistant Professor, Assistant Professor,
Dept of CS & E Dept of CS & E

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


APS COLLEGE OF ENGINEERING
Anantha Gnana Gangothri
26thk.m, N.H-209, Kanakapura Road, Bangalore–560 082
APS COLLEGE OF ENGINEERING
(Affiliated to Visvesvaraya Technological University)
Anantha Gnana Gangothri,
NH-209, Kanakapura Road, Bangalore–560 082
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

CERTIFICATE
This is to certify that the mini project work entitled
“Smart Library Booking System”
is a bonafide work carried out by
Abhinav Naik 1AP21CS001
Basha E 1AP21CS009
Alfiya Hassan 1AP21CS006
Gnanesh V S 1AP21CS019

In partial fulfilment of the requirement for “Database Management System Mini


Project” of fifth semester Bachelor of Engineering in Computer Science & Engineering of
Visvesvaraya Technological University, Belagavi during the year 2023-2024. It is certified that
all corrections/suggestions indicated for Internal Assessment have been incorporated in the
report deposited in the departmental library. The project report has been approved as it satisfies
the academic requirements in respect of project work prescribed for the “Database
Management System Mini Project” of fifth semester Bachelor of Engineering in Computer
Science and Engineering.

--------------------------- --------------------------- ----------------------------


Prof. Sowmya George Prof. Astha Tiwari Prof. Sameerana C P
Assistant Professor, Assistant Professor, Professor & Head,
Dept. of CSE, Dept. of CSE, Dept. of CSE,

Name of the External Signature and Date


1.
2.
ACKNOWLEDGEMENT

The satisfaction that accompanies the successful completion of any task would be
incomplete without the mention of the people who made it possible, whose constant guidance
and encouragement crowned the efforts with success.

We thank the principal, Dr. D G Anand, APS College of Engineering, for providing with
all the facilities that helped us to carry out the work easily.

We are greatly indebted to Prof. Sameerana C P Associate Professor, Head of


Department of Computer Science and Engineering for providing us with the best facilities and
atmosphere for the creative work, guidance and encouragement.

We are immensely grateful to our Coordinator Prof. Sowmya George, Assistant


Professor, Department of Computer Science and Engineering for his insightful comments and
for sharing his valuable knowledge and experience with us. We are really appreciating him help
to improve the quality of project.

We are immensely grateful to our internal guide Prof. Astha Tiwari, Assistant Professor,
Department of Computer Science and Engineering for her guidance, encouragement and
cooperation.

We would also like to thank all the teaching and non-teaching staff of Department of
Computer Science and Engineering for their support.

Abhinav Naik 1AP21CS001


Basha E 1AP21CS009
Alfiya Hassan 1AP21CS006
Gnanesh V S 1AP21CS019
ABSTRACT

In today's digital age, the efficient management of resources within educational


institutions, such as college libraries, is paramount. This mini project report presents the design
and implementation of an automated booking system specifically tailored for college libraries.

The system aims to streamline the borrowing process, enhance user experience, and
optimize resource utilization through the integration of modern technology.

The proposed system addresses common challenges faced by college libraries,


including long queues, manual book tracking, and difficulty in managing reservations. By
leveraging technology, it provides students and faculty with a user-friendly platform to browse,
reserve, and track the availability of library books remotely.

Users can access an online catalogue containing the library's collection of books and
reserve them through a user-friendly interface, eliminating the need for physical presence at
the library. The system offers real-time updates on the availability of books, ensuring accurate
information for users making reservations.

A queue management mechanism prioritizes reservations based on factors such as


reservation time and user status to handle simultaneous requests for the same book. The system
seamlessly integrates with existing library management systems, facilitating easy
implementation and reducing disruption to current library operations.

Through this mini project, we aim to contribute to the modernization of college library
services, making them more efficient, accessible, and user-friendly. By embracing technology,
educational institutions can better meet the evolving needs of their academic community and
enhance the overall learning experience.
TABLE OF CONTENTS

SERIAL NO. CHAPTER PAGE NO.


1 INTRODUCTION 1

1.1 Overview 1

1.2 Applications 2

2 LITERATURE SURVEY 3

2.1 Introduction 3

2.2 Existing System 4

2.3 Limitations 4
PROPOSED SYSTEM
3 5
AND ITS OBJECTIVES
3.1 Problem Statement 5
Objectives of the proposed
3.2 5
system
3.3 Proposed Solution 6

3.4 Methodology 6
SYSTEM
4 7
REQUIREMENTS
User software and
4.1 7
hardware Requirements
Development software
4.2 7
requirements
Development hardware
4.3 7
requirements
5 SYSTEM DESIGN 8

5.1 Software Design 8

6 IMPLEMENTATION 10

6.1 Schema Diagram 10

6.2 E-R Diagram 11

6.3 Node.js Sever side script 12


Python Script (Flask) sever
6.4 19
side script
THE FINAL
7 29
OUTCOMES
7.1 Login Page 29

7.2 New Users 29

7.3 Existing User Login 30

7.4 Home Page 30

7.5 Search Functionality 31

7.6 Logout 31
RESULTS AND
8 32
CONCLUSIONS
REFERENCES 33

TABLE OF FIGURES

SERIAL NO. FIGURE PAGE NO.


Software Design
1 8
Figure 5-a
Schema Diagram
2 10
Figure 6-a
E-R Diagram
3 11
Figure 6-b
Login Page
4 29
Figure 7-a
New Users
5 29
Figure 7-b
Existing User Login
6 30
Figure 7-c
Home Page
7 30
Figure 7-d
Search Functionality
8 31
Figure 7-e
Logout
9 31
Figure 7-f
Smart library Booking System 2023-24

CHAPTER 1

INTRODUCTION

1.1 Overview

A Database Management System (DBMS) is a software system that enables users


to efficiently store, manipulate, retrieve, and manage data in a structured manner. It serves
as an intermediary between the user and the database, providing an interface for users to
interact with the data without needing to understand the complexities of data storage and
retrieval at the low level.

A library system with prebooking functionality, built on a Database Management


System (DBMS), aims to efficiently manage library resources while enhancing user
experience. The primary goal is to ensure that patrons can easily reserve books in advance,
improving accessibility and reducing wait times for popular items. By leveraging the
capabilities of a DBMS, the system maintains a comprehensive database of library
materials, user accounts, and reservation records.

The DBMS facilitates seamless integration of prebooking features with other library
functions, such as catalogue management, circulation, and user authentication. It enables
users to search for books, reserve them, and manage their bookings through a user-friendly
interface. Additionally, the DBMS ensures data integrity and security, safeguarding
sensitive patron information and transaction records.

Prebooking data stored in the DBMS provides valuable insights into user
preferences and demand patterns, enabling libraries to optimize collection development and
resource allocation strategies. Libraries can allocate resources efficiently, ensuring that
high-demand items are readily available while minimizing unnecessary duplication of less
popular materials.

Furthermore, the DBMS automates various aspects of the prebooking process, such
as notifications, reminders, and inventory management, streamlining library operations and
reducing administrative burden. Overall, the integration of prebooking functionality into a
library system powered by a DBMS enhances user satisfaction, promotes efficient resource
management, and improves the overall effectiveness of library services.

APSCE DEPT OF CSE 1


Smart library Booking System 2023-24
1.2 Applications
1. Improved User Experience:
Users can prebook books they want to borrow, ensuring they are
available when needed. This reduces frustration from finding books already
checked out or unavailable on the shelves.

2. Efficient Resource Management:


Prebooking helps libraries anticipate demand for popular books and allocate
resources accordingly. Library staff can optimize collection development and
procurement based on prebooking data, ensuring sufficient copies of high-demand
items.

3. Reduced Wait Times:


Prebooking allows users to reserve books in advance, reducing wait times
for popular titles. Users can plan their reading schedules and have books ready for
pickup as soon as they become available.

4. Data-driven Decision Making:


Prebooking data provides valuable insights into user preferences, reading
trends, and collection usage. Libraries can analyse prebooking patterns to tailor
collection development, programming, and outreach efforts to meet the needs of
their patrons.

5. Feedback collection:
Prebooking systems provide opportunities for users to provide feedback on
library collections and services. Libraries can gather user comments and
suggestions to continuously improve their offerings and enhance user satisfaction.

6. Enhanced Accessibility:
Prebooking facilitates access to library materials for users with busy
schedules or limited mobility. They can reserve books online and pick them up at
their convenience, eliminating the need for multiple trips to the library.

APSCE DEPT OF CSE 2


Smart library Booking System 2023-24

CHAPTER 2

LITERATURE SURVEY
2.1 Introduction
Literature survey is the most important step in the software development
process. Before developing any tool, it is very necessary to determine the time factor,
economy and other essential requirements of the design. Once these things are satisfied,
then next steps are to determine which operating system and languages can be used for
developing the tools.

Online books booking systems play a crucial role in modern libraries and College
Libraries, providing users with convenient access to a wide range of titles. These systems
typically include features such as book search, availability checking, and pre-ordering
capabilities. Research by Gnanesh V S highlights the importance of efficient inventory
management and user-friendly interfaces in enhancing the online book ordering experience.

Modern library management systems offer comprehensive solutions for managing


library resources, including books, journals, and multimedia materials. Key functionalities
include inventory management, book reservation, and user account management. Survey
by Basha E emphasize the role of integrated library systems in streamlining library
operations and improving user access to library resources.

User experience (UX) is a critical aspect of online book services, influencing user
satisfaction and engagement. Research by Alfiya Hassan identifies factors such as ease of
use, accessibility, and personalized recommendations as key determinants of user
satisfaction in online book services. Implementing intuitive interfaces and responsive
customer support systems can contribute to a positive user experience.

The convention Library System in context of a college library includes students


going into library without checking the desired book is available in the library this causes
wastage of time. If the book is not available in the library, then the student may have to
visit the library every time to check the availability of a desired book in the library.

Checking the availability itself may be a laborious task. Survey by Abhinav Naik
highlights that there must be some system that has to incorporated in order make this task
easier and time efficient.

APSCE DEPT OF CSE 3


Smart library Booking System 2023-24
2.2 Existing System

College Library, the current college library system operates within a traditional
framework, where users physically visit the library to borrow books without prior
knowledge of the availability of specific titles. However, in the current landscape of
technological advancements, AI-driven chatbots have emerged as notable tools in various
applications, showcasing capabilities in automated responses and user interactions.

2.3 Limitations

1. Limited Accessibility: Users need to physically visit the library to check the
availability of books, which can be inconvenient, especially for those with busy
schedules or limited mobility.
2. Time Consuming: Searching for books in the library without prior knowledge of
their availability can be time-consuming, particularly if the desired book is not in
stock or is misplaced.
3. Uncertainty: Users may experience uncertainty about the availability of desired
books, leading to frustration and wasted time if the books are not available when
they visit the library.
4. Inefficient Resource Utilization: Without prior knowledge of book availability,
users may make unnecessary trips to the library, resulting in inefficient resource
utilization and increased foot traffic in the library.
5. Limited Information: Users may not have access to comprehensive information
about the library's collection, including new arrivals, popular titles, or related
resources, which could enrich their academic or personal interests.
6. Inconvenient Reservation Process: If a book is unavailable, users may need to go
through a manual reservation process, which can be cumbersome and time-
consuming, potentially leading to delays in accessing the desired resources.
7. Risk of Disappointment: Users may experience disappointment or frustration if
they are unable to find the books they need during their library visit, negatively
impacting their academic or research activities.
8. Difficulty in Planning: Without knowing the availability of specific books in
advance, users may find it challenging to plan their study or research projects
effectively, leading to suboptimal outcomes.

APSCE DEPT OF CSE 4


Smart library Booking System 2023-24

CHAPTER 3

PROPOSED SYSTEM AND ITS OBJECTIVES

3.1 Problem Statement


In the current operational framework of our college library, students frequently
encounter inefficiencies and time wastage due to the conventional approach of physically
visiting the library to check the availability of desired books. This practice not only
consumes valuable student time but also poses logistical challenges, especially when the
desired book is unavailable. As highlighted by the survey conducted by Abhinav Naik,
there is a pressing need for the integration of a more streamlined and technologically
advanced system to alleviate these issues.

Key Issues:

1. Inefficient Resource Utilization: The existing system relies heavily on manual


processes, leading to inefficiencies in resource allocation and utilization within the
library.
2. Time Consumption: Students are required to physically visit the library to
ascertain the availability of desired books, resulting in unnecessary time
expenditure and disruptions to their academic schedules.
3. Lack of Real-Time Information: The absence of a centralized digital platform
limits students' access to real-time information regarding the availability of library
resources, leading to frustration and inconvenience.

3.2 Objectives of the proposed system

The primary objective of this study is to develop and implement a comprehensive


digital library system that enhances efficiency, accessibility, and user experience within the
college library environment. By leveraging modern technologies and automation, the
proposed system aims to streamline the process of book availability checks, facilitate
remote access to library resources, and optimize resource management.

APSCE DEPT OF CSE 5


Smart library Booking System 2023-24
3.3 Proposed Solution
The proposed solution entails the development and integration of a user-friendly
digital library system equipped with features such as real-time catalogue updates, online
reservation capabilities, and personalized user accounts. By transitioning from manual to
automated processes, the system will empower students to conveniently access library
resources from any location, thereby reducing reliance on physical visits and minimizing
time wastage. Additionally, the implementation of data analytics tools will enable the
library administration to gain insights into usage patterns, demand trends, and resource
allocation needs, thereby facilitating informed decision-making and resource optimization.
3.4 Methodology

1. Database Setup:
o Create a database with tables for books, users, transactions, and
reservations.
o Each table should have fields for relevant information like book title,
author, availability status, user details, etc.
2. User Interface Development:
o Develop a simple interface for students to search for books and check their
availability.
o Implement a login system for users and librarians to access the system.
3. Book Availability Tracking:
o Update the availability status of books in real-time as they are borrowed or
returned.
o Enable users to see if a book is available before visiting the library.
4. Reservation System:
o Allow users to reserve books that are currently unavailable.
o Notify users when reserved books become available.
5. Security Measures:
o Implement basic security measures like encryption of sensitive data and
user authentication.
6. Testing and Deployment:
o Test the system thoroughly to ensure functionality and usability.
o Deploy the system and provide training to users and librarians.

APSCE DEPT OF CSE 6


Smart library Booking System 2023-24

CHAPTER 4

SYSTEM REQUIREMENTS

4.1 User software and hardware Requirements.

1. Browser: Firefox, Chrome, Bing, Internet explorer etc

2. RAM: 2GB.

3. Javascript compatibility in the browser.

4. CPU: A dual core processor for faster loading.

4.2 Development software requirements.

1. Browser: Firefox, Chrome, Bing, Internet explorer etc

2. Javascript: Node.js, express.js and react.js

3.Python: Python 3.12 and Flask

4. HTML and CSS

5. Database: MySQL

6. IDE: VSCode

4.3 Development hardware requirements.

1. Processor: A quad core processor preferably an intel APU.

2. RAM: 4GB

3. Storage: 1GB

APSCE DEPT OF CSE 7


Smart library Booking System 2023-24

CHAPTER 5

SYSTEM DESIGN

5.1 Software Design

The below diagram shows a simple representation of the working of


the system the database contains basically 6 tables. The application has 2
kinds of users that is an admin and a student user.

The admin may have complete access over the database and the user
may have limit access over the database.

Figure 5-a

APSCE DEPT OF CSE 8


Smart library Booking System 2023-24

The home page is implemented using HTML and CSS which has 3
interfaces that is for sign in, sign up and admin login. This web application is
a single page web application.

The single page web application is made interactive using React.js including
CSS. The are 2 sever scripts running:

1. To handle the database request after logging in.

2. To handle the login request from the user or the admin.

The first script uses python script with flask API. The second script
uses node.js and express.js to handle login.

The database is created using MySQL through which the data items
are displayed onto the web page. The appropriate references are made between
the relations and the tables.

The database queries make sure that the database is consistent every
state after it is changed. The SQL queries are embedded in to python script
and the node script files so that whenever a request is made the respective SQL
query is executed.

Each user gets a different view of the database like the admin gets the
complete view and the user gets a limited view of the database.

This is the overall software design of the web application.

APSCE DEPT OF CSE 9


Smart library Booking System 2023-24

CHAPTER 6

IMPLEMENTATION

6.1 Schema Diagram

The database contains 6 tables having primary keys and


foreign keys. The tables are shown as follows

Figure 6-a
Here Isbn, loan_id, card_id and author_id are the primary keys.
Authors, Book_authors, Book, Fines, Borrower, Book_loans are the tables.

APSCE DEPT OF CSE 10


Smart library Booking System 2023-24

6.2 E-R Diagram

Figure 6-b

• This E-R diagram represents the relation between various entities in this database.
• Here authors, book, borrower and Fines are entities represented using a rectangle.
• The Book_authors, Borrows and Book_loans are Relations of their entities.
• Each entity has its own primary key and its attributes.

APSCE DEPT OF CSE 11


Smart library Booking System 2023-24
6.3 Node.js Sever side script
const express = require('express');
const bodyParser = require('body-parser');
const session = require('express-session'); // Import express-
session
const pool = require('./db');

const app = express();


const port = 3030;

app.use(bodyParser.urlencoded({ extended: true }));

// Configure express-session middleware


app.use(session({
secret: '231e1eqweqwe', // Change this to a long, random string
resave: false,
saveUninitialized: true
}));
const restrictAuthenticated = (req, res, next) => {
if (req.session && req.session.user) {
// If the user is authenticated, redirect them to the home
page
res.redirect('/home');
} else {
// Otherwise, proceed to the next middleware
next();
}
};

// Middleware to restrict access to unauthenticated users

APSCE DEPT OF CSE 12


Smart library Booking System 2023-24
const restrictUnauthenticated = (req, res, next) => {
if (!req.session || !req.session.user) {
// If the user is not authenticated, redirect them to the
signin page
res.redirect('/signin');
} else {
// Otherwise, proceed to the next middleware
next();
}
};
// Serve static files (e.g., HTML) from a 'public' directory
app.use(express.static('public'));
// Middleware to set cache-control header for sensitive routes
app.use(['/home'], (req, res, next) => {
res.header('Cache-Control', 'no-cache, no-store, must-
revalidate');
next();
});

app.get('/MainPage', (req, res) => {


res.sendFile(__dirname + '/MainPage.html');
});

app.get('/signup',restrictAuthenticated, (req, res) => {


res.sendFile(__dirname + '/signup.html');
});

app.get('/signin',restrictAuthenticated, (req, res) => {


res.sendFile(__dirname + '/signin.html');
});

APSCE DEPT OF CSE 13


Smart library Booking System 2023-24

app.get('/home',restrictUnauthenticated, (req, res) => {


res.sendFile(__dirname + '/home.html');
});
// Handle POST request for form submission
app.post('/SignUpsubmit', (req, res) => {
const query = "SELECT COUNT(card_id) + 1 AS count FROM
borrower;";
const prefix = 'ID';

pool.query(query, (err, rows) => {


if (err) throw err;

const row = rows[0];


let card_id_temp = '';

for (let i = String(row.count).length; i < 6; i++) {


card_id_temp += '0';
}

const card_id = prefix + card_id_temp + row.count;

const { bname, ssn, address, phone } = req.body;

const sql = 'INSERT INTO borrower (card_id, ssn,bname, address,


phone) VALUES (?, ?, ?, ?, ?)';
pool.query(sql, [card_id,ssn,bname, address, phone], (err,
result) => {
if (err) {
console.error('Error inserting data:', err);

APSCE DEPT OF CSE 14


Smart library Booking System 2023-24
res.status(500).send('Error inserting data');
return;
}
res.send('Data inserted successfully');
});
});
});

app.post('/SignInsubmit', (req, res) => {


const { Ssn, Card_id } = req.body;

// Query the database to find the user


pool.query('SELECT * FROM borrower WHERE Ssn = ? AND Card_id =
?',
[Ssn, Card_id],
(err, result) => {
if (err) {
console.error('Error retrieving user data:', err);
return res.status(500).send('Error retrieving user
data');
}

if (result.length === 0) {
// If no user found with provided credentials, render the
signin page again with an error message
return res.status(401).json({ message: 'Invalid email or
password' });
}

APSCE DEPT OF CSE 15


Smart library Booking System 2023-24
// Ensure req.session exists before setting properties on
it
if (!req.session) {
console.error('Session object is not available');
return res.status(500).send('Internal server error');
}

// Store user information in the session


req.session.user = result[0]; // Assuming result is an
array with user data

// Redirect the user to the home page after successful


login
res.redirect('/home');
}
);
});
// Assume you have a route in your Express app to handle fetching
user information
app.get('/getUserInfo', (req, res) => {
// Query the database to fetch user information
// Assuming you have stored user information in the session
const user = req.session.users;
if (user && user.name) {
res.json({ name: user.name });
} else {
res.status(404).send('User not found');
}
});

APSCE DEPT OF CSE 16


Smart library Booking System 2023-24
// Assume you have a route in your Express app to handle fetching
suggestions
app.get('/getSuggestions', (req, res) => {
// Query the database to fetch suggestions
// Example query to fetch suggestions from a 'suggestions'
table
pool.query('SELECT title FROM book', (err, results) => {
if (err) {
console.error('Error fetching suggestions:', err);
return res.status(500).send('Error fetching suggestions');
}
const suggestions = results.map(row => row.title);
res.json(suggestions); // Return suggestions as JSON response
});
});

// Assume you have already imported necessary modules and set up


your Express app

// Route to handle the search query


app.use(bodyParser.json());

// Route to handle search requests


app.post('/search', (req, res) => {
const searchQuery = req.body.searchQuery;

// Execute the SQL query to search for the corresponding


attributes in the "book" table
const sql = `SELECT * FROM book WHERE title LIKE
'%${searchQuery}%'`; // Example SQL query
pool.query(sql, (err, results) => {

APSCE DEPT OF CSE 17


Smart library Booking System 2023-24
if (err) {
console.error('Error executing SQL query:', err);
res.status(500).send('Error executing SQL query');
return;
}
res.status(200).json(results); // Send the search results
back to the client
});
});
// Logout route
app.post('/logout', (req, res) => {
// Destroy the session to log out the user
req.session.destroy((err) => {
if (err) {
console.error('Error destroying session:', err);
res.status(500).send('Error logging out');
return;
}
res.send('Logged out successfully');
});
});

app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});

APSCE DEPT OF CSE 18


Smart library Booking System 2023-24
6.4 Python Script (Flask) sever side script

# server.py
from flask import Flask, render_template
from flask import jsonify
from flask import request
import mysql.connector
import errorCodes
import json
import datetime

app=Flask(__name__,static_folder="../static/dist",
template_folder="../static")

#enter your username and password


cnx = mysql.connector.connect(user='root',
password='root',database='lms',charset='utf8')
cursor = cnx.cursor(prepared=True)

@app.route('/', defaults={'path': ''})


@app.route('/<path:path>')
def index(path):
return render_template("index.html")

@app.route("/addBorrower",methods=['GET', 'POST'])
def addBorrower():
data = request.get_json(force=True)

APSCE DEPT OF CSE 19


Smart library Booking System 2023-24
query = "select count(card_id) + 1 from borrower;"
prefix = 'ID'
cursor.execute(query)
row = cursor.fetchone()
temp = str(row[0])
card_id_temp = ''
for i in range(len(temp),6):
card_id_temp = card_id_temp + '0'
card_id = prefix+card_id_temp+temp
query = "INSERT into
BORROWER(card_id,ssn,bname,address,phone) values(%s,%s,%s,%s,%s)"
response = None
try:

cursor.execute(query,(card_id,data["ssn"],data["name"],data["addr
ess"],data["phone"]))
response = {'message':'Borrower Added','success':True}
cnx.commit()
except mysql.connector.Error as err:
if(err.errno in errorCodes.errorCodeMessage):
response =
{'message':errorCodes.errorCodeMessage[err.errno],'success':False
}
else:
response = {'message':'Borrower Creation
failed','success':False}
return jsonify(response)

@app.route("/searchBook",methods=['GET', 'POST'])
def searchBook():
data = request.get_json(force=True)
searchQuery = data["searchQuery"]

APSCE DEPT OF CSE 20


Smart library Booking System 2023-24
searchResult = []
query1 = 'select b.ISBN from Book b left outer join
BOOK_AUTHORS ba on b.isbn = ba.isbn left outer join authors a on
ba.author_id = a.author_id where b.isbn like %s or b.title like
%s or a.name like %s'

ISBNList = []
try:

cursor.execute(query1,("%"+searchQuery+"%","%"+searchQuery+"%","%
"+searchQuery+"%"))
for row in cursor:
type_fixed_row = tuple([el.decode('utf-8') if
type(el) is bytearray else el for el in row])
ISBNList.append(type_fixed_row[0])
if(len(ISBNList)>0):
ISBN = list(set(ISBNList))
format_strings = '('+','.join(['%s'] * len(ISBN))+')'
query2 = 'select
b.ISBN,b.Title,GROUP_CONCAT(a.name),b.isCheckedOut from Book b
left outer join BOOK_AUTHORS ba on b.isbn = ba.isbn left outer
join authors a on ba.author_id = a.author_id where b.isbn IN ' +
format_strings + ' group by b.isbn'
cursor.execute(query2,tuple(ISBN))
for row in cursor:
type_fixed_row = tuple([el.decode('utf-8') if
type(el) is bytearray else el for el in row])
searchResult.append(type_fixed_row)
response =
{'searchResult':searchResult,'message':'search
success','success':True}
else:
response = {'searchResult':None,'message':'search
success','success':True}
except mysql.connector.Error as err:

APSCE DEPT OF CSE 21


Smart library Booking System 2023-24
if(err.errno in errorCodes.errorCodeMessage):
response =
{'searchResult':None,'message':errorCodes.errorCodeMessage[err.er
rno],'success':False}
else:
response = {'searchResult':None,'message':'search
failed','success':False}
return jsonify(response)

@app.route("/checkoutBook",methods=['GET', 'POST'])
def checkoutBook():
data = request.get_json(force=True)
cardId = data["borrowerId"]
isbn = data["isbn"]
response = None
try:
query = 'select 1 from BORROWER where card_id = %s'
cursor.execute(query,(cardId,))
isBorrower = 0
for row in cursor:
isBorrower = row[0]
if(isBorrower):
query = 'select isCheckedOut from BOOK where isbn =
%s'
isCheckedOut = 1
cursor.execute(query,(isbn,))
for row in cursor:
isCheckedOut = row[0]
query = 'select count(*) >= 3 from BOOK_LOANS where
card_id = %s and date_in is null'
isCountExceeded = 1

APSCE DEPT OF CSE 22


Smart library Booking System 2023-24
cursor.execute(query,(cardId,))
for row in cursor:
isCountExceeded = row[0]
if(isCheckedOut):
response = {'message':'Book already checked
out','success':False}
elif(isCountExceeded):
response = {'message':'Maximum limit of 3
reached. You cannot checkout','success':False}
else:
query1 = 'Insert into BOOK_LOANS
values(0,%s,%s,%s,%s,null)'
query2 = 'update BOOK set isCheckedOut = True
where isbn = %s'
dateOut = datetime.date.today()
dueDate = dateOut + datetime.timedelta(days=14)

cursor.execute(query1,(isbn,cardId,dateOut,dueDate))
cursor.execute(query2,(isbn,))
cnx.commit()
response = {'message':'Book Checked
Out','success':True}
else:
response = {'message':'Invalid Borrower
Id','success':False}
except mysql.connector.Error as err:
if(err.errno in errorCodes.errorCodeMessage):
response =
{'message':errorCodes.errorCodeMessage[err.errno],'success':False
}
else:
response = {'message':'Borrower Creation
failed','success':False}

APSCE DEPT OF CSE 23


Smart library Booking System 2023-24
return jsonify(response)

@app.route("/searchBookLoan",methods=['GET', 'POST'])
def searchBookLoan():
data = request.get_json(force=True)
searchQuery = data["searchQuery"]
searchResult = []
query = 'select
bl.loan_id,bl.isbn,bl.card_id,b.bname,bl.date_out,bl.due_date
from BOOK_LOANS bl join BORROWER b on bl.card_id = b.card_id
where (bl.isbn like %s or bl.card_id like %s or b.bname like %s)
and date_in is null'
try:

cursor.execute(query,("%"+searchQuery+"%","%"+searchQuery+"%","%"
+searchQuery+"%"))
for row in cursor:
type_fixed_row = tuple([el.decode('utf-8') if
type(el) is bytearray else el for el in row])
searchResult.append(type_fixed_row)
response = {'searchResult':searchResult,'message':'search
success','success':True}
except mysql.connector.Error as err:
if(err.errno in errorCodes.errorCodeMessage):
response =
{'searchResult':None,'message':errorCodes.errorCodeMessage[err.er
rno],'success':False}
else:
response =
{'searchResult':None,'message':'searchFailed','success':False}
return jsonify(response)

@app.route("/checkinBook",methods=['GET', 'POST'])
def checkinBook():

APSCE DEPT OF CSE 24


Smart library Booking System 2023-24
data = request.get_json(force=True)
loanId = data["loanId"]
response = None
format_strings = ','.join(['%s'] * len(loanId))
query1 = 'update BOOK_LOANS set date_in = curdate() where
loan_id in (%s)'
query2 = 'update BOOK set isCheckedOut = False where isbn in
(select isbn from BOOK_LOANS where loan_id in (%s))'
try:
cursor.execute(query1%format_strings,tuple(loanId))
cursor.execute(query2%format_strings,tuple(loanId))
cnx.commit()
response = {'message':'Book Checked In','success':True}
except mysql.connector.Error as err:
if(err.errno in errorCodes.errorCodeMessage):
response =
{'message':errorCodes.errorCodeMessage[err.errno],'success':False
}
else:
response = {'message':'Book Check In
fail','success':False}
return jsonify(response)

@app.route("/calculateFines",methods=['GET', 'POST'])
def calculateFines():
response = None
query = 'select loan_id,due_date,date_in from BOOK_LOANS
where date_in > due_date or curdate()> due_date'
cursor.execute(query)
today = datetime.date.today()
rows = cursor.fetchall()
resultSet = []

APSCE DEPT OF CSE 25


Smart library Booking System 2023-24
for row in rows:
if(row[2] == None):
diff = today - row[1]
fine = round(diff.days * 0.25,2)
else:
diff = row[2] - row[1]
fine = round(diff.days * 0.25,2)
try:
query = 'Insert into fines values(%s,%s,%s)'
cursor.execute(query,(row[0],fine,False))
cnx.commit()
response = {'message':'fines updated','success':True}
except mysql.connector.Error as err:
if(err.errno in errorCodes.errorCodeMessage):
if(err.errno==1062):
query = 'update fines set fine_amt = %s where
loan_id = %s and paid = false'
cursor.execute(query,(fine,row[0]))
cnx.commit()
response = {'message':'fines
updated','success':True}
else:
response =
{'message':errorCodes.errorCodeMessage[err.errno],'success':False
}
else:
response = {'message':'Fine calculation
failed','success':False}
return jsonify(response)

@app.route("/fetchFines",methods=['GET','POST'])

APSCE DEPT OF CSE 26


Smart library Booking System 2023-24
def fetchFines():
resultSet = []
try:
query = 'select b.card_id,b.bname,SUM(f.fine_amt) from
fines f join book_loans bl on f.Loan_id = bl.Loan_id join
borrower b on bl.card_id = b.Card_id where f.paid=false group by
bl.Card_id'
cursor.execute(query)
rows = cursor.fetchall()
resultSet = []
childMap = {}
for row in rows:
query = 'select
bl.loan_id,b.bname,f.fine_amt,bl.date_in from fines f join
book_loans bl on f.Loan_id = bl.Loan_id join borrower b on
bl.card_id = b.Card_id where f.paid=false and b.card_id=%s'
cardId = row[0].decode('utf-8')
cursor.execute(query,(cardId,))
childSet = []
for row1 in cursor:
type_fixed_row = tuple([el.decode('utf-8') if
type(el) is bytearray else el for el in row1])
childSet.append(type_fixed_row)
childMap[cardId] = childSet
type_fixed_row = tuple([el.decode('utf-8') if
type(el) is bytearray else el for el in row])
resultSet.append(type_fixed_row)
response =
{'aggregateData':resultSet,'finesDataForCardId':childMap,
'message':'fines update','success':True}
except mysql.connector.Error as err:
if(err.errno in errorCodes.errorCodeMessage):

APSCE DEPT OF CSE 27


Smart library Booking System 2023-24
response =
{'message':errorCodes.errorCodeMessage[err.errno],'success':False
}
else:
response = {'message':'Fines update
failed','success':False}
return jsonify(response)

@app.route("/settleFines",methods=['GET', 'POST'])
def settleFines():
data = request.get_json(force=True)
loanId = data["loanId"]
response = None
format_strings = ','.join(['%s'] * len(loanId))
query = 'update fines set paid = true where loan_id in (%s)'
try:
cursor.execute(query%format_strings,tuple(loanId))
cnx.commit()
response = {'message':'fine settled','success':True}
except mysql.connector.Error as err:
if(err.errno in errorCodes.errorCodeMessage):
response =
{'message':errorCodes.errorCodeMessage[err.errno],'success':False
}
else:
response = {'message':'Fine settlement
failed','success':False}
return jsonify(response)

if __name__ == "__main__":
app.run()

APSCE DEPT OF CSE 28


Smart library Booking System 2023-24

CHAPTER 7
THE FINAL OUTCOMES
7.1 Login Page

Figure 7-a

7.2 New Users

Figure 7-b

APSCE DEPT OF CSE 29


Smart library Booking System 2023-24

7.3 Existing User Login

Figure 7-c

7.4 Home Page

Figure 7-d

APSCE DEPT OF CSE 30


Smart library Booking System 2023-24

7.5 Search Functionality

Figure 7-e

7.6 Logout

Figure 7-f

APSCE DEPT OF CSE 31


Smart library Booking System 2023-24

CHAPTER 8
RESULTS AND CONCLUSIONS
Results:

1. Improved Efficiency: The implementation of the digital library system


significantly reduces the time students spend physically searching for books,
leading to improved efficiency in accessing library resources.
2. Enhanced Accessibility: With the ability to check book availability remotely,
students can access library resources from anywhere, increasing accessibility and
convenience.
3. Streamlined Reservation Process: The reservation system allows students to
reserve books in advance, ensuring they are available when needed and
minimizing disruptions to their academic schedules.
4. Real-time Availability Updates: The system provides real-time updates on the
availability status of books, allowing students to make informed decisions about
when to visit the library.

Conclusions:

1. Positive Impact on User Experience: The digital library system has positively
impacted user experience by reducing time wastage, improving accessibility, and
streamlining the reservation process.
2. Efficiency Gains for Library Staff: The automation of book availability tracking
and reservation management has freed up valuable time for library staff, allowing
them to focus on other tasks and providing better assistance to users.
3. Technological Advancements Enhance Library Services: The successful
implementation of the digital library system demonstrates how leveraging modern
technologies can enhance traditional library services and adapt to the evolving
needs of users.

APSCE DEPT OF CSE 32


Smart library Booking System 2023-24

REFERENCES

• MySQL: https://dev.mysql.com/doc/

• Python: https://www.python.org/doc/

• React.js: https://react.dev/learn

• Node.js: https://nodejs.org/docs/latest/api/

• Express.js: https://expressjs.com/en/5x/api.html

• Flask: https://flask.palletsprojects.com/en/3.0.x/api/

• https://github.com/topics/library-management-system

• https://github.com/topics/library-management-system?l=php&o=asc&s=stars

• Automate the Boring Stuff with Python, 2nd Edition.

• Node.js in Action

• React Quickly: Painless Web Apps with React, JSX, Redux, and GraphQL

APSCE DEPT OF CSE 33

You might also like