MySQL_Library_Management_Project
MySQL_Library_Management_Project
Project Overview
Objective: Design and implement a relational database for a library system,
including tables, constraints, transactions, joins, views, and other MySQL concepts. This
project
will help students learn and practice fundamental MySQL features in a real-world
scenario.
2. Constraints
Constraints:
- Ensure book_id, author_id, member_id, and loan_id have appropriate Primary Keys and
Foreign Key constraints.
- In the Books table, ensure the publication_year is between 1800 and the current year.
- In the Members table, ensure the email column has a valid email format using a
CHECK constraint on the pattern.
- In the Loans table, ensure that return_date is either NULL or greater than loan_date to
avoid inconsistencies.
2. Left Join:
- Write a query to display all members and the books they have currently loaned (if any).
Include members who haven’t borrowed any books.
4. Subqueries:
- Write a query to find the books that were published in the same year as the oldest book
in the library.
5. Views:
- Create a view called borrowed_books that lists all currently loaned books with columns:
title, member_name, loan_date.
2. Error Handling:
- Handle potential errors like duplicate member registration (e.g., unique constraint on
email).
- Use Stored Procedures to wrap this functionality, allowing members to borrow and
return books with error handling for availability and constraints.
2. Triggers:
- Create a trigger to automatically update the return_date in Loans when a book is
returned. This trigger should ensure that return_date is set to the current date once the
book is marked as returned.
3. Stored Procedures:
- Write a stored procedure borrow_book(member_id, book_id) to manage the borrowing
transaction, with checks for availability.
- Write another stored procedure return_book(loan_id) to handle book returns, setting
return_date to the current date.
2. Documentation:
- Write a brief document (one page per part) explaining:
- What each part of the project does.
- Example SQL statements for each query.
- Explanations of any stored procedures, triggers, and views created.
3. Project Presentation:
- Each student should prepare a short presentation (5-10 minutes) to showcase their
solution, highlighting the structure, queries, and additional features they’ve implemented.