0% found this document useful (0 votes)
7 views3 pages

A* Search Algorithm and SQL Procedures

The document outlines the implementation of basic search strategies, specifically the A* search algorithm, along with SQL commands for managing a LibraryDB database. It details procedures for inserting data into Books, Members, and Loans tables, querying data, joining tables for detailed information, finding overdue loans, counting books by authors, updating member information, and deleting loan records. The program was successfully executed, demonstrating effective database manipulation and querying techniques.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

A* Search Algorithm and SQL Procedures

The document outlines the implementation of basic search strategies, specifically the A* search algorithm, along with SQL commands for managing a LibraryDB database. It details procedures for inserting data into Books, Members, and Loans tables, querying data, joining tables for detailed information, finding overdue loans, counting books by authors, updating member information, and deleting loan records. The program was successfully executed, demonstrating effective database manipulation and querying techniques.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Aim:

To implement an basic search starategies like Implement A* search algorithm.

Procedure:

To manipulate and query the database created in the previous steps, follow these
procedures and SQL commands:

Step 1: Inserting Data

Procedure

Open pgAdmin and connect to your LibraryDB database.

Open Query Tool to execute SQL commands.

SQL Query:

-- Insert data into Books table

INSERT INTO Books (Title, Author, ISBN, PublicationYear) VALUES

('The Great Gatsby', 'F. Scott Fitzgerald', '9780743273565', 1925),

('To Kill a Mockingbird', 'Harper Lee', '9780061120084', 1960),

('1984', 'George Orwell', '9780451524935', 1949);

-- Insert data into Members table

INSERT INTO Members (Name, Email, MembershipDate) VALUES

('John Doe', '[Link]@[Link]', '2023-01-15'),

('Jane Smith', '[Link]@[Link]', '2023-03-22'),

('Alice Johnson', '[Link]@[Link]', '2023-02-10');

-- Insert data into Loans table

INSERT INTO Loans (BookID, MemberID, LoanDate, ReturnDate) VALUES

(1, 1, '2023-06-01', '2023-06-15'),

(2, 2, '2023-06-05', '2023-06-20'),

(3, 3, '2023-06-10', '2023-06-25');

Step 2: Querying Data

Procedure
Open Query Tool in pgAdmin.

Execute SQL Commands to retrieve and manipulate data.

Select All Books,Members,Loans

SQL Code Examples

SELECT * FROM Books;

SELECT * FROM Members;

SELECT * FROM Loans;

[Link] Tables to Get Detailed Loan Information

SELECT

[Link],

[Link] AS BookTitle,

[Link] AS MemberName,

[Link],

[Link]

FROM Loans

JOIN Books ON [Link] = [Link]

JOIN Members ON [Link] = [Link];

[Link] Overdue Loans (Assuming Current Date is '2023-06-30')

SELECT

[Link],

[Link] AS BookTitle,

[Link] AS MemberName,

[Link],

[Link]

FROM Loans

JOIN Books ON [Link] = [Link]


JOIN Members ON [Link] = [Link]

WHERE [Link] < '2023-06-30';

6. Count Number of Books by Each Authour

SELECT

Author,

COUNT(*) AS NumberOfBooks

FROM Books

GROUP BY Author;

7. Update a Member's Email

UPDATE Members

SET Email = '[Link]@[Link]'

WHERE MemberID = 1;

8. Delete a Loan Record

DELETE FROM Loans

WHERE LoanID = 3;

RESULT:

Thus the above program was implemented and executed successfully.

You might also like