Answer the question
In order to leave comments, you need to log in
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
)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question