N
N
nilayovalu2017-06-20 20:30:01
Software design
nilayovalu, 2017-06-20 20:30:01

How to design this "colossus"?

I'm building a food delivery website.
Customers place an order. The order can be single (single) and joint (joint).
A single order - nothing special, a row in the database with columns ID , customer , cost , status , etc.
Joint order - an order that several customers make, they are combined into so-called "groups" - there they have a chat, there they they see who they order food with, see the order status, price, etc. Joint orders are also put into the orders table marked "joint"
The site works only through the rest API. The order scheme is as follows:

  1. POST request to /orders to create an order. The user sends the goods that he wants to order and the type of order - single or joint.
  2. The server pops the order into the orders table and returns 201.
  3. The user starts making periodic requests to GET /orders/current to update information about the order

Everything is clear with a single - a line in the database with an order and that's it. And with joint everything is more difficult - there are several users. Let's say 3 users are combined into one group. It turns out that there are three identical rows in the orders table (only the creator IDs are different). Suddenly the status of the order has changed - and now I need to update the status of these 3 lines? Somehow it doesn't look good.
I have a solution to this problem - to create a completely different Group entity that does not intersect with Order in any way. Or is there a better solution?
I hope you understand my question) Write if something is not clear in the text of the question)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
longclaps, 2017-06-20
@longclaps

All orders - group, for single - a group of one user.

R
RidgeA, 2017-06-20
@RidgeA

A single order is a special case of a group order.
I would make an order entity, and an order item entity, and link them 1 to many.
Single order - 1 order entity - 1 order item entity
Group order - 1 order entity - N order item entities.
The status, of course, belongs to the order, when the status changes, only the essence of the order changes, and the order items are not touched.
Something like this, taking into account that the other points of the TK are not known to me.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question