Class DB2024TEAM07_RatingDAO

java.lang.Object
com.jdbc.database.DB2024TEAM07_RatingDAO

public class DB2024TEAM07_RatingDAO extends Object
This class provides data access object (DAO) methods for interacting with the DB2024_Rating and DB2024_Review tables in a database. It handles operations related to restaurant reviews and ratings.
  • Field Details

  • Constructor Details

    • DB2024TEAM07_RatingDAO

      public DB2024TEAM07_RatingDAO()
      Constructor that establishes a connection to the database using the DB2024TEAM07_Database class.
  • Method Details

    • add

      public int add(int review_id, int res_id)
      Adds a new review to the DB2024_Rating table.
      Parameters:
      review_id - the ID of the review
      res_id - the ID of the restaurant
      Returns:
      the number of rows affected (usually 1 for a successful insert)
    • getAvg

      public float getAvg(int res_id)
      Calculates and returns the average rating for a specific restaurant.
      Parameters:
      res_id - the ID of the restaurant
      Returns:
      the average rating as a float value