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

Batch2_DBMS

The document outlines the design and implementation of a Library Management System (LMS) aimed at automating library operations such as user and book management, borrowing, reservations, and fines. It details the challenges faced by the current manual system and proposes a comprehensive solution with an entity-relationship model, database schemas, and SQL queries for data manipulation. The LMS is expected to enhance user experience, improve operational efficiency, and ensure accurate record-keeping.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Batch2_DBMS

The document outlines the design and implementation of a Library Management System (LMS) aimed at automating library operations such as user and book management, borrowing, reservations, and fines. It details the challenges faced by the current manual system and proposes a comprehensive solution with an entity-relationship model, database schemas, and SQL queries for data manipulation. The LMS is expected to enhance user experience, improve operational efficiency, and ensure accurate record-keeping.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 23

ruswetha rus

Under the Esteemed Guidance of


Mrs.D.Gayatri
Mrs.M.Syamala Kumari

taKA

DEPARTMENT OF INFORMATION TECHNOLOGY

MAHARAJ VIJAYARAM GAJAPATHI RAJ COLLEGE OF


ENGINEERING
(AUTONOMOUS)

VIZTAIANAGARAM-535005,AP(INDIA)

Abstract:
To manage Library, there is a need for an Library Management System (LMS) to efficiently manage
library operations, including user ma.nagement, book management, borrowing and returning books,
reservations, and fines. The current manual system is time-consuming, error-prone, and lacks proper
tracking mechanisms. There is a need for a comprehensive LMS that automates these processes to
enhance user experience, improve operational efficiency, and ensure accurate record-keeping.

The key challenges are:


Management: The system should provide functionality to register new users, store their personal
information (such as name, email, and password), and allow users to update their information as
needed.

1. Book Management: The LMS needs to keep track of the available books, their authors,
genres, publication dates, and other relevant details. It should facilitate the addition of new books and
allow for updates or removal of existing books.

2. Borrowing and Returning: The LMS should support the borrowing and returning of
books by users. It should allow users to check out books, record borrowing details (such as borrow
date and return date), and handle returns or extensions based on predefined rules and policies.

3. Reservations: The system should provide the ability for users to reserve books that are
currently unavailable. It should maintain a reservation queue and automatically assign reserved books
to users when they become available, notifying them of the availability.

4. Fines Management: The LMS needs to handle fines for late returns or other violations. It
should calculate and track fines based on predefined rules, generate fine notifications, and provide
functionality to collect and manage fine payments from users.

The Library Management System (LMS) aims to streamline library operations, improve user
satisfaction, and ensure efficient management of books, users, borrowings, reservations, and fines. By
automating these processes, it will eliminate manual errors, save time, and provide accurate and up-
todate information for effective library management.

ER DIAGRAM:

1 Batch
:2
Library

Management Sy

rus

Entities:

2 Batch
:2
Users: Represents the individuals who use the library system. Users typically have attributes such as
user_id, name, email, and password.

Books: Represents the collection of books in the library. Each book entity may have attributes like
book_id, title, genre, and publication_date.

Authors: Represents the authors of the books in the system. The author entity might have attributes
such as author_id and author_name. bnmbhvhk

Borrowings: Represents the instances when a user borrows a book from the library. Borrowings entity
can contain details like borrowing_id, user_id, book_id, borrow_date, and return_date.

Reservations: Represents the instances when a user reserves a book to be borrowed in the future.
Reservations entity may contain attributes like reservation_id, user_id, book_id, and reservation_date.

Fines: Represents any fines imposed on users for late returns or violations of library policies. The
Fines entity might include attributes like fine_id, user_id, fine_amount, and fine_date.

Entity Relationships:
• Users and Borrowings have a one-to-many relationship, as a User can have multiple
Borrowings, but a Borrowing belongs to one User.

• Users and Reservations also have a one-to-many relationship, as a User can have multiple
Reservations, but a Reservation belongs to one User.

• Books and Authors have a many-to-many relationship, as a Book can have multiple Authors,
and an Author can be associated with multiple Books.

• Books and Borrowings have a one-to-many relationship, as a Book can be borrowed multiple
times, but each Borrowing is associated with one Book.

• Books and Reservations a one-to-many relationship, as a Book can be reserved multiple


times, but each Reservation is associated withj one Book.

• Users and Fines have a one-to-many relationship, as a User can have multiple Fines, but each

Fine belongs to one User.

Schemas :

