title: Prisma self-relation extra data field
body: <p>I'm trying to use prisma to model relationships between people with basic familial relation labels. The way that I'm thinking about modeling this relationship is using three tables &quot;Person&quot;, &quot;Relationships&quot; and &quot;Relation&quot;. Person for the individual's data, Relationships as the join table, and Relation describing the type of relationship (e.g. &quot;father&quot;, &quot;son&quot;, etc.). But I can't seem to get the foreign key relationships setup correctly... Here is what I have so far:</p>
  <pre><code>model Person {
    id       Int       @id @default(autoincrement())
    name     String
    slug     String    @unique
    relationships Relationship[]
  }
  
  model Relationship {
    id        Int       @id @default(autoincrement())
    relative Person? @relation(fields: [relativeId], references: [id])
    relativeId Int?
    relation Relation? @relation(fields: [relationId], references: [id])
    relationId Int?
    startDate DateTime?
    endDate   DateTime?
  }
  
  model Relation {
    id              Int    @id @default(autoincrement())
    name            String
    relationships Relationship[]
  }
  </code></pre>
  <p>Any pointers appreciated!</p>