How to allow optional user_id foreign key for data?

Hi,

I'd like to have data that can be created by unauthenticated users, and also authenticated users.

If it's an unauth user, the user_id field would be empty. If they are authenticated, it would be forced to be the uid().

If the user_id is empty, the data can be selected by anyone - but no other actions.

If the user_id exists, then anyone can select it, but only that user can update and delete.

Any easy way to do this while sharing the same table?

Thanks.
Was this page helpful?