3 Batch
:2
• Users ( user_id INT PRIMARY KEY, name VARCHAR(255), email VARCHAR(255),
password VARCHAR(255));
• Books ( book_id INT PRIMARY KEY, title VARCHAR(255), author_id INT, genre
VARCHAR(255), publication_date DATE, FOREIGN KEY (author_id) REFERENCES
Authors(author_id));
• Authors ( author_id INT PRIMARY KEY, author_name VARCHAR(255));
• Borrowings ( borrowing_id INT PRIMARY KEY, user_id INT,book_id INT,borrow_date
DATE,return_date DATE,FOREIGN KEY (user_id) REFERENCES
Users(user_id),FOREIGN KEY (book_id) REFERENCES Books(book_id));
• Reservations ( reservation_id INT PRIMARY KEY,user_id INT,book_id
INT,reservation_date DATE, FOREIGN KEY (user_id) REFERENCES Users(user_id),
FOREIGN KEY (book_id) REFERENCES Books(book_id));

• Fines (fine_id INT PRIMARY KEY,user_id INT, amount DECIMAL(10, 2), fine_date
DATE,FOREIGN KEY (user_id) REFERENCES Users(user_id));

4 Batch
:2
DataBase Creation
create database Library; use

Library;

Create Users Table


CREATE TABLE Users (user_id INT PRIMARY KEY, name VARCHAR(255), email
VARCHAR(255), password VARCHAR(255)); Data Insertion:

INSERT INTO Users (user_id, name, email, password)

VALUES (1267,"Manoj","[email protected]","Manoj@123"),

(1268,"Nikhil","[email protected]","Nikhil@123"),

(1269,"Jai","[email protected]","Jaij@123"),

(1270,"Ramesh","[email protected]","Ramesh@123"),

(1283,"Mani","[email protected]","Mani@123"),

(1288,"Rupas","[email protected]","rupas@123"),

(1295,"gowtham","[email protected]","Gowtham@123"),

(12128,"Prasanna","[email protected]","Prasanna@123");

SELECT * FROM Users;

OUTPUT :

Create Books table


5 Batch
:2
CREATE TABLE Books ( book_id INT PRIMARY KEY, title VARCHAR(255), author_id INT,
genre VARCHAR(255),publication_date DATE, FOREIGN KEY (author_id) REFERENCES
Authors(author_id)); Data

Insertion:

INSERT INTO Books (book_id, title, author_id, genre, publication_date)

VALUES (1, 'The Great Gatsby', 1, 'Fiction', '2020-01-01'),

(2, 'To Kill a Mockingbird', 2, 'Fiction', '1960-07-11'),

(3, '1984', 3, 'Dystopian', '1949-06-08'),

(4, 'Pride and Prejudice', 4, 'Romance', '1813-01-28'),

(5, 'The Catcher in the Rye', 5, 'Coming-of-Age', '1951-07-16'),

(6, 'The Great Gatsby', 1, 'Fiction', '1925-04-10'),

(7, 'The Hobbit', 7, 'Fantasy', '1937-09-21'),

(8, 'Moby-Dick', 8, 'Adventure', '1851-10-18'),

(9, 'The Lord of the Rings', 7, 'Fantasy', '1954-07-29'),

(10, 'The Shining', 9, 'Horror', '1977-01-28'),

(11, 'The Alchemist', 10, 'Adventure', '1988-01-01'),

(12, 'Brave New World', 11, 'Science Fiction', '1932-01-01'),

(13, 'The Odyssey', 12, 'Epic Poetry', '001-01-08'),

(14, 'The Road', 13, 'Post-Apocalyptic', '2006-09-26'),

(15, 'Wuthering Heights', 14, 'Gothic Fiction', '1847-12-20'),

(16, 'The Da Vinci Code', 15, 'Mystery', '2003-03-18'),

(17, 'The Grapes of Wrath', 16, 'Historical Fiction', '1939-04-14'),

(18, 'Siddhartha', 17, 'Spirituality', '1922-01-01'),

(19, 'The Hunger Games', 18, 'Young Adult', '2008-09-14'),

(20, 'The Road Not Taken', 19, 'Poetry', '1916-08-19'),

(21, 'The Name of the Wind', 20, 'Fantasy', '2007-03-27'),

(22, 'The Martian', 21, 'Science Fiction', '2011-09-27'),

(23, 'One Hundred Years of Solitude', 22, 'Magical Realism', '1967-05-30'),

(24, 'The Picture of Dorian Gray', 23, 'Gothic Horror', '1890-07-01'),

(25, 'The Chronicles of Narnia', 7, 'Fantasy', '1950-10-16');

SELECT * FROM Books;

6 Batch
:2
OUTPUT:

Create Authors table

CREATE TABLE Authors (author_id INT PRIMARY KEY, author_name VARCHAR(255));


Data Insertion:

INSERT INTO Authors VALUES (2, 'Harper Lee'),

