from the <https://www.prisma.io/docs/concepts/comp...
# orm-help
n
from the https://www.prisma.io/docs/concepts/components/prisma-schema/relations/one-to-one-relations#required-and-optional-1-1-relation-fields,
Copy code
model User {
  id      Int      @id @default(autoincrement())
  profile Profile?
}

model Profile {
  id     Int  @id @default(autoincrement())
  user   User @relation(fields: [userId], references: [id])
  userId Int  @unique // relation scalar field (used in the `@relation` attribute above)
}
1
v
👋 Hello @N, it looks like these messages are part of this thread (I've removed them from the main channel)
Copy code
The interpretation is that a User can optionally have a profile but a profile CANNOT be created without a user.
Is there a way to express the relationship: a User must have a Profile and a Profile CANNOT exist without a user?
A follow up question is why does Prisma have to enforce only one side of a relation can be mandatory.
And it also seems like you resolved your issue here: https://prisma.slack.com/archives/CA491RJH0/p1664635287817279
One minor ask if you don’t mind: it would be great if you could use Slack’s thread feature when posting a multi-part question or providing updates. This helps keep the main conversation channel a bit more clear 🙏
n
Ok
💯 1
💚 1