You are on page 1of 3

Task 1

Our first task is to create an erd using crow foot notation for the cooking recipe website. The figure
below is the erd our database.

There are total 8 numbers of tables in our database

1. User that is going to search the recipe


2. Recipe table that includes method and description about the recipe
3. Search table to overcome many to many relationship between user and recipe.
4. Feedback table that includes the feedback of the recipe given by the user.
5. Ingredients table that includes all the ingredients.
6. Recipe ingredients table to overcome many to many relationships between recipe and
ingredients also include the quantity and ingredient type in the recipe.
7. Course table that include the course type of the recipe.
8. Recipe Course table to overcome the many to many relationships between course table and
recipe table.

Task 2
Next task is to create a data dictionary for each attribute in the table including data type, size and also
include the primary and foreign key constraints. The attached excel file has the data dictionary for each
field for each table.
Task 3
Task 3 is to create the tables in the postgresql. The image below show the basic format of creating tables
in postgresql.

To do this task, pgadmin4 tool is used. The attached text file contains the script of whole erd.

Task 4
The next task is to test some queries that are as follow:

i. Find the starter recipe that can be served to 4 people. the query has inner join between
three table recipe that are to be selected, course that having the information about the
starter and the recipecourse table that links course and recipe table. The query and output
are shown in the figure below.

SELECT * from recipe

Inner join recipecourse on recipe.recp_id=recipecourse.recp_id

Inner join course on course.course_id=recipecourse.course_id

Where course.course_type = ‘starter’ and recipe.recp_served=’4’;

ii. Find the recipe that has chicken as a starter. There are also an inner join between three
tables include recipe, ingredient table and the recipeingredient that links them.

SELECT * from recipe


Join recipeingredients on recipeingredients.recp_id=recipe.recp_id

Join ingredients on ingredients.ing_id= recipeingredients.ing_id

Where recipeingredients.ing_type= ‘main’;

iii. Find the vegan recipe. There is a simple query for this.

SELECT * from recipe

Where recp_category=’vegon’;

You might also like