(3, 'George Orwell'),

(4, 'Jane Austen'),

(5, 'J.D. Salinger'),

7 Batch
:2
(1, 'F. Scott Fitzgerald'),

(8, 'Herman Melville'),

(9, 'Stephen King'),

(10, 'Paulo Coelho'),

(11, 'Aldous Huxley'),

(12, 'Homer'),

(13, 'Cormac McCarthy'),

(14, 'Emily Brontë'),

(15, 'Dan Brown'),

(16, 'John Steinbeck'),

(17, 'Hermann Hesse'),

(18, 'Suzanne Collins'),

(19, 'Robert Frost'),

(20, 'Patrick Rothfuss'),

(21, 'Andy Weir'),

(22, 'Gabriel García Márquez'),

(23, 'Oscar Wilde'),

(7, 'C.S. Lewis');

SELECT * FROM Authors;

OUTPUT:

8 Batch
:2
Create Borrowings table
CREATE TABLE Borrowings (borrowing_id INT PRIMARY KEY, user_id INT, book_id
INT, borrow_date DATE, return_date DATEFOREIGN KEY (user_id)
REFERENCES Users(user_id), FOREIGN KEY (book_id) REFERENCES Books(book_id));
Data Insertion:

INSERT INTO Borrowings (borrowing_id, user_id, book_id, borrow_date, return_date) VALUES

(1, 1267, 2, '2023-10-15', '2023-10-25'),

(2, 1268, 3, '2023-10-16', '2023-10-26'),

(3, 1269, 4, '2023-10-17', '2023-10-27'),

(4, 1270, 5, '2023-10-18', '2023-10-28'),

(5, 1283, 6, '2023-10-19', '2023-10-29'),

(6, 1288, 7, '2023-10-20', '2023-10-30'),

(7, 1295, 8, '2023-10-21', '2023-10-31'),

(8, 12128, 9, '2023-10-22', '2023-11-01');

SELECT * FROM Borrowings;

OUTPUT:

9 Batch
:2
Create Reservations table
CREATE TABLE Reservations (reservation_id INT PRIMARY KEY, user_id INT, book_id
INT, reservation_date DATE, FOREIGN KEY (user_id) REFERENCES Users(user_id),
FOREIGN KEY (book_id) REFERENCES Books(book_id));
Data Insertion:

INSERT INTO Reservations (reservation_id, user_id, book_id, reservation_date)

VALUES

(1, 1267, 2, '2023-10-25'),

(2, 1268, 3, '2023-10-26'),

(3, 1269, 4, '2023-10-27'),

(4, 1270, 5, '2023-10-28'),

(5, 1283, 6, '2023-10-29'),

(6, 1288, 7, '2023-10-30'),

(7, 1295, 8, '2023-10-31'),

(8, 12128, 9, '2023-11-01');

SELECT * FROM Reservations;

OUTPUT:

10
Batch :2
Create Fines table
CREATE TABLE Fines (fine_id INT PRIMARY KEY, user_id INT, book_id INT,
fine_amount DECIMAL(10, 2),FOREIGN KEY (user_id) REFERENCES Users(user_id),
FOREIGN KEY (book_id) REFERENCES Books(book_id));
Data Insertion:

INSERT INTO Fines (fine_id, user_id, amount, fine_date)

VALUES

(1, 1267, 5.00, '2023-10-25'),

(2, 1268, 3.50, '2023-10-26'),

(3, 1269, 7.00, '2023-10-27'),

(4, 1270, 8.00, '2023-10-28'),

(5, 1283, 6.50, '2023-10-29'),

(6, 1288, 4.25, '2023-10-30'),

(7, 1295, 9.75, '2023-10-31'),

(8, 12128, 2.75, '2023-11-01');

SELECT * FROM Fines; OUTPUT:

11
Batch :2
QURIES:
1).Retrieve the names and email addresses of all users.

SELECT name, email FROM Users;


OUTPUT:

2). Retrievethe books which werepublished before 2000


.

SELECT * FROM Books WHERE publication_date < '2000-01-01'; OUTPUT:

12
Batch :2
3).Retrieve the count of books in each genre.

SELECT genre, COUNT(*) AS book_count FROM Books GROUP BY genre;

13
Batch :2
4).Retrieve books and their authors

SELECT Books.title, Authors.author_name

FROM Books

INNER JOIN Authors ON Books.author_id = Authors.author_id; OUTPUT:

14
Batch :2
5).Retrieve users who have fines greater than Rs.5/-

SELECT Users.name, Fines.amount

FROM Users

INNER JOIN Fines ON Users.user_id = Fines.user_id

WHERE Fines.amount > 5.00; OUTPUT:

