S
S
survivor20052021-01-30 00:35:21
MySQL
survivor2005, 2021-01-30 00:35:21

How to properly design an order table?

I'm trying to make an online store.
What fields should the table of orders have.
At the moment I have the following fields:
id, order_number, product_id, product_quantity, product_price, order_date+time, order_status.
And here is the most interesting thing. I have a table of users and a table with addresses in the database.
So, in the table of orders, should I make my own fields about the user and his address, who ordered the goods, or refer to the existing table? I'm more inclined to make my own fields, since an unregistered user can buy products, so why should I enter it in the user table? And to hammer the table with the address too as that would not be desirable. On the other hand, they say it's not good when there are tables of users and addresses, but you need to repeat them again in the table of orders. How is this done in practice?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Lada, 2021-01-30
@Andrey_Andrey

Good afternoon!
There is a good sql simulator on stepik, it discusses in detail the creation of an IM, indicating the logical model of the database.
Perhaps it will help https://stepik.org/lesson/308891/step/1?unit=291017
The first 4 steps are enough to understand

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question