The accepted answer should be declared false, because the "?" is mandatoy see this section.

Answer from naivary on Stack Overflow
🌐
GitHub
github.com › prisma › prisma › issues › 18058
Optional relationship creates foreign key constraint · Issue #18058 · prisma/prisma
February 23, 2023 - Seems to be similar to concerns posted here: prisma/prisma-engines#2221 posted by @rt2zz · 1. create db and client 2. Do not create a user 3. attempt to create (or upsert) an author · Inserting an Author before a User record is created should not be rejected by the database. model User { id String @id @default(cuid()) email String? @unique author Author? } model Author { id String @id @default(cuid()) email String @unique name String user User? @relation(fields: [email], references: [email]) }
Author   prisma
Discussions

Prisma 1:1 relation with no optional field on MySQL? - Stack Overflow
You can choose if the side of the relation with a relation scalar should be optional or mandatory. In the following example, profile and profileId are required. More on stackoverflow.com
🌐 stackoverflow.com
Optional relation using a required field makes model unusable
Bug description Hi there 👋, thanks for your work ❤️. Prisma is the best ORM I've worked with so far :) Unfortunately, I've now encountered a situation where an optional relation creates a t... More on github.com
🌐 github.com
11
October 14, 2021
database - Prisma 1-1 optional relation - Stack Overflow
I'm trying to create optional (1-1) relation between Cart and User models. My prisma schema generator client { provider = "prisma-client-js" } datasource db { provider = " More on stackoverflow.com
🌐 stackoverflow.com
Prisma 1-Way Relationship or Optional List?
A drink can have many tables and a table can have many drinks. I don't have Prisma experience, but this is called a many to many relationship and I'm sure it handles it for you. So although you're thinking about it as one way, you almost got to the solution on your own. The many to many relationship is stored in a separate table called a join table. It contains the primary keys for both the drink and table tables so you can join both tables through it based on the query you need More on reddit.com
🌐 r/node
2
2
April 16, 2023
🌐
Prisma
prisma.io › home › relations › relations › relations › relations
Relations | Prisma Documentation
A relation is a connection between two models in the Prisma schema. This page explains how you can define one-to-one, one-to-many and many-to-many relations in Prisma.
🌐
GitHub
github.com › prisma › prisma › issues › 9784
Optional relation using a required field makes model unusable · Issue #9784 · prisma/prisma
October 14, 2021 - The error is caused by the optional dayEntry relation which uses the required id field. Interestingly, there's no error anymore when I remove the employee relation.
Author   prisma
🌐
Medium
medium.com › yavar › prisma-relations-2ea20c42f616
Prisma relations
August 19, 2022 - On the other side of the relation, the annotated relation field and relation scalar can either both be optional, or both be mandatory. In the following example, you can create a Post without assigning a User: ... It refers to relations where zero or more records on one side of the relation can be connected to zero or more records on the other side...
🌐
Prisma
prisma.io › home › relation mode › relation mode › relation mode › relation mode › relation mode
Manage relations between records with relation modes in Prisma | Prisma Documentation
There are performance implications to emulation of referential integrity and referential actions in Prisma Client. In cases where the underlying database supports foreign keys, it is usually the preferred choice. To set the relation mode, add the relationMode field in the datasource block: ... foreignKeys: this handles relations in the database with foreign keys. This is the default option for all relational database connectors and is active if no relationMode is explicitly set in the datasource block.
Find elsewhere
🌐
Stack Overflow
stackoverflow.com › questions › 77512534 › prisma-1-1-optional-relation
database - Prisma 1-1 optional relation - Stack Overflow
You should not add unique constraint to a nullable column, this may cause only one NULL value in the entire table and prisma already warn you about this.
🌐
Reddit
reddit.com › r/node › prisma 1-way relationship or optional list?
r/node on Reddit: Prisma 1-Way Relationship or Optional List?
April 16, 2023 -

I'm building a bar database, each bar has a table of drinks on the menu, and each drink has a list of user reviews.

I've uploaded a dataset to the drinks table, that a user can search using autocomplete to select which drink they had at the bar.

Problem: Since I'm using the drinks table independently for the autocomplete, they don't each have a place associated with them, and a new instance will need to be added so that each drink is independent to the bar it is served at. Do I need to create an entirely new table for the drinks associated with a bar, and the ones used for autocomplete?

