Re: How to store user's tastes

From: Luuk <luuk_at_invalid.lan>
Date: Sun, 21 Apr 2019 20:07:57 +0200
Message-ID: <5cbcb17c$0$22337$e4fe514c_at_news.xs4all.nl>


On 21-4-2019 19:07, ^Bart wrote:
> Hello everybody!
>
> I need to create a DB where I should store user's tastes or user's
> foodstyle (vegan, vegetarian, etc.)
>
> CREATE TABLE foodstyles
> (
> id_foodstyle BIGINT(7) NOT NULL AUTO_INCREMENT,
> name VARCHAR(50) NOT NULL UNIQUE,
> FK_id_ingredient SMALLINT(7) NOT NULL,
> PRIMARY KEY (id_foodstyle),
> INDEX (FK_id_ingredient),
> FOREIGN KEY (FK_id_ingredient) REFERENCES ingredients (id_ingredient)
> )
> ENGINE=INNODB;
>
> In this case I should repeat the name vegan a lot of times:
>
> name   | FK_id_ingredient
> vegan  |       4
> vegan  |       2
> vegan  |       8
> vegan  |       9
> vegan  |       3
>
> How could I find the best way to store informations in a group named
> vegan with a lot of things?
>

[Quoted] What is the problem with storing 'vegan' a lot of times?

[Quoted] You could also create an id for it, but then you would be storing the id which refers to 'vegan' a lot of times. (and have to find out which id it is...)

> ^Bart
>
>

-- 
Luuk
Received on Sun Apr 21 2019 - 20:07:57 CEST

Original text of this message