Re: The best way to insert tags in a DB

From: Jerry Stuckle <jstucklex_at_attglobal.net>
Date: Sat, 19 Oct 2019 22:04:12 -0400
Message-ID: <qogfac$4am$1_at_jstuckle.eternal-september.org>


On 10/19/2019 4:40 PM, ^Bart wrote:
> Hi everybody! :)
>
> I need to insert in a db tags about food recipes and I thought to start
> in this way:
>
> recipes
> -------------------------
> id_recipe     name
> 1        hamburger
>
> recipetags
> -------------------------
> id_recipetag    name
> 1        meat
> 2        bread
> 3        latuce
>
> recipedetails
> ------------------------------------------------
> id_recipedetail    FK_id_recipe    FK_id_recipetag
> 1        1        1
> 2        1        2
> 3        1        3
>
> Is there a better way to insert tags? I thought I could insert them like
> this:
>
> recipetags
> ------------------------------------
> id_recipetag    name
> 1        meat
> 2        bread
> 3        lettuce
>
> recipes
> -----------------------------------------------------
> id_recipe     name        tags
> 1        hamburger    meat, bread, lettuce
>
> What do you think about these two ideas? Do you have another one?
>
> Thanks! :)
> ^Bart

[Quoted] Your second way violates normalization rules and can have all kinds of problems.

[Quoted] You really need to read up and *understand* database normalization. The rules are there for a reason - and they work.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex_at_attglobal.net
==================
Received on Sun Oct 20 2019 - 04:04:12 CEST

Original text of this message