T
T
Timur Kalimullin2014-03-03 21:08:45
MySQL
Timur Kalimullin, 2014-03-03 21:08:45

How to properly implement order table structure?

Good afternoon, when creating order archives, a question arose about the correct approach to implementing the database structure.
As usual: the visitor places N items in the cart. Each product has its own different parameters (weight, color, price, quantity, etc.)
So far I see the following table view:

CREATE TABLE `Orders` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `order_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
  `order_user` INT NOT NULL DEFAULT '0',
  `order_method` VARCHAR(10) NOT NULL DEFAULT 'mail',
  `order_comment` VARCHAR(255) NOT NULL DEFAULT 'Ожидает проверки',
  `order_status` INT NOT NULL DEFAULT '0'
)

CREATE TABLE `Orders-Product` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `order_id` INT NOT NULL DEFAULT '0',
  `product_id` INT NOT NULL DEFAULT '0',
  `product_title` VARCHAR(255) NOT NULL DEFAULT '',
  `product_count` INT NOT NULL DEFAULT '0',
  `product_price` VARCHAR(10) NOT NULL DEFAULT '0'
)

CREATE TABLE `Orders-Meta` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `order_id` INT NOT NULL DEFAULT '0',
  `meta_id` INT NOT NULL DEFAULT '0',
  `meta_key` VARCHAR(255) NOT NULL DEFAULT '',
  `meta_value` TEXT NOT NULL
)

The table with other Orders-Meta parameters will contain data such as: Information about the customer provided at the time of the order, product parameters, discounts, promotions, and other parameters.
How correct is this approach? Perhaps there is a better solution?
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Appp Zooo, 2014-06-18
@ikeagold

Here is a great example from Opencart , googled on request: opencart db scheme
If you continue like this, then here is Magento , Prestashop
fetch.php?cache=&media=database_schema_o

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question