Está en la página 1de 13

NITTE MEENAKSHI INSTITUTE OF TECHNOLOGY

(AN AUTONOMOUS INSTITUTION)


(AFFILIATED TO VISVESVARAYA TECHNOLOGICAL UNIVERSITY, BELGAUM, APPROVED BY AICTE & GOVT.OF KARNATAKA)

COURSE-PROJECT REPORT
ON

RECIPE DATABASE

Submitted by:
Aniruddha Achar B P
Adarsh G Sosale

1NT13CS016
1NT13CS006

In partial fulfilment of the requirements for the completion of V Semester Database


Management System Course-Project work during the academic year 2015-2016.

Department of Computer Science and Engineering


Nitte Meenakshi Institute of Technology,
Yelahanka, Bangalore 560064
Academic Year 2014-15

NITTE MEENAKSHI INSTITUTE OF TECHNOLOGY


(AN AUTONOMOUS INSTITUTION)
(AFFILIATED TO VISVESVARAYA TECHNOLOGICAL UNIVERSITY, BELGAUM, APPROVED BY AICTE & GOVT.OF KARNATAKA)

CERTIFICATE
This is to certify that the Project Report

Recipe Database
Is an authentic work carried out by
Aniruddha Achar B P
Adarsh G Sosale

1NT13CS016
1NT13CS006

In partial fulfilment of the requirements for the completion of V Semester Database


Management System Course-Project work during the academic year 2015-2016.

Name & Signature of the Guide

Name & Signature of HOD

Acknowledgement
This project was compiled for the Database Management System Course of 5th Semester.
We would like to thank our Assistant professor, Mr. Afroz Pasha for providing us with the
opportunity and motivating us to come up with something new and creative. We also thank
him for his assistance and support, both moral and technical, in writing this project.
We would also like to thank our respective parents and family members, all of whom have been
thoroughly supportive.
We are also grateful to the internet, in no small amounts, for all the amazing research material
and ideas which inspired us to come up with something on our own.
Last, but not the least, we are sincerely indebted to the author of the prescribed text book,
Ramez Elmasir and Shamkant B. Navethe, for providing us an absolute reference guide, using
which we could solve numerous technical problems we faced.
With the mutual consensus among the team members, we have decided to release the source
code of this project to the public, effectively making this whole project open source, after the
due evaluation is done.
The project and its code will soon be available on Github, under MIT/APACHE license.

ABSTRACT

In this connected world, sharing of information is a concept we take for granted. Where is this
information stored? How is this information stored? How is this information retrieved? We use
databases. In this project we try to use various concepts of database management to create a
database of cooking recipes and present them using a web frontend.

Contents
Acknowledgement ..................................................................................................................... 3
Chapter 1 Introduction: .............................................................................................................. 1
1.1Project Scope .................................................................................................................... 1
1.2 Motivation ........................................................................................................................ 1
1.3 Overview of the report: .................................................................................................... 1
Chapter 2 Design of the database: ............................................................................................. 2
2.1 Database requirements: .................................................................................................... 2
2.2 ER diagram: .................................................................................................................... 2
2.3 UML diagram: ................................................................................................................. 3
Chapter 3 Design and use of stored procedures ......................................................................... 4
3.1 getDetail() ........................................................................................................................ 4
3.2 insertingredient() .............................................................................................................. 4
3.3 getDetails_by_ingredients() ............................................................................................. 6
Chapter 4 Web interface for the database .................................................................................. 7
4.1 Business logic: ................................................................................................................. 7
4.2 Presentation ...................................................................................................................... 7
Chapter 5 Result and future development .................................................................................. 8
5.1 Future development: ........................................................................................................ 8

Chapter 1

Recipe Database

Chapter 1 Introduction:
1.1Project Scope
This project develops a database and an accompanying front end system to store, manage, and
retrieve various recipes. The user can view the recipes stored in the database, update the names
of the recipes stored in the database, delete recipes and insert new recipes using the web front
end.

