1.1 Introduction To SQL: 1.DDL: Data Definition Language
1.1 Introduction To SQL: 1.DDL: Data Definition Language
CHAPTER 1
INTRODUCTION
1.1 INTRODUCTION TO SQL
Structure Query Language (SQL) is a programming language used for storing and
managing data in Relational Database Management System (RDBMS). SQL was the first
commercial language introduced for E.F Codd's Relational model. Today almost all RDBMS
(MySQL, Oracle, Infomix, Sybase, MS Access) uses SQL as the standard database language.
SQL is used to perform all type of data operations in RDBMS. Most of the actions you need
to perform on a database are done with SQL statements. SQL defines following data
languages to manipulate data of RDBMS:
1.DDL: Data Definition Language
All DDL commands are auto-committed. That means it saves all the changes permanently in
the database.
Eg: create - To create new table or database, alter - For alteration, truncate - Delete data from
table, drop - To drop a table
2.DML: Data Manipulation Language
DML commands are not auto-committed. It means changes are not permanent to database,
they can be rolled back.
Eg: insert - To insert a new row, update - To update existing row, delete - To delete a row,
merge - merging two rows or two tables
3.TCL: Transaction Control Language
These commands are to keep a check on other commands and their affect on the database.
These commands can annul changes made by other commands by rolling back to original
state. It can also make changes permanent.
Eg: commit - to permanently save, rollback - to undo change, save point - to save temporarily
4.DCL: Data Control Language
Data control language provides command to grant and take back authority.
Eg: grant - grant permission of right, revoke - take back permission
5.DQL: Data Query Language
DQL is used to operate on queries.
Eg: Select - retrieve records from one or more table
The front end software used is PHP. PHP is an acronym for "PHP: Hypertext
Preprocessor”. PHP is a server scripting language, and a powerful tool for making dynamic
and interactive Web pages. It is a widely used, open source scripting language. It is free to
download and use.PHP files can contain text, HTML, CSS, JavaScript, and PHP code. PHP
code are executed on the server, and the result is returned to the browser as plain HTML.PHP
files have extension ".php".
PHP code may be embedded into HTML or HTML5 makeup, or it can be used in
combination with various web template systems, web content management systems and web
frameworks. PHP code is usually processed by a PHP interpreter implemented as a module in
the web server or as a Common Gateway Interface (CGI) executable. The web server
software combines the results of the interpreted and executed PHP code, which may be any
type of data, including images, with the generated web page. PHP code may also be executed
with a command-line interface (CLI) and can be used to implement standalone graphical
applications.
CHAPTER 1: INTRODUCTION
The brief introduction about the backend software SQL, front end software HTML and the
project report outline details are specified
CHAPTER 4: IMPLEMENTATION
The implementation parts for developing the project are explained step wise briefly.
CHAPTER 6: TESTING
The testing process, objectives and the test cases are tested and the expected results with the
observed results are written with the remarks.
CHAPTER 7: RESULT
The results with the snapshots for the various operations are displayed with the snapshots.
CHAPTER 2
REQUIREMENT SPECIFICATION
Database : MYSQL
RAM : 4.00 GB
Hard Disk : 1 TB
CHAPTER 3
OBJECTIVE OF THE PROJECT
The objectives of the project is to provide web based interface to a petshop owner to
manages his petshop activities.
To provide an option for storing and managing the basic information about pets and pet
products in the shop.
To provide an option for storing and managing the sales details of the shop.
To provide an option for storing and managing the basic information about the customer
CHAPTER 4
IMPLEMENTATION
4.1 ER DIAGRAM
An entity-relationship model (ER model) describes inter-related things of
Interest in a specific domain of knowledge. An ER model is composed of entity types
(which classify the things of interest) and specifies relationships that can exist
between instances of those entity types.
ER model is commonly formed to represent things that a business needs to
remember in order to perform business processes. Consequently, the ER model
becomes an abstract data model that defines a data or information structure that can
be implemented in a database, typically a relational database.
The main components of ER model are: entity set and relationship set.
Here are the geometric shapes and their meaning in an ER Diagram
Rectangle : Represents Entity sets.
Ellipses : Attributes.
Diamonds: Relationship set.
Lines : They link attributes to Entity Sets and this to Relationship Set.
Fig no: 4.1 is the ER diagram of “Petshop Management System” with entities pets, animals,
birds, pet products, sales details, customer, sold pets
4.1 ER DIAGRAM
1 1 1 1
N
1
1
N
M
For each regular (Strong) entity type E in the ER schema. Create a relation R that include all
simple attributes of E.
Regular entities of this database are pets,pet_products,customer,sales_details.
pets
pet_products
customer
sales_details
sold_pets
sd_id pet_id
animals
birds
animals
birds
pet_id type noise
sold_pets
pet_id
sales_details
sold_pets
sd_id pet_id
customer
cs_id cs_fname cs-minit cs_lname cs-address
sales_details
pet_products
pp_id
pp_name pp_type cost belongs_to
sales_details
sold_products
An attributes that may have multiple values for the same entity. In this database cs_phone of
customer entity can have multiple value
phone
cs_id cs_phone
animals
pet_id breed weight height age fur
birds
pet_id type noise
pet_products
pp_id pp_name pp_type cost belongs_to
customer
cs_id cs_fname cs-minit cs_lname cs-address
sales_details
sd_id cs_id date total
sold_pets
sd_id pet_id
sold_products
sd_id pp_id quantity
phone
cs_id cs_phone
1. calculations_for_pets
create procedure calculations_for_pets(in pid varchar(9),in sid varchar(9))
BEGIN
DECLARE
cpid ,csid int DEFAULT 0;
set cpid=(select cost from pets where pet_id=pid);
set csid=(select total from sales_details where sd_id=sid);
set csid=csid+cpid;
update sales_details set total=csid where sd_id=sid;
end
2. calculations_for_product
create procedure calculations_for_product(in ppid varchar(9),in sid varchar(9),in qnty
int(11))
BEGIN
DECLARE
cppid ,csid int DEFAULT 0;
set cppid=(select cost from pet_products where pp_id=ppid);
set csid=(select total from sales_details where sd_id=sid);
set csid=csid+qnty*cppid;
update sales_details set total=csid where sd_id=sid;
end
CHAPTER 5
FRONT END DESIGN
5.1 CONNECTIVITY TO DATABASE
Systems design is the process of defining the architecture, components, modules,
interfaces, and data for a system to satisfy specified requirements. Systems design could see it
as the application of systems theory to product development. There is some overlap with the
disciplines of systems analysis, systems architecture and systems engineering. If the broader
topic of product development "blends the perspective of marketing, design, and
manufacturing into a single approach to product development," then design is the act of
taking the marketing information and creating the design of the product to be manufactured.
Systems design is therefore the process of defining and developing systems to satisfy
specified requirements of the user.
Until the 1990s systems design had a crucial and respected role in the data processing
industry. In the 1990s standardization of hardware and software resulted in the ability to build
modular systems. The increasing importance of software running on generic platforms has
enhanced the discipline of software engineering.
Object-oriented analysis and design methods are becoming the most widely used
methods for computer systems design.[citation needed] The UML has become the standard
language in object-oriented analysis and design.[citation needed] It is widely used for
modelling software systems and is increasingly used for high designing non-software systems
and organizations.[citation needed]
System design is one of the most important phases of software development process.
The purpose of the design is to plan the solution of a problem specified by the requirement
documentation. In other words the first step in the solution to the problem is the design of the
project.
1.mysqli connect ()
To connect to MySQL using the MySQL Improved extension, follow these steps:
a)Use the following PHP code to connect to MySQL and select a database. Replace
username with your username, password with your password, and dbname with the database
name:
<?php
$mysqli = new mysqli("localhost", "username", "password", "dbname");
?>
b) After the code connects to MySQL and selects the database, you can run SQL queries and
perform other operations.
The connectivity code used in this database is as follows:
<?php
$servername=”localhost”;
$username = “root”;
$password =””
$dbname=”petshop_ management”
$conn= new mysql( $servername,$username,$password,$dbname);
if ($conn -> connect_error)
{ die (“connection failed:”.$conn->connect_error); }
3. Error Handling
It is useful when debugging, and even when you just want to make sure that a database does
not behave unexpectedly. Once a query has been created via the mysql_query() function, any
error messages generated will be stored in the mysql_error() function. Here is a sample code
snippet to display a error message. However, when there is no error messages, a blank string
is returned. print mysql_error();
.button2 {
background-color: transparent;color: white; border-radius: 5px;
border: 3px solid rgba(31, 58, 147, 1);
}
.button2:hover {
background-color:rgba(31, 58, 147, 1); color: white;
}
.button3 {
background-color:transparent; color: white; border-radius: 5px;border: 3px solid #f44336;
}
.button3:hover {
background-color: #f44336;color: white;
}
.button4 {
background-color: transparent; color: white; border-radius: 5px;
border: 3px solid rgba(249, 105, 14, 1);
}
.button4:hover {background-color:rgba(249, 105, 14, 1);color:white;
}
.button5 {
background-color: transparent;color: white;border-radius: 5px;border: 3px solid #b40a70;
}
.button5:hover {
background-color:#8d2663; color: white;
}
</style>
</head>
<body>
<div class="topnav">
<a class="active" href="home.html"><img src="ic_add_pet.png"></a>
<a href="home.html">pets shop</a>
<div class="topnav-right">
<a href="#about">logout</a></div>
</div>
<div class="screen">
<form>
<button class="button button1" type="submit" formaction="animals.php">animals</button>
<button class="button button2" type="submit" formaction="birds.php">Birds</button>
<buttonclass="buttonbutton3"type="submit"formaction="petproducts.php">products</butto>
<buttonclass="button button4" type="submit" formaction="sales.php">salesdetails</button>
<buttonclass="buttonbutton5"type="submit"formaction="customer.php">customer</button>
</form>
</div>
</body>
</html>
<?php
if(isset($_POST["submit"]))
{
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "Petshop_management";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {die("Connection failed: " . $conn->connect_error);}
$id = $_POST["id"];
$name = $_POST["name"];
$type= $_POST["type"];
$belongs = $_POST["belong"];
$cost = $_POST["cost"];
$sql = "INSERT INTO pet_products( pp_id,pp_name,pp_type,cost,belongs_to)
VALUES ('$id','$name','$type','$cost','$belongs')";
if ($conn->query($sql) == TRUE) {echo "New record of id=$id created successfully";}
else { echo "Error: " . $sql . "<br>" . $conn->error;}
$conn->close();
}
?>
<?php
if(isset($_POST["submit"]))
{$servername = "localhost";$username = "root";$password = "";
$dbname = "Petshop_management";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {die("Connection failed: " . $conn->connect_error);}
$id = $_POST["id"];$name = $_POST["name"];$type= $_POST["type"];
$belongs = $_POST["belong"];
$cost = $_POST["cost"];
$sql = "UPDATE pet_products SET pp_name='$name',pp_type='$type',cost='$cost'
,belongs_to='$belongs' WHERE pp_id='$id'";
if ($conn->query($sql) == TRUE) { echo "id=$id updated successfully";}
else { echo "Error: " . $sql . "<br>" . $conn->error;}
$conn->close();
}
?>
CHAPTER 6
TESTING
This chapter gives the outline of all testing methods that are carried out to get a bug
free system. Quality can be achieved by testing the product using different techniques at
different phases of the project development. The purpose of testing is to discover errors.
Testing is the process of trying to discover every conceivable fault or weakness in a work
product. It provides a way to check the functionality of components sub assemblies and/or a
finished product. It is the process of exercising software with the intent of ensuring that the
Software system meets its requirements and user expectations and does not fail in an
unacceptable manner. There are various types of test. Each test type addresses a specific
testing requirement.
CHAPTER 7
RESULTS
This section describes the screens of the “PETSHOP MANAGEMENT SYSTEM”. The
snapshots are shown below for each module.
7.1 SNAPSHOTS
This page asks admin username and password for authentication ,if the authentication is
successfull then it loads home page.
This page provides links to animals page, birds page, products page ,salesdetails page and
customer page.
.
This page accept the data to update in animals entity and pet entity.
CONCLUSION
The development of this Petshop Management System is great improvement over the manual
system which uses lots of manual work and paper. The computerization of the system speeds
up the process.
The Petshop Management System is fast, efficient and reliable, Avoids data redundancy and
inconsistency. It contains all the functional features described in objective of the project.
REFERENCES
[1] Elmasri, Ramez, Fundamentals of database systems. Pearson education in india 2008.
[2] https://programmerblog.net/createmysal-trigger-php/
[3]http://www.tutorialspoint.com
[4] http://www.w3schools.com