SQL: Implementing many-to-many relationships in

Asked 2 years ago, Updated 2 years ago, 31 views

Hello.

Node.js is developing an om, but I am asking you this question because there are some confusing parts. Do I need only two tables to make a many-to-many relationship? Or do I need three tables that act as intermediate legs?

Thank you.

sql

2022-09-22 18:11

1 Answers

I'm sure you've just filled out the tags as you filled out the questions.

You tagged me sql. From the point of view of the problem, you can attach multiple tags, and from the point of view of the tag, it can belong to various problems, so it's a multi-to-many relationship like you said.

To display this relationship, there will be a separate table with question_id and tag_id in columns, respectively.

If your DB (for example, Postgresql) supports Array, there is also a way to put a column called tag_ids in the question table and store tag_ids there. As I organized and operated the table like this, there was a big problem with the cost when updating.


2022-09-22 18:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.