Project 3: Library Book Lending & Member Tracking System
Project 3: Library Book Lending & Member Tracking System
For our final Level 1 capstone project, we will design and deploy a complete Library Book Lending & Member Management System. A modern library system tracks members, physical book copies, loans, return deadlines, and overdue penalty calculations.
This project reinforces date arithmetic (DATEDIFF, DATE_ADD), multi-table relational schema design, conditional logic (CASE), and audit tracking.
1. Relational Schema Architecture
+--------------------+ +--------------------+
| members | | books |
+--------------------+ +--------------------+
| member_id (PK) | | book_id (PK) |
| full_name | | title |
| membership_date | | isbn (UQ) |
+--------------------+ | total_copies |
| | available_copies |
| 1 +--------------------+
| | 1
| N | N
+----------------------------------------------------+
| loan_records |
+----------------------------------------------------+
| loan_id (PK) |
| member_id (FK -> members) |
| book_id (FK -> books) |
| borrowed_date |
| due_date |
| returned_date (NULL if currently on loan) |
+----------------------------------------------------+2. Step 1: DDL Table Creation
3. Step 2: Sample Data Population
4. Step 3: Real-World Administrative Queries
5. Grand Summary of Level 1 Achievement
Congratulations! You have completed Level 1: SQL & MySQL for Beginners. You have mastered:
- Relational database fundamentals and MySQL architecture.
- Full DDL database and table lifecycles (
CREATE,ALTER,DROP,TRUNCATE). - Integrity constraints (Primary Keys, Foreign Keys, Unique, Not Null, Check).
- DML manipulation (
INSERT,UPDATE,DELETE, Upsert). - DQL querying, sorting, pagination, scalar functions, grouping, and aggregations.
- You are now ready to tackle Level 2: SQL & MySQL for Intermediate!
Multiple Choice Questions
1. In Query 1, how are overdue book loans identified?
A. WHERE returned_date IS NOT NULL B. WHERE returned_date IS NULL AND due_date < CURRENT_DATE() C. WHERE loan_id > 10 D. WHERE due_date > borrowed_date Answer: B Explanation: An active loan has returned_date IS NULL. If the current date is past the due_date, the book is overdue.
2. What does DATEDIFF(date1, date2) * 10.00 calculate in Query 1?
A. The number of pages read B. The overdue fine accumulated at ₹10 per day late C. The member's annual subscription fee D. The retail price of the book Answer: B Explanation: DATEDIFF() computes the number of days elapsed beyond the due date, which multiplied by 10 yields the late fine in rupees.
3. What constraint on the books table guarantees that available_copies can never exceed total_copies?
A. FOREIGN KEY B. CHECK (available_copies <= total_copies) C. UNIQUE D. AUTO_INCREMENT Answer: B Explanation: The CHECK constraint actively enforces that available physical inventory cannot exceed the total registered book stock.
4. When a member returns a borrowed book, what two database actions must occur?
A. The table is truncated and rebuilt B. The loan record's returned_date is updated, and the book's available_copies count is incremented by 1 C. The member is deleted from the database D. The book's ISBN is changed Answer: B Explanation: Completing a return updates the transaction record with the return date and restores the book's available copy count in the catalog.
5. Why is returned_date initialized as NULL when a new loan is recorded?
A. Because NULL represents an active, uncompleted loan where the return event has not yet occurred B. Because MySQL cannot store dates before the year 2026 C. To save disk space D. Because loans are illegal Answer: A Explanation: NULL denotes the absence of data, indicating that the book has been checked out but not yet returned.
Related Lessons
| Previous Lesson | Next Lesson |
|---|---|
| Project 2: Retail Store Inventory Management System | None |
Practice Quiz
Test your understanding of this lesson with 5 questions. Each question has one correct answer.