0% found this document useful (0 votes)
6 views8 pages

Experiment 10 Dbms

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views8 pages

Experiment 10 Dbms

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Experiment - 10

Objective: Design and implementation of Library Information System

Specification: To create a database with an interface for implementing Library Information


System for an educational organization.

a) Hardware & Software Design Requirements

S. No. Requirements Configuration


1 System 1
2 Operating System Windows 7 or higher / Linux
3 Front End C++/Java/Php etc.
4 Back End Oracle 11g/MySql
b) Steps for Achieving Objective

i. Create the database design with required tables (using SQL) as:

Book_Details(Account_No, author, title, publication, volume, edition, copies, price, status


etc. as required)

Student_Details(stu_name, Account_No, gender, course, enrollment_no, issue_date,


return_date)

Book_Issue(enrollment_no, issue_date, return_date, Account_No, stu_name, course, author,


volume, edition)

Book_Return(enrollment_no, Account_No, return_date, issue_date, fine_amount, stu_name,


course, author, volume, edition)

(Apart from these additional tables/fields can be added as required)


ii. Create the system design with features for student registration, Issuing Book, Returning
Book, Search/view book details, Add/update book details, fine payment as per the database
design created in step i.

iii. Value of fine for books returned late should be as per any chosen criteria.

iv. Basic project should contain required design forms with features to support step ii and iii
respectively.

Brief Description:

The document details "Experiment No: 9," involving the design and implementation of a
Library Information System. It outlines the objective, hardware and software requirements,
and steps for achieving the objective, relevant for database design and system implementation
projects in educational settings.

Implementation:-

Create db.php
<?php
$servername = "localhost"; // Your server name
$username = "root"; // Your database username
$password = "saptarshi@11"; // Your database password (leave empty if not set)
$dbname = "library"; // Your database name

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>

Create insert_student_details.php

<?php
include 'db.php'; // Include the database connection

// Insert sample data into Student_Details


$sql = "INSERT INTO Student_Details (stu_name, Account_No, gender, course,
enrollment_no) VALUES
('Alice Johnson', 'S001', 'Female', 'Computer Science', 'CS2023001'),
('Michael Smith', 'S002', 'Male', 'Mechanical Engineering', 'ME2023002'),
('Emily Davis', 'S003', 'Female', 'Biology', 'BIO2023003'),
('David Brown', 'S004', 'Male', 'Mathematics', 'MATH2023004'),
('Sophia Wilson', 'S005', 'Female', 'Literature', 'LIT2023005')";

if ($conn->query($sql) === TRUE) {


echo "Sample data inserted into Student_Details successfully!";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close(); // Close the connection


?>

Create insert_book_details.php

<?php
include 'db.php'; // Include the database connection
// Insert sample data into Book_Details
$sql = "INSERT INTO Book_Details (Account_No, author, title, publication, volume,
edition, copies, price, status) VALUES
('B001', 'J.K. Rowling', 'Harry Potter and the Chamber of Secrets', 'Scholastic', '1', '1st', 10,
19.99, 'Available'),
('B002', 'George Orwell', 'Animal Farm', 'Secker & Warburg', '1', '1st', 8, 14.99, 'Available'),
('B003', 'J.R.R. Tolkien', 'The Fellowship of the Ring', 'George Allen & Unwin', '1', '2nd', 5,
15.50, 'Available'),
('B004', 'F. Scott Fitzgerald', 'The Great Gatsby', 'Charles Scribner\'s Sons', '1', '1st', 7, 10.99,
'Available'),
('B005', 'Harper Lee', 'To Kill a Mockingbird', 'J.B. Lippincott & Co.', '1', '1st', 6, 12.99,
'Available')";

