diff --git a/content/200-concepts/100-components/01-prisma-schema/06-relations/300-many-to-many-relations.mdx b/content/200-concepts/100-components/01-prisma-schema/06-relations/300-many-to-many-relations.mdx index 4433a1735f..c46d607cd1 100644 --- a/content/200-concepts/100-components/01-prisma-schema/06-relations/300-many-to-many-relations.mdx +++ b/content/200-concepts/100-components/01-prisma-schema/06-relations/300-many-to-many-relations.mdx @@ -350,19 +350,23 @@ Implicit m-n relations: If you obtain your data model from [introspection](/concepts/components/introspection), you can still use implicit m-n-relations by following Prisma's [conventions for relation tables](#conventions-for-relation-tables-in-implicit-m-n-relations). The following example assumes you want to create a relation table to get an implicit m-n-relation for two models called `Post` and `Category`. -##### Table names +##### Relation table If you want a relation table to be picked up by introspection as an implicit m-n-relation, the name must follow this exact structure: - It must start with an underscore `_` -- Then the name of the first table in alphabetical order (in this case `Category`) +- Then the name of the first model in alphabetical order (in this case `Category`) - Then `To` -- Then the name of the second table in alphabetical order (in this case `Post`) +- Then the name of the second model in alphabetical order (in this case `Post`) In the example, the correct table name is `_CategoryToPost`. When creating an implicit m-n-relation yourself in the Prisma schema file, you can [configure the relation](#configuring-the-name-of-the-relation-table-in-implicit-many-to-many-relations) to have a different name. This will change the name given to the relation table in the database. For example, for a relation named `"MyRelation"` the corresponding table will be called `_MyRelation`. +###### Multi-schema + +If your implicit many-to-many relationship spans multiple database schemas (using the [`multiSchema` preview feature](/guides/database/multi-schema)), the relation table (with the name defined directly above, in the example `_CategoryToPost`) must be present in the same database schema as the first model in alphabetical order (in this case `Category`). + ##### Columns A relation table for an implicit m-n-relation must have exactly two columns: