Answer the question
In order to leave comments, you need to log in
Database structure question
Actually, I would like to see some advice, maybe somehow optimize the following.
I have tables
Dishes:
CREATE TABLE `Courses` (
`id` INT NOT NULL ,
`category` INT NOT NULL ,
`title` VARCHAR(255) NOT NULL ,
`description` TEXT NULL ,
`price` DECIMAL(10,2) NULL ,
`currency` INT NOT NULL )
CREATE TABLE `Ingredients` (
`id` INT NOT NULL AUTO_INCREMENT ,
`title` VARCHAR(45) NOT NULL ,
`count` INT NULL ,
`unit` VARCHAR(45) NULL ,
`price` DECIMAL(10,2) NOT NULL ,
`currency` INT NOT NULL )
CREATE TABLE `Orders` (
`id` INT NOT NULL AUTO_INCREMENT ,
`restaurant` INT NOT NULL ,
`client` INT NOT NULL ,
`table` INT NOT NULL ,
`status` TINYINT NOT NULL DEFAULT 0)
CREATE TABLE `OrderCourses` (
`id` INT NOT NULL AUTO_INCREMENT ,
`order` INT NOT NULL ,
`course` INT NOT NULL ,
`count` INT NOT NULL)
CREATE TABLE `OrderCourses_copy1` (
`id` INT NOT NULL AUTO_INCREMENT ,
`order` INT NOT NULL ,
`course` INT NOT NULL ,
`ingredient` INT NOT NULL ,
`count` INT NOT NULL)
Answer the question
In order to leave comments, you need to log in
In OrderIngredients, instead of two fields order and course, make one order_course where you will store the id from the OrderCourses table
I agree with mekegi , I would also take out the fields separately price
, currency
from dishes and ingredients (3 NF), it may come in handy in the future.
Personally, I wouldn't mess around with the ingredients.
Even in the network of pizzerias throughout Ukraine (chelentano) they do not do this. As far as I can tell.
Custom pizzas (where the client himself chooses the ingredients) on the monitor are simply considered throwing "dishes" in your case.
It's easier to create a Course Group: Ingredients. And there are all sorts of double cheeses and sauces to write down.
That is, the order in your database, simplified according to my advice, would look like this:
Order 5
Table 3
Dishes: 2 water, 1 Pizza, 1 extra cheese, 1 garlic sauce, 1 dumplings
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question