Consider the following schema for institute library: Student (Roll No, Name, Father_ Name, Branch) Book (ISBN, Title, Author, Publisher) Issue (Roll No, ISBN, Date-of –Issue) Write the following queries in SQL and relational algebra: List roll number and name of all students of the branch ‘CSE’. Find the name of student who has issued a book published by ‘ABC’ publisher. List title of all books and their authors issued to a student ‘RAM’. List title of all books issued on or before December 1, 2020.List all books published by publisher ‘ABC’.
Question
Consider the following schema for institute library: Student (Roll No, Name, Father_ Name, Branch) Book (ISBN, Title, Author, Publisher) Issue (Roll No, ISBN, Date-of –Issue) Write the following queries in SQL and relational algebra: List roll number and name of all students of the branch ‘CSE’. Find the name of student who has issued a book published by ‘ABC’ publisher. List title of all books and their authors issued to a student ‘RAM’. List title of all books issued on or before December 1, 2020.List all books published by publisher ‘ABC’.
Solution
Sure, here are the SQL queries for your questions:
- List roll number and name of all students of the branch ‘CSE’.
SELECT Roll_No, Name
FROM Student
WHERE Branch = 'CSE';
- Find the name of student who has issued a book published by ‘ABC’ publisher.
SELECT s.Name
FROM Student s
JOIN Issue i ON s.Roll_No = i.Roll_No
JOIN Book b ON i.ISBN = b.ISBN
WHERE b.Publisher = 'ABC';
- List title of all books and their authors issued to a student ‘RAM’.
SELECT b.Title, b.Author
FROM Book b
JOIN Issue i ON b.ISBN = i.ISBN
JOIN Student s ON i.Roll_No = s.Roll_No
WHERE s.Name = 'RAM';
- List title of all books issued on or before December 1, 2020.
SELECT b.Title
FROM Book b
JOIN Issue i ON b.ISBN = i.ISBN
WHERE i.Date-of-Issue <= '2020-12-01';
- List all books published by publisher ‘ABC’.
SELECT *
FROM Book
WHERE Publisher = 'ABC';
Please note that the date format in the fourth query might need to be adjusted depending on the SQL dialect and the format of the Date-of-Issue column in your database.
Similar Questions
Problem StatementGiven a library management system with tables for publishers, library branches, books, book authors, book copies, and book lending. Write a query to retrieve details about books, including the book ID, title, publisher name, publication year, author name, number of copies, branch name, and branch address.The following table is already created, and the records are inserted into the table.Table Details:The sample records are given below. Input format :The input records are already prepopulated, as given in the problem statement.Output format :The output is a detailed dataset that includes the following information for each book as shown below:Book_id Title Publisher_Name Pub_Year Author_Name No_of_Copies Branch_Name Branch_Address1 Introduction to SQL Tech Publications 2020 John Smith 10 Main Library 123 Library St2 Python Programming Code Books 2019 David Miller 15 Downtown Branch 456 Downtown St3 Data Science Handbook Data Insights 2021 Anna White 20 Suburb Branch 789 Suburb St4 Algorithms Unlocked Algorithm House 2018 Chris Brown 8 Main Library 123 Library St5 Database Management Systems Tech Publications 2017 Emma Wilson 12 Downtown Branch 456 Downtown StRefer to the sample output for the column headers.Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.
Create the database with a name ‘LIBRARY’. (05 Marks) ii. Write the SQL statements required to create the above tables in the ‘LIBRARY’ database using mysql including appropriate data types as given below. Books BookId VARCHAR(10) NOT NULL ISBN INTEGER(30 BookAuthor VARCHAR(50 BookName VARCHAR(50) BookEdition VARCHAR(10) Branch BranchId VARCHAR(10) NOT NULL, BranchName VARCHAR(50) BranchLocation VARCHAR(30)
Consider these following tables and only solve the query. Tables: 1) student: s_no (primary key), student_name, course_no (foreign key), age 2) courser-course-no (primary key), course-name. Query: Display all the student name, course name and also age of the students, whose age is between 23 to 27 and course having 'BCA'. Find out the students whose age is maximum.
Read the passage and answer the following questions:A School in Delhi uses database management system to store student details. The school maintains a database ‘school_record’ under which there are two tables.Student Table : Maintains general details about every student enrolled in school.StuLibrary Table : To store details of issued books. BookID is the unique identification number issued to each book. Minimum issue duration of a book is one Day.Identify the SQL Query which displays the data of StuLibrary table in ascending order of StudentID*1 pointSelect * from StuLibrary Order By BookID;Select * from StuLibrary Group By StuID;Select * from StuLibrary Order By StuID ASC;Select * from StuLibrary Order By StuID DESC;The Primary Key for StuLibrary Table is/are*1 pointBookIDBookID, StuIDBookID, Issued_dateIssued_dateWhich of the following SQL Query will fetch ID of those issued books which have not been returned?*1 pointSELECT BookID from StuLibrary where BookID is NULL;SELECT BookID from StuLibrary where StuID is NULL;SELECT BookID from StuLibrary where Issued_date is NULL;SELECT BookID from StuLibrary where Return_date is NULL;The Alternate Key for Student Table will be*1 pointStuNameStuContactStuAadharStuClassBackSubmitClear form
Consider following schema and write SQL for given statements.Student (RollNo, Name, DeptCode, City)Department (DeptCode, DeptName)Result (RollNo, Semester, SPI)1. List out the RollNo, Name along with SPI of Student.2. Display student name who got highest SPI in semester 1.3. Display the list of students whose DeptCode is 5, 6,7,10
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.