Answer the question
In order to leave comments, you need to log in
Many-to-many relationship with many tables?
Hello.
The site has news, videos, galleries, people. All entities have tags. Now there are 4, but there may be more.
I'd like to create one table where I link them to a tag. The tag table is common to all.
Like this:
| id | material_id | tag_id | material_type |
|.1.|.........1.........|.....1....|........news..... ..|
|.2.|.........1.........|.....1....|........video..... ..|
|.3.|.........1.........|.....1....|.......gallery...... |
I tried to do this, but I ran into a key constraint - I don't know how to set a foreign key for an intermediate table.
How to register a foreign key on n tables?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question