This is a Restaurant Review System built with Python and utilizes SQLAlchemy and Alembic Migrations, SQLAlchemy Relationships, Class and Instance Methods, and SQLAlchemy Querying working with a Yelp-style domain with three models: Restaurant, Review, and Customer.
NOTE: Some methods in the deliverables have been changed so they don't conflict with table names.
The packages are included in the Pipfile, and can be installed through it into the virtual environment.
-
Python3 v3.10 +
-
SQLAlchemy v2.0.20
-
Alembic v1.12.0
-
Faker v19.3.1
- Create and manage customer and restaurant profiles
- Add, retrieve, and delete reviews for restaurants
- Find customers and restaurants based on reviews
- Retrieve a list of all reviews
- Find the fanciest restaurant in the list
- Find a customer's favorite restaurant
git clone https://github.com/ArshavineRoy/sqlalchemy-code-challengecd sqlalchemy-code-challengeThe root directory of this repository contains the Pipfile with all the required dependencies. To install them into your virtual environment, run this command from the root directory:
pipenv installIf pipenv is not already installed, you can do so using pip:
pip install pipenvpipenv shellRun all commands from within this directory
cd app./main.pyThe Restaurant Review System uses the Association Object Models for the associations and relationships between the three models: Restaurant, Customer, and Reviews.
A Restaurant has many Reviews, a Customer has many Reviews, and a Review belongs to a Restaurant and to a Customer. The ERD below shows these relationships:
You can use the Restaurant Review System to simulate interactions between customers, restaurants, and reviews to:
- Create customer and restaurant instances.
- Add reviews using the add_review method.
- Retrieve information about customers, restaurants, and reviews using the provided methods.
For example, you should be able to call session.query(Customer).first().all_restaurants() and see a list of the restaurants for the first customer in the database based on your seed data; and session.query(Review).first().customer should return the customer for the first review in the database.
Use the seed.py file to create sample data to test the models and relationships by the following methods.
self.all_reviews()
-
changed from
self.reviews()in deliverables -
returns a collection of all the reviews for the
Restaurant
self.all_customers()
-
changed from
self.customers()in deliverables. -
returns a collection of all the customers who reviewed the
Restaurant
cls.fanciest()
- A class method that returns one restaurant instance for the restaurant that has the highest price
self.all_reviews_formatted()
- returns a list of strings with all the reviews for this restaurant in the following format:
[ "Review for {insert restaurant name} by {insert customer's full name}: {insert review star_rating} stars.",
"Review for {insert restaurant name} by {insert customer's full name}: {insert review star_rating} stars.", ]self.all_reviews()
-
changed from
self.reviews()in deliverables. -
returns a collection of all the reviews that the
Customerhas left
self.all_restaurants()
changed from self.restaurants() in deliverables.
- returns a collection of all the restaurants that the
Customerhas reviewed
self.full_name()
- returns the full name of the customer, with the first name and the last name concatenated, Western style.
self.favorite_restaurant()
- returns the restaurant instance that has the highest star rating from this customer
self.add_review(restaurant, rating)
-
takes a
restaurant(an instance of theRestaurantclass) and a rating -
creates a new review for the restaurant with the given
restaurant_id
self.delete_reviews(restaurant)
-
takes a
restaurant(an instance of theRestaurantclass) and -
removes all their reviews for this restaurant
review.customer()
- returns the
Customerinstance for this review
review.restaurant()
- returns the
Restaurantinstance for this review
review.full_review()
- returns a string in the following format:
Review for {insert restaurant name} by {customer full_name}: {review star_rating} stars.
Authored by Arshavine Waema.
Licensed under the MIT License - see the LICENSE file for details.