What is a good way of achieving this?

🌐
Prisma
prisma.io › home › models › models › models › models
Models | Prisma Documentation
@map and @@map allow you to tune the shape of your Prisma Client API by decoupling model and field names from table and column names in the underlying database. The properties of a model are called fields, which consist of: A field name · A field type · Optional type modifiers · Optional attributes, including native database type attributes · A field's type determines its structure, and fits into one of two categories: Scalar types (includes enums) that map to columns (relational databases) or document fields (MongoDB) - for example, String or Int ·
🌐
Stack Overflow
stackoverflow.com › questions › 71415674 › how-to-create-an-optional-many1-relationships-from-one-table-to-itself-in-a-pos
postgresql - How to create an optional many:1 relationships from one table to itself in a Postgres database using Prisma? - Stack Overflow
I have the following model in my Prisma schema, the part of the model in question is the optional oldVersionId: model Block { id String @id @default(uuid()) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt actingUser User @relation(fields: [userId], references: [id]) userId String accessType AccessType @default(PRIVATE) blockType BlockType @default(IMPERATIVE) blockState BlockState @default(NOT_STARTED) humanText String parents HierarchyRelation[] @relation("parents") children HierarchyRelation[] @relation("children") workspace String workspaceOutgoing ReferenceRelation[] @relation("outgoing") workspaceIncoming ReferenceRelation[] @relation("incoming") oldVersion Block?
🌐
Lightrun
lightrun.com › answers › prisma-prisma-optional-relation-using-a-required-field-makes-model-unusable
Optional relation using a required field makes model unusable
I’m not trying to modify any ids, I just want to create a new entry. bar: { connect: { bar_id: 5 }} is also not the problematic part, Prisma complains about foo_id. ... If you are already using a proto, you can't add a required field because old application's won't be providing that field and applications...Read more > Visio Database Model - child has parent optional check box · I need child has parent Checkbox Optional to be unchecked. ... Relationship Type = Non-identifying - Migrate the key using FK not PK....Read more >
🌐
GitHub
github.com › prisma › prisma › issues › 8447
An optional one-to-many relationship still creates a foreign key constraint · Issue #8447 · prisma/prisma
July 26, 2021 - The contacts table in this schema is meant to store a list of contacts for each user that can potentially point to other user profiles if they exist in the database. contact_holder points to the primary key of the profiles table and contact will optionally point to phone_number in the profiles table if a user with that number exists. According to the docs, this should allow me to add a number that doesn't exist yet: contact String contact_ref profiles? @relation(fields: [contact], references: [phone_number]) However when I run prisma db push a foreign key called contacts_contact_fkey is being generated that prevents me from doing this.
Author   prisma
🌐
Answer Overflow
answeroverflow.com › m › 1228822030447546459
How to Implement an Optional One-to-One Relationship in ...
April 13, 2024 - Context I'm using Prisma 5.10.2 with MongoDB and attempting to set up an optional one-to-one relationship between two models based on the official Prisma documentation. However, I've encountered a problem with MongoDB's support for nullable unique fields.
🌐
Prisma
prisma.io › home › referential actions › referential actions › referential actions › referential actions › referential actions
Special rules for referential actions in SQL Server and MongoDB | Prisma Documentation
For this reason, when you set postgres as the database provider in the (default) foreignKeys relation mode, Prisma ORM warns users to mark as optional any fields that are included in a @relation attribute with a SetNull referential action.
🌐
Stack Overflow
stackoverflow.com › questions › 74088042 › prisma-orm-optional-relations-for-user-models
sql - Prisma ORM optional relations for user models - Stack Overflow
October 16, 2022 - // schema.prisma enum Role { SUPERADMIN ADMIN STUDENT } model User { id Int @id @default(autoincrement()) citizenId String @unique hash String role Role @default(STUDENT) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt student Student? @relation(fields: [citizenId], references: [citizenId], map: "user_student_fk") admin Admin?
🌐
GitHub
github.com › prisma › prisma › issues › 17614
Conditional Nested Read on Optional Relations · Issue #17614 · prisma/prisma
January 30, 2023 - The user can have optionally the Profile and once completed must be approved by an administrator. What I would like to do is to user.findMany including the Profile relation ONLY when isApproved is true BUT still getting the User data with a ...
Author   prisma