Question

Consider a “Library Management System” which keeps the following tables: Book (isbn-no, book-title, author, publisher, edition, year-of-copyright) BookAccession (accession-no, isbn-no, date-of-purchase) Members (m-id, m-name, m-address, m-phone). Issue-return (accession-no, m-id, expected-date-of-return, actual-date-of-return) 7 Please note that a member can be issued a book for a period of 15 days. The actual-date-of-return is kept blank for the books that have not been returned. Write and run the following SQL queries on the tables:

(i) Find the m-id and m-name of the members who have got maximum number of un-returned books

(ii) List the book details along with the number of copies for that book in the library (issued or notissued both)

(iii) Find the names of all those students who have got all the books issued to him of the author named “ABC” .

(iv) Find the books that are expected to be returned in this week.

(v) Find those members who have not got any book issued to him/her during last six months.

15 Sep 2022
Answer :
Word Count : 629

(i) To find the m-id and m-name of the members who have got the maximum number of un-returned books, we can use the following SQL query:


SELECT i.m-id, m.m-name, COUNT(*) AS num_unreturned_books
FROM Issue_return i
INNER JOIN Members m ON i.m-id = m.m-id
WHERE i.actual-date-of-return IS NULL
GROUP BY i.m-id, m.m-name
HAVING COUNT(*) = (SELECT MAX(num_unreturned_books_count) FROM (SELECT COUNT(*) AS num_unreturned_books_count FROM Issue_return WHERE actual-date-of-return IS NULL GROUP BY m-id) AS unreturned_books_counts)
This query first joins the Issue_return and Members tables based on the m-id column. It then filters the rows where the actual-date-of-return column is NULL, i.e., the books have not been returned. It groups the results by m-id and m-name, and counts the number of un-returned books for each member. It then uses a subquery to find the maximum number of un-returned books, and returns the m-id and m-name for the members who have that number of un-returned books.

(ii) To list the book details along with the number of copies for that book in the library (issued or not-issued both), we can use the following SQL query:


SELECT b.isbn-no, b.book-title, b.author, b.publisher, b.edition, b.year-of-copyright, COUNT(*) AS num_copies
FROM Book b
LEFT JOIN BookAccession ba ON b.isbn-no = ba.isbn-no
GROUP BY b.isbn-no, b.book-title, b.author, b.publisher, b.edition, b.year-of-copyright
This query joins the Book and BookAccession tables based on

___ ____ ____ _____ ______ __________.
__________ ______ _______ ____ ___.
__________ ______ _________ _______ ______ ___ ______ ___ _______ ___ _______ __________.
_____ ________ ___ ______ _________ ________ ________ ___.
_______ __________ ___ _______ ________ _______ _____.
________ ______ _____ ____ ________ _________ _________.
_____ _______ _____ _____ ____ ________ _________.
___ ______ ____ ____ ____ _________ ________ __________ ________ ________ ___.
_______ ___ _______ _______ ___ _______.
_________ ______ ______ __________ _______.
________ _________ ____ _________ __________ ___ __________ _________ _______ ________ _____ ________.
__________ ________ ______ __________ _____ __________ ____ ___ ______ ________ _______ ______.
______ ________ ______ ____ ___.
______ ______ _______ ________ __________ ___ ____ __________ ______ _________ ________.
_________ __________ ___ _________ ______.
_____ ________ _______ ____ ____ _________ _____ ___ _______ ______ ___ __________.
__________ __________ _____ ___ _____ _________ ____ _____ ________.
_________ ___ __________ ________ _________ ________ _____ ___ ____ _________ ________.
______ _________ _____ _______ _______ _____ _____.
________ ________ __________ __________ ______.
____ ______ ____ _____ _______ _______ ____ _____ ___ ________.
__________ ___ ___ ____ ______ ___ _________ _________ _____ __________ _______ ____.
_____ __________ _______ ____ __________ _____ ___.
__________ ________ _________ ______ __________ _____ ___ _______ ____ _________ ____.
___ __________ ____ ____ _______ _____ ________.
________ ______ ____ _______ ______.
_________ _______ _______ __________ _________ _________ ____ ___ ____ ______.
_________ ___ _________ ______ ______ ____ _________.
____ ___ __________ ___ _____ _____ _____ _______ ________ ________ _____.
________ ________ __________ ______ _________ ____ __________ ___.
____ ______ __________ __________ ________ __________ ________ ________ _____ _______.
_____ ____ ________ ______ _________ __________ ____.
______ ____ _______ ______ ____.
__________ ________ ____ ________ ___ __________ __________.
_______ _______ _____ __________ _____ ________.
____ ____ _____ ____ _____ ________ ____ ____ _____ _______ __________ ___.
_____ _______ ________ ____ _________ ________ __________ _________ _____ ______.
______ ___ _____ __________ __________ _________ _______ ___.
____ _________ ________ _________ _____ _______ _________.
_____ ______ _____ ____ ________.
__________ ___ _______ _____ ___ ______ ____ ____ ___ __________ __________.
_______ ___ ______ _____ ______ ____ ________ _______.
__________ _______ ___ ________ ______ __________ __________ _____ ______ _________ __________.
___ __________ __________ ____ ________ _________ ______ ________ _________ ___ ________.
_______ ____ ______ _______ ___ _________ _________ _________ ___.
_______ ____ ____ _______ ________ ________ ____ ________ ____.
____ __________ _______ ____ ________ ________ ____.
__________ _______.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU MCS 23 2022 2023 - Consider a “Library Management System” which keeps the fol | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→