Hey everyone! I have this issue with many to many ...
# orm-help
a
Hey everyone! I have this issue with many to many relationship. My question is why when implicit, it creates only 1 relation if the tables are named survey and question the created table is _SurveyToQuestion but I don't see the _QuestionToSurvey table. Is there something I'm confusing? In that case sorry for my ignorance, but in my specific scenario a survey can have many questions and a question can be in many surveys. Thanks for your help
1
n
Hi Alejandro 👋 Welcome to our Slack community! 🙌 Only one table is required to satisfy both the scenarios of a survey having many questions and a question in many surveys. Even when using explicit many to many relationship only one table would be required which is usually called as Join/relation table. Creating relation tables is a common data modeling practice in SQL to represent relationships between different entities. In essence it means that “one m-n relation is modeled as two 1-n relations in the database”.
a
But that's not the case, I mean the table with surveys is not included in the Joined table which is named _questionToSurveys. I already tested that. Creating and explicit relation looks like the best approach but I can't name any model with underscore _ . Prisma don't allow it. So how can I make use of introspection to recreate both tables if is desired?... For now that approach you mention haven't worked so far. Btw thank you for your response, your help is much appreciated. I think prisma is fantastic!