0% found this document useful (0 votes)
2 views

Lab2

This document outlines a lab worksheet for database systems, detailing steps for setting up a database schema, inserting records for authors, categories, books, members, and borrower information. It includes SQL queries to calculate the number of authors, average books available, minimum publication year, and to retrieve lists of books with authors and members. The document is structured to guide students through practical database operations.

Uploaded by

solutionsw36
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lab2

This document outlines a lab worksheet for database systems, detailing steps for setting up a database schema, inserting records for authors, categories, books, members, and borrower information. It includes SQL queries to calculate the number of authors, average books available, minimum publication year, and to retrieve lists of books with authors and members. The document is structured to guide students through practical database operations.

Uploaded by

solutionsw36
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Database Systems and Applications

Lab Work Sheet-2


Student Name: Muskan

Bits id: - 2023wd15015

Step 1: Database Schema Setup

Public
Step 2: Insert Records

Insert Authors (Including Student's Name and BITS ID in Biography)

Insert Sample Data for Other Tables

Query’s:-
INSERT INTO Authors (FirstName, LastName, Biography)

VALUES

('John', 'Smith', 'Author ID: 101'),

('Jane', 'Doe', 'Author ID: 102'),

('Emily', 'Johnson', 'Author ID: 103');

INSERT INTO Categories (CategoryName)

VALUES

('Fiction'),

('Science'),

('Technology'),

('Philosophy');

INSERT INTO Books (Title, AuthorID, CategoryID, PublicationYear, ISBN, CopiesAvailable)

Public
VALUES

('The Great Adventure', 1, 1, 2020, '978-1-23456-7890', 5),

('The Science of Tomorrow', 2, 2, 2018, '978-0-98765-4321', 3),

('Tech Innovators', 3, 3, 2022, '978-1-23456-7891', 8),

('Philosophy of Mind', 2, 4, 2021, '978-0-98765-4322', 2);

INSERT INTO Members (FirstName, LastName, Email, PhoneNumber, MembershipDate)

VALUES

('Alice', 'Walker', '[email protected]', '1234567890', '2023-01-01'),

('Bob', 'Brown', '[email protected]', '2345678901', '2022-11-15'),

('Charlie', 'Davis', '[email protected]', '3456789012', '2024-04-10');

INSERT INTO Borrower (BookID, MemberID, LoanDate, ReturnDate, DueDate)

VALUES

(1, 1, '2023-02-01', '2023-02-10', '2023-02-08'),

(2, 2, '2023-05-15', '2023-05-22', '2023-05-20'),

(3, 3, '2024-01-05', '2024-01-12', '2024-01-10');

Public
Step 3: Queries
1. Write a query to calculate number of authors present in the Authors table?

2. Write a query to get average number of books available in the Books table?

Public
3. Write a query to calculate minimum publication year of books in the Books table?

4. Retrieve a list of all books along with their authors' names.

5. Write a query to get a list of all members and the books they have borrowed. Include
members who have not borrowed any books.

Public
6. Retrieve a list of all authors and the total number of books they have written

7. List all books along with their author’s full name and publication year.

Public
Public

You might also like