How to declare 1-to-0:1 relation between tables?
As the title says. The existing helper
one
seems to be for 1-to-1 relations.
Thanks!3 Replies
you mean cases where an item might be related to either 0 or 1 item?
could you provide your schema for the tables that participate in the relation?
Yes, that's right. Here's an example:
1.
users
table with id: varchar(255)
as primary key.
2. secretSettings
table with userId: varchar(255)
primary key, referencing the users
table; as well as a bunch of data columns storing secret settings.
A user may have zero or one entry in secretSettings
.
I realize that this can be implemented by just creating a nullable column within the users
table, but I want to keep them separate due to security concerns
Hey @Dan Kochetov, circling back on the above. Would you have any ideas? ThanksIf you just create a
one
reference from users to secretSettings without specifying the reference columns (becase you don't have any on the users side), it should become nullable automatically. Did you try that?