if ($conn->query($sql) === TRUE) {


echo "Sample data inserted into Book_Details successfully!";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close(); // Close the connection


?>

Create insert_book_issue.php

<?php
include 'db.php'; // Include the database connection

// Insert sample data into Book_Issue


$sql = "INSERT INTO Book_Issue (enrollment_no, issue_date, return_date, Account_No,
stu_name, course, author, volume, edition) VALUES
('CS2023001', '2024-01-10 10:00:00', NULL, 'B001', 'Alice Johnson', 'Computer Science',
'Harry Potter and the Chamber of Secrets', '1', '1st'),
('ME2023002', '2024-01-11 11:30:00', NULL, 'B002', 'Michael Smith', 'Mechanical
Engineering', 'Animal Farm', '1', '1st'),
('BIO2023003', '2024-01-12 09:15:00', NULL, 'B003', 'Emily Davis', 'Biology', 'The
Fellowship of the Ring', '1', '2nd'),
('MATH2023004', '2024-01-13 14:45:00', NULL, 'B004', 'David Brown', 'Mathematics', 'The
Great Gatsby', '1', '1st'),
('LIT2023005','2024-01-14 16:00:00' , NULL,'B005','Sophia Wilson','Literature','To Kill a
Mockingbird','1','1st')";

if ($conn->query($sql) === TRUE) {


echo "Sample data inserted into Book_Issue successfully!";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close(); // Close the connection


?>

Create insert_book_return.php

<?php
include 'db.php'; // Include the database connection

// Insert sample data into Book_Return


$sql = "INSERT INTO Book_Return (enrollment_no, Account_No, return_date, issue_date,
fine_amount, stu_name, course, author, volume, edition) VALUES
('CS2023001','B001','2024-01-20 10:00:00','2024-01-10 10:00:00' ,0.00,'Alice
Johnson','Computer Science','Harry Potter and the Chamber of Secrets','1','1st'),
('ME2023002','B002','2024-01-25 11:30:00','2024-01-11 11:30:00' ,5.00,'Michael
Smith','Mechanical Engineering','Animal Farm','1','1st'),
('BIO2023003','B003','2024-01-22 09:15:00','2024-01-12 09:15:00' ,2.50,'Emily
Davis','Biology','The Fellowship of the Ring','1','2nd'),
('MATH2023004','B004','2024-01-30 14:45:00','2024-01-13 14:45:00' ,0.00,'David
Brown','Mathematics','The Great Gatsby','1','1st'),
('LIT2023005','B005','2024-02-05 16:00:00','2024-01-14 16:00:00' ,10.00,'Sophia
Wilson','Literature','To Kill a Mockingbird' ,'1' ,'1st')";

if ($conn->query($sql) === TRUE) {


echo "Sample data inserted into Book_Return successfully!";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close(); // Close the connection


?>

Create fine-calc.php

<?php
include 'db.php'; // Include the database connection

// Query to calculate fines for overdue books


$sql = "SELECT
enrollment_no,
DATEDIFF(NOW(), return_date) AS overdue_days,
fine_amount + (DATEDIFF(NOW(), return_date) * 1.00) AS total_fine
FROM
Book_Return
WHERE
return_date < NOW() AND payment_status = 'Unpaid'";

$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<h2>Overdue Books and Fines</h2>";
echo "<table border='1'>
<tr>
<th>Enrollment No</th>
<th>Overdue Days</th>
<th>Total Fine</th>
</tr>";
while ($row = $result->fetch_assoc()) {
echo "<tr>
<td>" . htmlspecialchars($row["enrollment_no"]) . "</td>
<td>" . htmlspecialchars($row["overdue_days"]) . "</td>
<td>" . htmlspecialchars($row["total_fine"]) . "</td>
</tr>";
}
echo "</table>";
} else {
echo "No overdue books found.";
}

$conn->close(); // Close the connection


?>
Running the Project
1. Set up your MySQL database with the appropriate tables
(Employee_Details and Salary).
2. Place all PHP files in your web server's root directory (e.g., htdocs for XAMPP).
3. Access the forms through your web browser
(e.g., http://localhost/employee_form.php).
4. Fill out the forms to add employees and their salary details.
Output :-

You might also like