1.2 Motivation
As the famous proverb goes Necessity is the mother of all inventions, the idea and
the motivation for us to develop a project to manage recipes is the need to have a personalized
database that has the recipes that one needs and not inundated with ones written by thousands
of people on the internet. This also helps us securely save and manage recipes that are
specifically designed for the individual or the family. This project also provides us with the
opportunity to learn various concepts not only in DBMS but also in JAVA which is used to
implement the front end web platform.

1.3 Overview of the report:


The rest of the report deals with the design, implementation and use of the web platform
and the database.

Chapter 2: Deals with the design of the database for storing and maintaining the
recipes. In this chapter the decomposition of the various relations obtained
through the requirement study.
Chapter 3: Deals with the various stored procedures defined to retrieve and
insert data into the database.
Chapter 4: Deals with the front end web platform, its design, implementation
and use.
Chapter 5: Deals with the result of the project and further development of the
concepts explored in this project.

1
Department of Computer Science

Chapter 2

Recipe Database

Chapter 2 Design of the database:


2.1 Database requirements:

Each recipe will have a recipe id, name, cooking and preparation time.
Each ingredient will have an ingredient name and an ingredient id.
The recipe is related to ingredients by a uses relation which also specifies the quantity
of ingredients being used here.
Each recipe will belong to a cuisine type and a recipe type.

From the above requirements it was easy for us to write the functional dependencies of all the
relations. To maintain the basic normal forms and for ease of access of data in the database, all
the tuples were indexed.

2.2 ER diagram:

ID

Prep
Time

Name

Cooking
time

Steps

Recipe
1
1

Cuisine

ID

Region

Type
of
recipe

Has
ingre
dient
s

Cuisine
type

Quantity

Ingredients

ID

Recipe type

Nam
e

ID

Name

Name

2
Department of Computer Science

Chapter 2

Recipe Database

2.3 UML diagram:

3
Department of Computer Science

Chapter 3

Recipe Database

Chapter 3 Design and use of stored procedures


In this chapter we discuss about the stored procedures used in the implementation of the project.
The stored procedures were used here to make data retrieval easy and used for conditional
insertion of data into the database.
There are two stored procedures used in the project:
1. getDetail()
2. insertingredient()
3. getDetails_by_ingredients()

3.1 getDetail()
This stored function is used to get the details about the recipe. It is used to retrieve the
ingredients used in the recipe, the recipe name and the quantity of ingredients used. This takes
an integer parameter that is the recipe id whose details needs to be retrieved.
PROCEDURE `getDetails`(rid int)
BEGIN
select Recipe_name as name, ingredients.Name as Ingredients, recipe_ingredients.Quantity
as Quantity from (recipe join recipe_ingredients on recipe_ingredients.`R-id` =
recipe.idRecipe)join ingredients on ingredients.Ingredientid = recipe_ingredients.I_id where
idRecipe = rid;

END

3.2 insertingredient()
This procedure is used to insert ingredients into a new recipe. A special procedure is used to
reduce data redundancy. When a new recipe is added into the database, it is necessary that the
ingredients of preexisting recipes should not be added back again into the database. This can
be achieved by first checking if the ingredient that is to be mapped to the recipe already
exists. If it exists, then we need to just map the recipe with the existing recipe along with the
quantity of the ingredient to be used. If the ingredient does not exist, we need to insert the
ingredient into the database and the map it to the recipe along with the ingredients quantity.

4
Department of Computer Science

Chapter 3

Recipe Database

PROCEDURE `insertingredient`(iname varchar(20), rname varchar(100),quantity varchar


(100))
BEGIN
if (exists (select * from ingredients where ingredients.Name = iname)) then
select @iid:= ingredients.Ingredientid as ingredient_id from ingredients where
ingredients.Name = iname;
select @rid:= recipe.idRecipe from recipe where recipe.Recipe_name = rname;
select recipe.idRecipe from recipe where recipe.Recipe_name = rname;
select rname;
select @iid;
select @rid;
insert into recipe_ingredients values (@rid,@iid,quantity);
select * from recipe_ingredients;

