Batch2_DBMS
Batch2_DBMS
taKA
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.
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.
• Users and Fines have a one-to-many relationship, as a User can have multiple Fines, but each
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;
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");
OUTPUT :
Insertion:
6 Batch
:2
OUTPUT:
7 Batch
:2
(1, 'F. Scott Fitzgerald'),
(12, 'Homer'),
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:
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:
VALUES
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:
VALUES
11
Batch :2
QURIES:
1).Retrieve the names and email addresses of all users.
12
Batch :2
3).Retrieve the count of books in each genre.
13
Batch :2
4).Retrieve books and their authors
FROM Books
14
Batch :2
5).Retrieve users who have fines greater than Rs.5/-
FROM Users
SELECT Users.name
FROM Users
OUTPUT:
15
Batch :2
SELECT Users.name, SUM(Fines.amount) AS total_fine
FROM Users
SELECT name
FROM Users
OUTPUT:
FROM Books
16
Batch :2
LEFT JOIN Reservations ON Books.book_id = Reservations.book_id
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:
• email → user_id
2. Books Table:
• author_id → author_name
3. Authors Table:
• author_id → author_name
4. Borrowings Table:
5. Reservations Table:
6. Fines Table:
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.
• 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.
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.
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
21
Batch :2
THANK YOU
22
Batch :2