0% found this document useful (0 votes)
346 views20 pages

Sri Aurobindo Institute of Technology: RDBMS LAB (ME-606)

This document provides details about experiments conducted for the RDBMS lab at Sri Aurobindo Institute of Technology. It includes an index listing 8 experiments conducted between March and April 2022 on topics like introduction to RDBMS, XAMPP, PHP, MySQL queries, building a registration data management system, searching and exporting data to PDF. The document provides information on Structured Query Language, its history and types of SQL statements including DDL, DML, DCL and TCL. It also includes details on XAMPP and PHP.

Uploaded by

Rajat Malviya
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)
346 views20 pages

Sri Aurobindo Institute of Technology: RDBMS LAB (ME-606)

This document provides details about experiments conducted for the RDBMS lab at Sri Aurobindo Institute of Technology. It includes an index listing 8 experiments conducted between March and April 2022 on topics like introduction to RDBMS, XAMPP, PHP, MySQL queries, building a registration data management system, searching and exporting data to PDF. The document provides information on Structured Query Language, its history and types of SQL statements including DDL, DML, DCL and TCL. It also includes details on XAMPP and PHP.

Uploaded by

Rajat Malviya
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/ 20

SRI AUROBINDO INSTITUTE OF

TECHNOLOGY

RDBMS LAB [ME-606]

Submitted to : Submitted by
Mr. Mahesh Arse Rajat Malviya
0873ME203D16

DEPARTMENT OF MECHANICAL ENGINEERING

Session-2021-22
RDBMS lab [ME606]

SRI AUROBINDO INSTITUTE OF TECHNOLOGY


DEPARTMENT OF MECHANICAL ENGINEERING

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

4. mysql queries 04/04/2022 7-10

5. Project : Registration data management system 06/04/2022 11-17

6. To search any data from database 12/04/2022 17-18

7. To print or convert any data in PDF of webpage 18/04/2022 19-20

8. Login – Logout System 19/04/2022 20


Intoduction

Relational Database Management System (RDBMS)


A relational database management system is organized into tables that are used to hold information
about the objects to be represented in the database. Each column in a table holds a certain kind of
data, and a field stores the actual value or attribute. The rows represent a collection of related
values of one object. Each row in a table can be marked with a unique identifier, and rows within
multiple tables can be made related using foreign keys. The data of a relational database can be
accessed in many ways without reorganizing the tables themselves.

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.

Here are important reasons for using SQL

1. It helps users to access data in the RDBMS system.


2. It helps you to describe the data.
3. It allows you to define the data in a database and manipulate that specific data.
4. With the help of SQL, you can create and drop databases and tables.
5. SQL offers you to use the function in a database, create a view, and stored procedure.
6. You can set permissions on tables, procedures, and views.

A Brief History of SQL

 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

Types of SQL Statements

Page 3
Here are five types of widely used SQL queries.

1. Data Definition Language (DDL)


2. Data Manipulation Language (DML)
3. Data Control Language (DCL)
4. Transaction Control Language (TCL)
5. Data Query Language (DQL)

Data Definition Language (DDL)

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.

List of DDL commands:

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.

Data Manipulation Language (DML)

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.

List of DML commands:

1. INSERT : It is used to insert data into a table.


2. UPDATE: It is used to update existing data within a table.
3. DELETE : It is used to delete records from a database table.
4. LOCK: Table control concurrency.
5. CALL: Call a PL/SQL or JAVA subprogram.
6. EXPLAIN PLAN: It describes the access path to data.

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.

List of DCL commands:

1. GRANT: This command gives users access privileges to the database.


2. REVOKE: This command withdraws the user’s access privileges given by using the GRANT
command.

Transaction Control Language (TCL)

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.

List of TCL commands:

1. COMMIT: Commits a Transaction.


2. ROLLBACK: Rollbacks a transaction in case of any error occurs.
3. SAVEPOINT:Sets a savepoint within a transaction.
4. SET TRANSACTION: Specify characteristics for the transaction.

Page 5
XAMPP

XAMPP = Cross – Apache-MySql – php & purl

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

1. CREAT TABLE 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 :

3. SELECT * FROM st_data

Output :

Page 8
4. SELECT * FROM st_data WHERE ID=5;

Output :

5. UPDATE `data` SET `ID`='[value-1]',`fname`='[value-2]',`mname`='[value-


3]',`lname`='[value-4]',`age`='[value-5]',`profassion`='[value-
6]',`email`='[value-7]',`phone`='[value-8]',`addr`='[value-9]',`pass`='[value-
10]',`cpass`='[value-11]' WHERE 1

UPDATE `data` SET


`age`=21,`email`='[email protected]',`phone`='1234567890',`addr`='Indore' WHERE
ID=7

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=
"";

if(!empty($_POST['fname']) && !empty($_POST['mname']) && !empty($_POST['lname'])


&& !empty($_POST['age']) && !empty($_POST['profassion']) &&
!empty($_POST['email']) && !empty($_POST['phone']) && !empty($_POST['addr']) &&
!empty($_POST['pass']) && !empty($_POST['cpass'])){
$fname = $_POST['fname'];//$_GET
$mname = $_POST['mname'];

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'];

$sql = "INSERT INTO


data(fname,mname,lname,age,profassion,email,phone,addr,pass,cpass)
VALUES('$fname','$mname','$lname',$age,'$profassion','$email',$phone,'$addr','$pa
ss','$cpass')";
$result = mysqli_query($conn, $sql);
if($result){
echo "Data inserted successfully";
// echo '<br><br><button><a href="display.php">All
Data</a></button>';
}else{
echo "Data not submitted";
}
}else{
echo "All fields are required..!";
}?>

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";
}?>

To search any data from database


search.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>Search</title>
</head>
<body>
<Center>
<h1>Search</h1>
<form action="search_2.php" method="get">
<input type="text" name="fname">
<input type="submit" value="Submit">
</form>
</Center>
</body>
</html>

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 – Logout System

login.php

logout.php

home.php

Page 20

You might also like