Re: How to store user's tastes

From: ^Bart <gabriele1NOSPAM_at_hotmail.com>
Date: Mon, 22 Apr 2019 00:21:37 +0200
Message-ID: <q9iqdf$1qu4$1_at_gioia.aioe.org>


> More difficult to keep the data consistent over tables.

[Quoted] I created three tables:

  • ingredientscategories [Quoted] values Meat, Fish, Cereals, Cereals gluten free, Vegetables, Fish, etc.
  • ingredients values every ingredients
  • foodlists values Celiac, Vegan, etc.

Foodlists table is a deny table, a Vegan, Vegetarian, etc. will be set like "Style" and Celiac will be set like "Intollerance" something like not dangerous and dangerous for example for the restaurant's owner!

CREATE TABLE ingredientcategories
(
[Quoted] id_ingredientcategory TINYINT(7) NOT NULL AUTO_INCREMENT, name VARCHAR(30) NOT NULL,
PRIMARY KEY (id_ingredientcategory)
)
ENGINE=INNODB; CREATE TABLE ingredients
(
id_ingredient SMALLINT(7) NOT NULL AUTO_INCREMENT, name VARCHAR(30) NOT NULL,
[Quoted] FK_id_ingredientcategory TINYINT(15) NOT NULL, PRIMARY KEY (id_ingredient),
INDEX (FK_id_ingredientcategory),
FOREIGN KEY (FK_id_ingredientcategory) REFERENCES ingredientcategories (id_ingredientcategory)
)
ENGINE=INNODB; CREATE TABLE foodlists
(
id_foodlist BIGINT(7) NOT NULL AUTO_INCREMENT, name VARCHAR(50) NOT NULL UNIQUE,
[Quoted] FK_id_ingredientcategory SMALLINT(7) NOT NULL, kind ENUM ("Style","Intollerance"),
PRIMARY KEY (id_foodlist),
INDEX (FK_id_ingredientcategory),
FOREIGN KEY (FK_id_ingredientcategory) REFERENCES ingredientcategories (id_ingredientcategory)
)
ENGINE=INNODB;

>> You could also create an id for it, but then you would be storing the 
>> id which refers to 'vegan' a lot of times. 

>
> Takes less disk space to store the id than the text.

[Quoted] Yes, this is a good idea but I think I solved the problem by using three tables.

^Bart Received on Mon Apr 22 2019 - 00:21:37 CEST

Original text of this message