title: prisma: How to convert a database table with more that one FK to prisma schema?
body: <p>I'm new to Prisma and relational databases in general. I'm a little bit confused about how to create many-to-many relations between tables, especially relation fields.</p>
  <p>For example, imagine I want to convert this database model to Prisma schema.
  <a href="https://i.stack.imgur.com/RSLAP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RSLAP.png" alt="enter image description here" /></a></p>
  <p>This is the answare that I came up with:</p>
  <pre><code>model User {
    id             String         @id
    comments       Comment[]
    posts          Post[]
  }
  
  model Post {
    id             Int            @default(autoincrement()) @id
    author         User           @relation(fields: [authorId], references: [id])
    authorId       String
    comments       Comment[]
  }
  
  model Comment {
    id             Int            @default(autoincrement()) @id
    post           Post           @relation(fields: [postId], references: [id])
    postId         Int       
    author         User           @relation(fields: [authorId], references: [id])
    authorId       String
    text           String
  }
  </code></pre>
  <p>The <code>Comment</code> table has two foreign keys to both <code>User</code> and <code>Post</code> tables. Do I need to have the <code>comments</code> field in both models? And in general, Am I doing it right?</p>