else
insert into ingredients (Name) value (iname);
select @iid:= ingredients.Ingredientid as ingredient_id from ingredients where
ingredients.Name = iname;
select @rid := idRecipe from recipe where Recipe_name = rname;
INSERT INTO `recipe_db`.`recipe_ingredients` (`R-id`, `I_id`, `Quantity`) values
(@rid,@iid,quantity);
end if;
END
The above procedure takes in three components
1. Ingredient name.
2. Recipe name.
5
Department of Computer Science

Chapter 3

Recipe Database

3. Quantity.
The procedure first checks if the ingredient already exists in the ingredient table. If it exists,
we need not add it again. We just need to add it to the recipe_ingredient table along with the
quantity of that ingredient being used. If the ingredient is new, we add it into the ingredients
table where it is given a new ingredient id. This new ingredient is then mapped to the recipe it
is used in through the recipe_ingredient table where the quantity of the ingredient being used.

3.3 getDetails_by_ingredients()
One feature implemented in this project was to search the recipes using the ingredients. To
achieve this we had to first retrieve the ingredient id of the ingredient that is being searched,
then combine the various tables that make up a recipe and then retrieve all the recipes that use
this ingredient.
PROCEDURE `getDetails_by_ingredients`(iname varchar(20))
BEGIN
select distinct Recipe_name as name, ingredients.Name as Ingredients,
recipe_ingredients.Quantity as Quantity from (recipe join recipe_ingredients on
recipe_ingredients.`R-id` = recipe.idRecipe)join ingredients on ingredients.Ingredientid =
recipe_ingredients.I_id where ingredients.name=iname;
END
The above procedure takes in ingredient as an argument and then searches for recipes that have
this ingredient as a part of it.

6
Department of Computer Science

Chapter 5

Recipe Database

Chapter 4 Web interface for the database


The presentation of the database content to the user in a friendly and clear way can be achieved
by using web interfaces where the data is retrieved from the database and presented to the user
in the html or other web format. The user uses a web browser to view data present in the
database.
For this project we decided to use Java for connecting, retrieving and processing the data from
the database. Java was used to handle the business logic of the web platform. We used Java
Server Page for the presentation of the retrieved data. JSP provided us with the required amount
of control to check various run time conditions and to appropriately react to users input.

4.1 Business logic:


Java is used to connect to the MySQL database where all the recipes are stored. The connection
is established using a Driver manager class object which hold the information about the
location of the database, type of the database being used and the type of database user, his/ her
credentials. After a connection is established, a statement object is created to execute queries.
A separate class was create to hold all the details of the recipes. This class had attributes similar
to the recipe attributes in the database. Along with these attributes, various methods to get these
attributes were also defined in this class.
Different classes and associated methods were defined for the actions that the user could
perform on the web platform. Classes for searching for the recipes by recipe name or
ingredients in the recipe was created. Similarly classes for browsing through the recipes and
adding and deleting recipes were also created.
In these classes various SQL queries along with the prepared statements mentioned in the
previous chapter was used to retrieve, add, update and delete data from the database.

4.2 Presentation
JSP was used to present the data retrieved by the java classes. For the presentation, HTML and
CSS along with a few lines of Java Script was used in the project. A CSS library called Boot
strap by twitter was used.
Using JSP, various forms for searching, updating, adding and deleting recipes was performed.
These forms were processed using request from the client. These requests were stored in a
variable, depending on the request, appropriate actions to either browse, search, update, delate
or add a recipe was used.
The web platform was hosted on a glass fish server.

7
Department of Computer Science

Chapter 5

Recipe Database

Chapter 5 Result and future development


The objectives and goals that we had set out with were all met. We developed a database that
stores and manages various recipes. To support the database, we developed a web front end in
Java and JSP. The database is in 3NF. The user can search, delete, add and remove the recipes
from the database.

5.1 Future development:


Possible future development includes deploying this database and the web front end on a open
source web platform where people can add, see and update recipes. Other addition that can be
done to this project is addition of a shopping list based on the recipes the user wants to cook
for a week. The web site would present the user with a weekly timetable of recipes and also
the list of ingredients the user need to prepare these recipes.

8
Department of Computer Science

También podría gustarte