You are on page 1of 7

DATABASE – S8 PRACTICE

Name: Renato L. Dulog ID Number: 22104607

Exercise 1: Design Foodpanda’s relational database

Foodpanda is a Cambodian application where customers can order different


meals from a restaurant. After they have ordered, they can either pick up the
order at the restaurant or be delivered by a delivery person.

The goal of this exercise is to make you design the Entity Relationship Diagram
of the Foodpanda database just by understanding how the application works.

Below is a description of how Foodpanda’s database entities are related. Read


id carefully, each point is important.

CUSTOMER
● The CUSTOMER has an account on the application. When he creates
his account, he needs to inform his first name, last name, email
address, phone number, and postal address.
● The CUSTOMER can make as many ORDERS as he want with
the application

ORDER
● An ORDER is made by one CUSTOMER.
● An ORDER is described by the total price of the ORDER, the date of the
ORDER. If the CUSTOMER will pick up the ORDER at the RESTAURANT
or if he has it delivered. The address of delivery if he has it delivered.
● If the ORDER is delivered, it is taken care of by one delivery person
● An ORDER can contain many FOOD ITEMS.
● An ORDER can be made only in one RESTAURANT.

FOOD ITEM
● A FOOD ITEM is described by his name, his unit price, his food
category, and the RESTAURANT where it is cooked.
● One FOOD ITEM can appear in different ORDERS.

RESTAURANT
● A RESTAURANT is described by his name, his address, his website, his
phone number and his restaurant category
● One RESTAURANT can take care of many ORDERS
● One RESTAURANT has many FOOD ITEMS to offer

DELIVERY PERSON
● The DELIVERY PERSON is described by his name, his phone number
and his vehicle (scooter or bike or car or tuktuk)
● One DELIVERY PERSON can take care of many ORDERS

ADDRESS
● The ADDRESS is described by its street, its city and its province.
● In Foodpanda:
o the addresses of where live the customers are stored
o the addresses of where the order is delivered is stored
o the addresses of the restaurants are stored
QUESTIONS

Q1) List the entities that compose the Foodpanda’s database. You need to
find 6 entities.

Answer:
 CUSTOMER
 ORDER
 FOOD
 ITEM
 RESTAURANT
 DELIVERY PERSON
 ADDRESS

Q2) Represent the table schema/model of each entity (6 entities including


the Delivery Person) with their attribute and the data type of the attributes.
Don’t forget the Primary Key.

CUSTOMER
PK customer_id Numeric
first_name String
last_name String
email_address String
phone_number Numeric
postal_addres String
s

ORDER
PK order_id Numeric
FK customer_id Numeric
total_price Numeric
order_date Date
delivery_option String
delivery_address String
FK delivery_person_i Numeric
FK d Numeric
restaurant_id

FOOD
PK food_item_id Numeric
food_item_name String
unit_price Numeric
food_category String
FK restaurant_id Numeric

RESTAURANT
PK restaurant_id Numeric
restaurant_name String
address String
website String
phone_number Numeric
restaurant String
category

DELIVERY PERSON
PK delivery_person_i Numeric
d String
name Numeric
phone_number String
vehicle

ADDRESS
PK address_id Numeric
street String
city String
province String

Q3) Identify the relation between each entity that are related (One to many,
Many to Many) and justify your answer. You should find 7 relations between
the 6 entities.

Answer:

1. One-to-Many relationship between CUSTOMER and ORDER: One CUSTOMER can


make many ORDERS, but each ORDER is made by only one CUSTOMER.

2. One-to-Many relationship between ORDER and FOOD ITEM: One ORDER can
contain many FOOD ITEMS, but each FOOD ITEM belongs to only one ORDER.

3. Many-to-One relationship between ORDER and CUSTOMER: Many ORDERS can


be made by one CUSTOMER, but each ORDER is made by only one CUSTOMER.

4. Many-to-One relationship between ORDER and RESTAURANT: Many ORDERS can


be made at one RESTAURANT, but each ORDER is made at only one
RESTAURANT.
5. Many-to-One relationship between ORDER and DELIVERY PERSON: Many
ORDERS can be taken care of by one DELIVERY PERSON, but each ORDER is taken
care of by only one DELIVERY PERSON.

6. One-to-Many relationship between RESTAURANT and FOOD ITEM: One


RESTAURANT can offer many FOOD ITEMS, but each FOOD ITEM is offered by
only one RESTAURANT.

7. Many-to-Many relationship between ADDRESS and


CUSTOMER/RESTAURANT/ORDER: One ADDRESS can be associated with many
CUSTOMERS, RESTAURANTS, or ORDERS, and each CUSTOMER, RESTAURANT, or
ORDER can be associated with many ADDRESSES. This relationship is justified by
the fact that an ADDRESS can be shared by multiple entities in the FoodPanda
application, such as the customer's home address, the delivery address for an
order, or the address of a restaurant.
Q4) ONE TO MANY RELATIONS: Now that you have identified the relations,
select the ONE TO MANY relationship and make the Entity Relationship
Diagram of each relation. Add the Foreign Keys.

Example: relation between the FOOD ITEM and the RESTAURANT tables. I added
the Restaurant id as a foreign key the the FOOD ITEM table.

FOOD ITEM
PK XX XX
X X
FK XX XX
X X
Restaurant id numeric
RESTAURANT
XX XX
X X
XX XX
X X
XX XX
X X

Q5) MANY TO MANY RELATIONS: You should have identified only one MANY
TO MANY relation. Design the intersection table in order to represent the
Entity Relationship Diagram of this relation.

Example from previous practice on Google Classroom Database:


relation between USER and CLASSROOM. You had to create the
intersection table User_Classroom.

Q6) Merge the Entity Relationship Diagram of each relation to design the Entity
Relationship Diagram of the Foodpanda database.

Example from previous practice: Entity Relationship Diagram of the Google


Classroom database

You might also like