Sri Aurobindo Institute of Technology: RDBMS LAB (ME-606)
Sri Aurobindo Institute of Technology: RDBMS LAB (ME-606)
TECHNOLOGY
Submitted to : Submitted by
Mr. Mahesh Arse Rajat Malviya
0873ME203D16
Session-2021-22
RDBMS lab [ME606]
Session-2021-22
INDEX
S.NO. List of Experiments Date of Date of Page Sign
Experiment Submission No.
1. Introduction : Relational Database Management System 15/03/2022 4-5
(RDBMS)
2. XAMPP 22/03/2022 6
3. php 28/03/2022 7
Structured Query Language (SQL): The primary interface used to communicate with a relational
database. It’s the standardized query language for requesting information from a database.
SQL
SQL stands for Structured Query language
SQL is the standard language for dealing with Relational Databases. SQL can be used to insert,
search, update, and delete database records. SQL can do lots of other operations, including
optimizing and maintenance of databases.
1970 – Dr. Edgar F. “Ted” Codd described a relational model for databases.
1974 – Structured Query Language appeared.
1978 – IBM released a product called System/R.
1986 – IBM developed the prototype of a relational database, which is standardized by
ANSI.
1989 – First ever version launched of SQL
1999 – SQL 3 launched with features like triggers, object-orientation, etc.
SQL 2003 – window functions, XML-related features, etc.
SQL 2006 – Support for XML Query Language
SQL 2011 -improved support for temporal databases
Page 3
Here are five types of widely used SQL queries.
DDL or Data Definition Language actually consists of the SQL commands that can be used to define
the database schema. It simply deals with descriptions of the database schema and is used to create
and modify the structure of database objects in the database.DDL is a set of SQL commands used to
create, modify, and delete database structures but not data. These commands are normally not used
by a general user, who should be accessing the database via an application.
1. CREATE: This command is used to create the database or its objects (like table, index,
function, views, store procedure, and triggers).
2. DROP: This command is used to delete objects from the database.
3. ALTER: This is used to alter the structure of the database.
4. TRUNCATE: This is used to remove all records from a table, including all spaces allocated
for the records are removed.
5. COMMENT: This is used to add comments to the data dictionary.
6. RENAME: This is used to rename an object existing in the database.
The SQL commands that deals with the manipulation of data present in the database belong to DML
or Data Manipulation Language and this includes most of the SQL statements. It is the component of
the SQL statement that controls access to data and to the database. Basically, DCL statements are
grouped with DML statements.
Page 4
Data Control Language (DCL)
DCL includes commands such as GRANT and REVOKE which mainly deal with the rights,
permissions, and other controls of the database system.
Though many resources claim there to be another category of SQL clauses TCL – Transaction
Control Language. So we will see in detail about TCL as well. TCL commands deal with the
transaction within the database.
Page 5
XAMPP
XAMPP is a cross-platform web server that is free and open-source. XAMPP is a short form for
Cross-Platform, Apache, MySQL, PHP, and Perl. XAMPP is a popular cross-platform web server that
allows programmers to write and test their code on a local webserver. It was created by Apache
Friends, and the public can revise or modify its native source code. It includes MariaDB, Apache
HTTP Server, and interpreters for PHP and Perl, among other computer languages. Because of
XAMPP’s simplicity of deployment, a developer can quickly and easily install a WAMP or LAMP
stack on an operating system, with the added benefit that common add-in apps like WordPress and
Joomla can also be loaded.
Page 6
PHP
PHP is a script on the server-side used for the creation of Static or Dynamic Web sites or Web
applications. PHP is a pre-processor for hypertext, which used to stand for home pages. The
software used to build web applications is an open-source, server-side scripting language. We say a
program designed for automated work by writing a script-based language (code lines). It is suitable
for the output and construction of dynamic web pages for web applications, e-commerce
applications, and database applications. PHP can be inserted into HTML.
mysql queries
Table Name = st_data
Output :
Page 7
2.INSERT INTO `data`(`ID`, `fname`, `mname`, `lname`, `age`, `profassion`,
`email`, `phone`, `addr`, `pass`, `cpass`) VALUES ('[value-1]','[value-
2]','[value-3]','[value-4]','[value-5]','[value-6]','[value-7]','[value-
8]','[value-9]','[value-10]','[value-11]')
INSERT INTO st_data(id , name, age, addr) VALUES (01, "Ravi Dhakad", 19,
"Ujjain")
Output :
Output :
Page 8
4. SELECT * FROM st_data WHERE ID=5;
Output :
Output :
Page 9
6. DELETE FROM `data` WHERE ID=8
Output :
Page 10
Project : Registration data management system
connect.php
<?php
$localhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "registration_data";
$conn = new mysqli($localhost, $dbuser, $dbpass, $dbname);
if($conn){
}else{
echo "Connection failed";
}?>
registrationform.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Registration Form</title>
<center>
<h2>Registration Form</h2>
</head>
<body>
<form action="registrationcheck.php" method="post">
<table>
<tr>
<td>First Name:</td>
<td><input type="text" name="fname" required></td>
</tr>
<tr>
<td>Middle Name:</td>
<td><input type="text" name="mname" required></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type="text" name="lname" required></td>
</tr>
<tr>
<td>Age:</td>
<td><input type="text" name="age" required></td>
Page 11
</tr>
<tr>
<td>Profassion:</td>
<td><input type="text" name="profassion" required></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="email" required></td>
</tr>
<tr>
<td>Phone Number:</td>
<td><input type="text" name="phone" required></td>
</tr>
<tr>
<td>Address:</td>
<td><input type="text" name="addr" required></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="pass" required></td>
</tr>
<tr>
<td>Confirm Password:</td>
<td><input type="password" name="cpass" required></td>
</tr>
</table>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</center>
</html>
registrationcheck.php
<?php
include "connect.php";//require, require_once
$fname= $mname= $lname= $age= $profassion= $email= $phone= $addr= $pass= $cpass=
"";
Page 12
$lname = $_POST['lname'];
$age = $_POST['age'];
$profassion = $_POST['profassion'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$addr = $_POST['addr'];
$pass = $_POST['pass'];
$cpass = $_POST['cpass'];
display.php
<?php
include "connect.php";
$q = "SELECT * FROM data";
$result = mysqli_query($conn, $q);
if(mysqli_num_rows($result)>0){
$html = '<table border="1" cellspacing="0" cellpadding="2">
<thead>
<tr>
<td>ID</td>
<td>First Name</td>
<td>Middle Name</td>
<td>Last Name </td>
<td>Age</td>
<td>Email ID</td>
<td>Mobile No.</td>
<td>Profession</td>
Page 13
<td>Address</td>
<td>Operations</td>
</tr>
</thead>';
while($row = mysqli_fetch_assoc($result)){
$id = $row['ID'];
$fname = $row['fname'];
$mname = $row['mname'];
$lname = $row['lname'];
$age = $row['age'];
$email = $row['email'];
$profassion = $row['profassion'];
$phone = $row['phone'];
$addr = $row['addr'];
$html .= '<tbody>
<tr>
<td>'.$id.'</td><td>'.$fname.'</td>
<td>'.$mname.'</td><td>'.$lname.'</td>
<td>'.$age.'</td><td>'.$email.'</td>
<td>'.$phone.'</td><td>'.$profassion.'</td>
<td>'.$addr.'</td>
<td><a href = "delete.php?ID='.$id.'"<button type="submit"
name="submit" value="submit">Delete</button></a>
<a href = "edit.php?ID='.$id.'"<button type="submit" name="submit"
value="submit">Edit</button></a>
<a href = "print.php?ID='.$id.'"<button type="submit" name="submit"
value="submit">Print</button></a></td>
</tr></tbody>';
}
$html .='</table>';
}
echo $html;
?>
delete.php
<?php
include "connect.php";
$id = $_GET['ID'];
$sql = "DELETE FROM data WHERE ID=".$id;
$result = mysqli_query($conn, $sql);
if($result){
echo "Data deleted successfully";
}else{
echo "Data not found";
Page 14
}?>
edit.php
<?php
include "connect.php";
$id = $_GET['ID'];
$sql = "SELECT * FROM data WHERE ID='$id'";
$result = mysqli_query($conn, $sql);
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)){
$fname = $row['fname'];
$mname = $row['mname'];
$lname = $row['lname'];
$age = $row['age'];
$prof = $row['profassion'];
$email = $row['email'];
$phone = $row['phone'];
$addr = $row['addr'];
}
}?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Registration Updation Form</title>
<center>
<h2>Registration Updation Form</h2>
</head>
<body>
<form action="update.php" method="post">
<table>
<tr>
<td>ID:</td>
<td><input type="text" name="ID" disabled value=<?php echo
$id;?>></td>
</tr>
<tr>
<td>First Name:</td>
<td><input type="text" name="fname" value=<?php echo $fname;?>
required></td>
</tr>
<tr>
Page 15
<td>Middle Name:</td>
<td><input type="text" name="mname" required value=<?php echo
$mname;?> ></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type="text" name="lname" value=<?php echo $lname;?>
></td>
</tr>
<tr>
<td>Age:</td>
<td><input type="text" name="age" value=<?php echo $age;?> ></td>
</tr>
<tr>
<td>Profassion:</td>
<td><input type="text" name="profassion" value=<?php echo
$prof;?> ></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="email" value=<?php echo $email;?>
></td>
</tr>
<tr>
<td>Phone Number:</td>
<td><input type="text" name="phone" value=<?php echo $phone;?>
></td>
</tr>
<tr>
<td>Address:</td>
<td><input type="text" name="addr" value=<?php echo $addr;?>
></td>
</tr>
</table>
<button type="submit" name="submit" >Update</button>
</form>
</body>
</center>
</html>
update.php
<?php
include "connect.php";
$id = $_POST['ID'];
Page 16
$fname = $_POST['fname'];
$mname = $_POST['mname'];
$lname = $_POST['lname'];
$age = $_POST['age'];
$prof = $_POST['profassion'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$addr = $_POST['addr'];
$sql = "UPDATE data SET
fname='$fname',mname='$mname',lname='$lname',age=$age,profassion='$prof',email='$
email',phone='$phone',addr='$addr' WHERE ID=".$id;
$result = mysqli_query($conn, $sql);
if($result){
echo "Data updated successfully";
}else{
echo "Data not updated";
}?>
search_2.php
<?php
Page 17
include "connect.php";
$fname = $_GET['fname'];
$q = "SELECT * FROM data WHERE fname='$fname'";
$result = mysqli_query($conn, $q);
if(mysqli_num_rows($result)>0){
$html = '<table border="1" cellspacing="0" cellpadding="2">
<thead><tr>
<td>ID</td>
<td>First Name</td>
<td>Middle Name</td>
<td>Last Name </td>
<td>Age</td>
<td>Email ID</td>
<td>Mobile No.</td>
<td>Profession</td>
<td>Address</td>
<td>Operations</td>
</tr></thead>';
while($row = mysqli_fetch_assoc($result)){
$id = $row['ID'];
$fname = $row['fname'];
$mname = $row['mname'];
$lname = $row['lname'];
$age = $row['age'];
$email = $row['email'];
$profassion = $row['profassion'];
$phone = $row['phone'];
$addr = $row['addr'];
$html .= '<tbody>
<tr><td>'.$id.'</td>
<td>'.$fname.'</td>
<td>'.$mname.'</td>
<td>'.$lname.'</td>
<td>'.$age.'</td>
<td>'.$email.'</td>
<td>'.$phone.'</td>
<td>'.$profassion.'</td>
<td>'.$addr.'</td></tr>
</tbody>';
}
$html .='</table>';
}
echo $html;?>
Page 18
To print or convert any data in PDF of webpage
print.php
<?php
include "connect.php";
include "vendor\autoload.php";
$id = $_GET['ID'];
//composer require dompdf/dompdf
use Dompdf\Dompdf;
$q = "SELECT * FROM data WHERE ID='$id'";
$result = mysqli_query($conn, $q);
if(mysqli_num_rows($result)>0){
$html = '<table border="1" cellspacing="0" cellpadding="2">
<thead>
<tr>
<td>ID</td>
<td>First Name</td>
<td>Middle Name</td>
<td>Last Name </td>
<td>Age</td>
<td>Email ID</td>
<td>Mobile No.</td>
<td>Profession</td>
<td>Address</td>
<td>Operations</td>
</tr>
</thead>';
while($row = mysqli_fetch_assoc($result)){
$id = $row['ID'];
$fname = $row['fname'];
$mname = $row['mname'];
$lname = $row['lname'];
$age = $row['age'];
$email = $row['email'];
$profassion = $row['profassion'];
$phone = $row['phone'];
$addr = $row['addr'];
$html .= '<tbody>
<tr>
<td>'.$id.'</td>
<td>'.$fname.'</td>
<td>'.$mname.'</td>
<td>'.$lname.'</td>
<td>'.$age.'</td>
Page 19
<td>'.$email.'</td>
<td>'.$phone.'</td>
<td>'.$profassion.'</td>
<td>'.$addr.'</td>
</tr></tbody>';
}
}
$html .='</table>';
$dompdf = new Dompdf();
$dompdf->loadHtml($html);//load html
$dompdf->setPaper('A4','landscape');
$dompdf->render(); //generate pdf
ob_end_clean(); //clean object
$dompdf->stream("sait",array('Attachment'=>0)); //generate output pdf
?>
login.php
logout.php
home.php
Page 20