Solution#163
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because the indexing requirements for all relevant tables are not yet fully met, even though what you have so far is on the right track. You correctly select the ShopDB database and create indexes Email on Customers(Email) and Name on Products(Name), which aligns with login-by-email and product-search-by-name usage patterns. However, the task explicitly expects indexes to support queries involving Orders and OrderItems, and those are missing: you should add CREATE INDEX CustomerID ON Orders(CustomerID);, CREATE INDEX OrderID ON OrderItems(OrderID);, and CREATE INDEX ProductID ON OrderItems(ProductID); in task.sql (near your existing index statements). These columns are commonly used in joins and filters (e.g., fetching orders by customer or order items by order/product), so without these indexes queries will be slower and tests that check for these indexes may fail. After adding those, optionally consider whether your scenario needs an index on Orders(Date) for frequent date-range queries, but that part is not strictly required. Once updated, re-run the provided test steps (ensuring the tables are empty and then running test.sql) to verify everything passes. Your current work shows good understanding of basic indexing; adjusting these few missing indexes will complete the solution.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
| @@ -1,2 +1,4 @@ | |||
| # Write your SQL code for the database creation here. Good luck! | |||
| USE ShopDB; | |||
| USE ShopDB; | |||
There was a problem hiding this comment.
Good to use the correct database with USE ShopDB; — ensure you ran the create-database.sql script beforehand so this database exists before running these statements.
| USE ShopDB; | ||
| USE ShopDB; | ||
|
|
||
| CREATE INDEX Email ON Customers(Email); |
There was a problem hiding this comment.
You created an index on Customers(Email), which is appropriate for login-by-email queries. The task also expects indexes on other tables/columns inferred from the usage scenario — those are currently missing.
| USE ShopDB; | ||
|
|
||
| CREATE INDEX Email ON Customers(Email); | ||
| CREATE INDEX Name ON Products(Name); No newline at end of file |
There was a problem hiding this comment.
You created an index on Products(Name), which is appropriate for product searches. However, you should also add indexes for Orders.CustomerID and for OrderItems.OrderID and OrderItems.ProductID. Per the code-style requirement, name each index exactly as the column (for example: CREATE INDEX CustomerID ON Orders(CustomerID);).
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your solution is approved because task.sql correctly selects the ShopDB database and creates all required indexes: Email on Customers(Email), Name on Products(Name), CustomerID on Orders(CustomerID), and both OrderID and ProductID on OrderItems, with index names matching the column names as required [CHECKLIST ITEM #1, #2, #11, #14, #18-21]. These indexes align well with the described usage patterns: login by email, product search by name, and efficient joins/filters across orders and order items. There are no critical blockers to functionality based on the task description, so the core requirements are met. As a best practice (not required for this task), you could consider making the script idempotent by using guards such as CREATE INDEX IF NOT EXISTS ... so rerunning it won’t fail if indexes already exist. Also optionally, if you later observe frequent date-range filtering on orders, adding an index like CREATE INDEX Date ON Orders(Date); could further improve performance. To fully validate everything in your own environment, it would be good to run create-database.sql, ensure the tables are empty, execute task.sql, and then run test.sql to confirm all checks pass [CHECKLIST ITEM #10, #13, #15-17, #22].
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.