I'm in need of some help with the database design of order table of a shopping cart for online food ordering system. I have a design below. Tables about which I'm Concerned are order_details and order. Basically what is going to happen is user selects foods from restaurant menus and will place order, User details are stored in the user table (which is not shown in the image).
This is my first attempt, I was never good at Database. So please take it easy if you fill that the question is way too low for this site.
And my questions are:
- Are the tables good enough?
- Do I need to add any more fields?
And one more question I need to store multiple addresses of users(user can have multiple shipping address) how can I handle this?
Note The item_price
table in the image is not i use. Please ignore that table while answering. Thanks
menu_category_item
is a little unclear, it implies something about categorization; I'd consider "menu_item". Ifrestaurant_facilities
has a one-to-one relationship withrestaurants
, I'd leave them in a single wide table, but I'm not a fan of horizontal partitioning. You'll probably wantprice
andtax
onorder_details
; some places charge different taxes for food vs alcohol, for example.menu_category_item
contains menuId, ItemID, RestaurantID, categoryID, Price as same same item can belong to different restaurants with different prices. Yesrestaurant_facilities
has one-to-one relationship withrestaurants
. And should I move Tax, Discount, Total, Additional Charges to order_details? or Only Tax and Total?order_details
should definitely includeunit_price
,total_price
, andtax
; I'd leave them inorders
too, it's denormalization, but a very common and reasonable exception.discount
is a tough call; do you expect most discounts to be off of a specific item, or off of a whole ticket? For the greatest flexibility, I'd make discounts a type of menu item. A person's order may include 1) Steak, $20 and 2) Salad, $5 and 3) Free Salad with any meal on Tuesdays, -$5. The nice thing about this is that it easily handles cases like this where a discount depends on a collection rather than a single line item.menu_category_item