sql - Multiple many to many relationships between same tables or one n:m relationship with identifying attribute? -
Currently I have several n: m links between the two tables:
- & gt; Favorites (user_id, post_id) & lt; - Post users - & gt; Follow (user_id, post_id) & lt; - Mail Is there a feature to join in 2 or just one, which is a symbol of the type of joining, something like this:
user - & gt; User file (user_id, post_id, type (VALUES = "favorite, follow") & lt; - mail In my application I do not have this at all, but I think that You think that there is a "right" answer. I think
strong> dependent . If you use a single table with the "Relationship Type" column and want to remove only one kind of relationship - then just enter it Nandita - then you will need to apply every query to that table, for such type of people whom you not want to filter, there is a rule that can be for slow queries. -Keys do not properly index the "Relationship Type" column. Also, it does so that future developers should always know what type of filter they want to filter or they want to filter. It is possible to get back the relationship data that is expected to come back. Two different tables are easy to understand. For example, for me, what is known to EXPEC is a comparison of the "Users_Posts" table In the "Favorites" table, you can convey the difference in different tables faster. On the other hand, if you often need to select both type of relationship in a set, then it is easy to put them in a table because you can add data to single tables on a table with two tables There is no need to worry about. What if there are 10,000 different possible connection types? Do you want 10,000 different tables, or would you like the same table? Most people prefer the same table in that case. So I think it depends on many factors, such as expected usage, size etc. "Right" answer is more than an art than science.
Comments
Post a Comment