I heard that the many-to-many relationship should be avoided and reduced to one-to-many. Is it true? And why should you do that?
1 answer
Probably it means that when, for example, you have a table of articles and a table of tags, then:
It would be wrong to add additional columns to the table of articles for a number of tags of the form
ID тега 1
,ID тега 2
,ID тега 3
It will be correct to create another table of the type of
ID связи
ID статьи
-ID статьи
ID тега
-ID тега
Why it is so easy to see trying to search for tags in either case.
|
sites
andfilter_rules
(sites that need to be parsed, and filter rules for paths that can be parsed, something like robots.txt). Many-to-many option: each site may have several filtering rules, and vice versa. A third table,sites_filter_rules
. One-to-many option: site_id column appears in the table with rules. And if two sites use the same rule, then this rule is duplicated in the table, only thesite_id
column is different. - melihovv