Nice post, Ezzdin! The database design is really good, and I really enjoyed reading this.
Here are my suggestions -
In the context of cart_item and order_item, you probably don't need product_id as it is redundant. The required data can be fetched using product_skus_id.
Storing the total directly in the cart table introduces redundancy, as the total is calculated based on the individual product prices or quantities. This redundancy can lead to data integrity issues. Unless you are using some event-driven mechanism such as database triggers, instead of storing the total directly in the database, you might need to calculate the total dynamically when needed.
Creative and energetic Software Engineer with 3 years of experience full of challenges, difficulties, and achievements. Love learning new things and teaching others and developing software.
Thank you so much for your positive feedback and insightful suggestions! I'm thrilled to hear that you found the article interesting.
You have a good point about the product_id redundancy, and I will updated the structure with this optimization.
Regarding the storage of the total directly in the cart table, I appreciate your concern about redundancy and potential data integrity issues and instead of that we can calculate the total dynamically when needed, and actually I don’t know much about the event-driven mechanism and will lock into that. Thanks Adhiraj!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice post, Ezzdin! The database design is really good, and I really enjoyed reading this.
Here are my suggestions -
In the context of
cart_itemandorder_item, you probably don't needproduct_idas it is redundant. The required data can be fetched usingproduct_skus_id.Storing the total directly in the cart table introduces redundancy, as the total is calculated based on the individual product prices or quantities. This redundancy can lead to data integrity issues. Unless you are using some event-driven mechanism such as database triggers, instead of storing the total directly in the database, you might need to calculate the total dynamically when needed.
Thank you so much for your positive feedback and insightful suggestions! I'm thrilled to hear that you found the article interesting.
You have a good point about the
product_idredundancy, and I will updated the structure with this optimization.Regarding the storage of the total directly in the cart table, I appreciate your concern about redundancy and potential data integrity issues and instead of that we can calculate the total dynamically when needed, and actually I don’t know much about the event-driven mechanism and will lock into that. Thanks Adhiraj!