6).Retrieve the users who have made reservations

SELECT Users.name

FROM Users

INNER JOIN Reservations ON Users.user_id = Reservations.user_id;

OUTPUT:

7).Calculate the total fine amount for each user

15
Batch :2
SELECT Users.name, SUM(Fines.amount) AS total_fine

FROM Users

LEFT JOIN Fines ON Users.user_id = Fines.user_id

GROUP BY Users.name; OUTPUT:

8).Retrieve users with no fines

SELECT name

FROM Users

WHERE user_id NOT IN (SELECT user_id FROM Fines); OUTPUT:

9).Retrieve the average fine amount SELECT

AVG(amount) AS average_fine FROM Fines;

OUTPUT:

10).Retrieve books and the number of reservations for each book

SELECT Books.title, COUNT(Reservations.reservation_id) AS reservation_count

FROM Books
16
Batch :2
LEFT JOIN Reservations ON Books.book_id = Reservations.book_id

GROUP BY Books.title; OUTPUT:

Normalisation:

17
Batch :2
Functional Dependency :Functional dependencies in a relational database describe the
relationships between attributes (columns) in a table. They help to ensure data integrity and
guide the normalization process.

1. Users Table:

• user_id → {name, email, password}

• email → user_id

2. Books Table:

• book_id → {title, author_id, genre, publication_date}

• author_id → author_name

3. Authors Table:

• author_id → author_name

4. Borrowings Table:

• borrowing_id → {user_id, book_id, borrow_date, return_date}

• user_id → {name, email, password}

• book_id → {title, author_id, genre, publication_date}

5. Reservations Table:

• reservation_id → {user_id, book_id, reservation_date}

• user_id → {name, email, password}

• book_id → {title, author_id, genre, publication_date}

6. Fines Table:

• fine_id → {user_id, amount, fine_date}

• user_id → {name, email, password}

18
Batch :2
These functional dependencies describe how the attributes in each table depend on one
another. In database, I've established relationships through primary keys and foreign keys to
maintain data consistency and integrity. These functional dependencies also guide the
process of normalizing the tables to eliminate redundancy and ensure that data is stored
efficiently.

Normalisation to Books Table:

The functional dependencies for the "Books" table are

• book_id → {title, author_id, genre, publication_date}

• author_id → author_name (from the Authors table)

1NF (First Normal Form):

• In 1NF, a table must have atomic values, meaning that each cell (intersection of a row
and column) contains a single, indivisible value.

• The "Books" table satisfies 1NF because each of its attributes (columns) contains
atomic values. For example, "title," "author_id," "genre," and "publication_date" each
contain single, indivisible values.

2NF (Second Normal Form):

In 2NF, a table must meet the criteria for 1NF, and all non-key attributes must be fully
functionally dependent on the entire primary key.

In the "Books" table, the primary key is "book_id," and all non-key attributes (title,
author_id, genre, publication_date) are fully functionally dependent on "book_id."
Therefore, it satisfies 2NF.

19
Batch :2
3NF (Third Normal Form):

In 3NF, a table must meet the criteria for 2NF, and it should not have any transitive
dependencies. A transitive dependency occurs when a non-key attribute depends on another
non-key attribute.

The "Books" table has a transitive dependency between "author_id" and "author_name"
because "author_id" determines "author_name." However, this is resolved by having a
separate "Authors" table, ensuring that there are no transitive dependencies in the "Books"
table.
Therefore, it satisfies 3NF.

BCNF (Boyce-Codd Normal Form):

In BCNF, a table must meet the criteria for 3NF, and for any non-trivial functional
dependency X → Y, X must be a superkey. In other words, X must be able to uniquely
determine Y.

The "Books" table satisfies BCNF because it has a single-column primary key "book_id," and
all non-key attributes (title, author_id, genre, publication_date) are fully functionally
dependent on "book_id." There are no non-trivial functional dependencies that violate BCNF
in this table.

In summary, the "Books" table is in 1NF, 2NF, 3NF, and BCNF. It is well-structured and free
from redundancy, and the relationships between its attributes are well-defined and logically
sound. This level of normalization ensures data integrity and database consistency.

20
Batch :2
Conclusion:
In conclusion, the Library Management System project stands as a testament to the transformative
power of technology in improving library services. By addressing the challenges of manual processes,
it has ushered in a new era of efficiency, convenience, and data-driven decision-making. This project
exemplifies the library's commitment to evolving with the times and remaining a valuable community
resource.

References:
BOOK:"Database Management Systems" by Raghu Ramakrishnan and Johannes Gehrke

Online Resorse: https://dev.mysql.com/doc/

21
Batch :2
THANK YOU

22
Batch :2

You might also like