Created creating indexes script#162
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes because the indexing is only partially aligned with the requirements and will likely fail the expected tests. You correctly created CREATE INDEX Name ON Products (Name); and CREATE INDEX Email ON Customers (Email);, which match the column-name rule and support the product search and login scenarios well. However, task.sql is missing the order-related indexes that the usage scenarios clearly imply and that are typically required for correct performance and test coverage: an index on Orders(CustomerID) and indexes on OrderItems(OrderID) and OrderItems(ProductID). These are critical because queries that join Orders to Customers on CustomerID and OrderItems to Orders/Products on OrderID/ProductID will be inefficient and may cause the automated tests to fail without them. In task.sql, after selecting the ShopDB database and after your existing index statements, add:
CREATE INDEX CustomerID ON Orders (CustomerID);CREATE INDEX OrderID ON OrderItems (OrderID);CREATE INDEX ProductID ON OrderItems (ProductID);
Make sure the index names remain exactly the same as their column names, as you already did forNameandEmail. Once you add these three indexes, your solution should fully cover the main read paths (login, product search, and order lookups), and the script will better meet the task’s expectations.
✨ 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
| # Write your SQL code for the database creation here. Good luck! | ||
| USE ShopDB; | ||
|
|
||
| CREATE INDEX Name ON Products (Name); |
There was a problem hiding this comment.
You created an index on Products(Name) named Name, which matches the naming requirement and is appropriate for product searches. However, the script is missing other indexes implied by the usage scenarios (see comments).
| USE ShopDB; | ||
|
|
||
| CREATE INDEX Name ON Products (Name); | ||
| CREATE INDEX Email ON Customers (Email); |
There was a problem hiding this comment.
Index on Customers(Email) named Email is correct and necessary (login checks use email). Keep this.
| @@ -1,2 +1,5 @@ | |||
| # Write your SQL code for the database creation here. Good luck! | |||
| USE ShopDB; | |||
|
|
|||
There was a problem hiding this comment.
Add indexes for order-related lookups. Based on the usage scenarios, add at least:
CREATE INDEX CustomerID ON Orders (CustomerID);
CREATE INDEX OrderID ON OrderItems (OrderID);
CREATE INDEX ProductID ON OrderItems (ProductID);
These indexes improve joins/queries for orders and order items and are usually required by the tests.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am approving your solution because the SQL script correctly selects the ShopDB database and creates all required indexes with names that exactly match their columns (Name on Products(Name), Email on Customers(Email), CustomerID on Orders(CustomerID), OrderID on OrderItems(OrderID), and ProductID on OrderItems(ProductID)). The implemented indexes align well with the intended usage scenarios—product name searches, customer email lookups, and efficient access to orders and order items—so the functional requirements of the task are fully satisfied. I do not see any critical issues that would prevent task.sql from running correctly on a database created from the provided schema. As a minor operational improvement, make sure you run create-database.sql to create the ShopDB database and then execute your task.sql followed by the optional test.sql locally to confirm there are no runtime errors. Another optional enhancement is to consider an index on Orders(Date) if you expect frequent queries or reports filtered by order date, although this is not a mandatory requirement. Overall, your work meets the task expectations and demonstrates a solid understanding of indexing to support the described query patterns.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.