Parts Implemented by Sadık Ekin Özbay

I did CRUD operations of Restaurants, Comments and Foods. Moreover I did create function of order.

Restaurants Table

Restaurants are the main part of our project.

Attributes of Restaurants Table

  • ID SERIAL PRIMARY KEY
    Primary key of restaurants.
  • NAME VARCHAR(80) NOT NULL
    Name of the restaurant.
  • ADDRESS VARCHAR(255) NOT NULL
    Address of the restaurant.
  • CONTACT_NAME VARCHAR(80) NOT NULL
    Contact name of the restaurant.
  • CREATOR_ID INTEGER REFERENCES USERS(ID)
    Person who created the restaurant. It is also a reference to users.
  • SCORE INTEGER NOT NULL DEFAULT 0 CHECK( SCORE >= 0 AND SCORE <= 5),
    Score of the restaurant. It have to be bigger than 0 and smaller than 5.
  • PROFILE_PICTURE VARCHAR(500) NOT NULL,
    It is profile picture link for the restaurant.
  • HOURS VARCHAR(80) NOT NULL,
    It is working hours of the restaurant.
  • CURRENT_STATUS VARCHAR(80) NOT NULL
    It is current status of the restaurant.

Operations

To operate create, select, update and delete operations a class implemented. Class structure is used. .. code-block:: python

class Restaurant():
def __init__(self):
self.primaryId = “” self.name = “” self.address = “” self.contactName = ‘’ self.creatorId = “” self.score = 0 self.profilePicture = “” self.hours = “” self.currentStatus = “”

Create

To add new restaurant, create_restaurant method of Restaurant class used. This constructor takes form and current user ID.

Edit

To edit a restaurant, update_restaurant_by_id method of Restaurant class used. This constructor takes form, restaurant ID and current user ID.

Delete

To delete a restaurant, edit_restaurant method of Restaurant class used. This constructor takes only restaurant ID.

Select One

This method is used for selecting just one spesific restaurant from all restaurants. This method is used in Restaurant show page.

Select All

This method is used for selecting all restaurants.This method is used in Restaurant index page.

Give Star To A Restaurant

This method allows the users to give ratings to restaurants. The second function checks if the user gave a rating to that restaurant or not. It s/he is not, then s/he can give a rating.

Foods Table

Foods are the main part of the Restaurants. We can add foods to restaurants.

Attributes of Foods Table

  • ID SERIAL PRIMARY KEY
    Primary key of foods.
  • NAME VARCHAR(80) NOT NULL
    Name of the foods.
  • ICON VARCHAR(255) NOT NULL
    Icon of the fo0ds.
  • FOOD_TYPE VARCHAR(80) NOT NULL
    Type name of the foods.
  • PRICE VARCHAR(80) NOT NULL
    Price of the foods.
  • CALORIE VARCHAR(80) NOT NULL
    Calorie of the foods.

Operations

To operate create, select, update and delete operations a class implemented. Class structure is used. .. code-block:: python

class Foods():
def __init__(self):
self.primaryId = “” self.name = “” self.icon = “” self.foodType = “” self.price = “” self.calori = “”

Create

To add new food, create_food method of Food class used. This constructor takes form.

Edit

To edit a food, food_edit_page is used.

Delete

To delete a food, food_delete_func method is used.

Select All

This method is used for selecting all foods.This method is used in add food to the restaurant page.

Restaurant_Foods Table

This is the connection table for restaurants and foods.

Attributes of Restaurant_Foods Table

  • ID SERIAL PRIMARY KEY
    Primary key of restaurant foods.
  • RESTAURANT_ID INTEGER REFERENCES RESTAURANTS(ID) ON DELETE CASCADE
    Reference to the restaurant.
  • FOOD_ID INTEGER REFERENCES FOODS(ID) ON DELETE CASCADE
    Referece to foods.
  • SELL_COUNT INTEGER NOT NULL
    Sell count of spesific food on spesific restaurant.

Operations

To operate create. Class structure is used. .. code-block:: python

class RestaurantFoods():
def __init__(self, primaryId, restaurantId, foodId):
self.primaryId = primaryId self.restaurantId = restaurantId self.foodId = foodId

Create

To add new food to the spesific restaurant, we use this. Implemented the food part. My friend, Burak Bekci, implemented drink part.

Comments Table

Comments are the one of the main part for restaurants.

Attributes of Comments Table

  • ID SERIAL PRIMARY KEY
    Primary key of the comment.
  • USER_ID INTEGER REFERENCES USERS(ID) ON DELETE CASCADE
    Reference to the user.
  • RESTAURANT_ID INTEGER REFERENCES RESTAURANTS(ID) ON DELETE CASCADE
    Reference of the restaurant.
  • CONTENT VARCHAR(255) NOT NULL
    Content of the comment
  • SENDDATE TIMESTAMP NOT NULL
    Send date of the comment

Operations

To operate create, delete and select operations a class implemented.

Create

To create new comment, we take content of the comment from user. We take id of the user and id of the current user automaticly.

Delete

Only admin user can delete the comment.

Select All

This method is used for selecting all comments.This method is used in Restaurant show page for showing the comments.