I
I
Igor Katkov2015-09-29 12:05:24
MySQL
Igor Katkov, 2015-09-29 12:05:24

Is this table characterizing the many-to-many relationships correct?

Good day!
I am new to database design and in general, so do not blame me.
While working on the project, I noticed a table that was created for the Many-To-Many relationship. It looks like this:
items_categories:
id | item_type | item_id | category_id | delta
Actually, it stores links in itself: (products, product properties, groups (?) to categories). That is, the type of the item is stored in item_type. What is a delta, I still do not understand ...
So, is it normal to use such a table? If not, does such a table affect query speed?
Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
shaqster, 2015-09-29
@shaqster

To link two tables on a many-to-many basis, a third table is indeed used. But it should contain only two fields - id1 and id2, since it is intended only to display the relationship between two entities, and nothing more. The rows in such a table do not need their own id, since you will not have two identical records.

S
soulness, 2015-09-30
@soulness

This table is a separate data entity containing links to other tables. look at point 8 here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question