Question: USE MS SQL SERVER! make sure queries run with dummy data. In this assignment, you will implement several queries and triggers in SQL for the
USE MS SQL SERVER! make sure queries run with dummy data.
In this assignment, you will implement several queries and triggers in SQL for the Yelp Edmonton database created in Assignment Here are once more the database tables:
business business id name, address, city, postalcode, stars, reviewcount
checkin checkin id businessid date
tip tip id userid businessid date, complimentcount
review review id userid businessid stars, useful, funny, cool, date
useryelp user id name, reviewcount, yelpingsince, useful, funny, cool, fans, averagestars
friendship user id friend
Assignment marks
Formulate the following queries in SQL Server SQL:
a Select the names of the users who have received the highest number of compliments on their tips. marks
Note: You need to count the compliments for each user and identify the users with the maximum compliments.
b Select the names of businesses that have received more than five reviews and have an average rating of stars or higher. Include only businesses that are located in 'Edmonton'. marks
c Select the average number of stars of all 'Best Buy' locations that were reviewed by a user named 'John' and have any review not necessarily John's review that was voted as 'useful' atmost thrice.
marks
Note: The result must be a decimal number representing the average stars of all Best Buy stores that meet the criteria.
d Select the number of businesses that have received reviews from two friends, where one friend gave a review marked as "useful" and the other friend gave a review marked as "funny." marks
Assignment marks
Formulate the following integrity constraints as triggers in SQL Server SQL:
a When a new tip is registered, update the total number of tips for the corresponding
business. If a tip is submitted by a user who has already tipped for that business, only the
latest tip from that user should be considered for counting. Use the tip table's existing
columns to derive the count. marks
b Implement a rule that users can only leave a review for a business if they have at least one
friend who has also reviewed that business. This rule should only apply to new reviews and
should not affect any existing reviews already recorded in the database. marks
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
