I have an app where users can by virtual products.
The relationship between users and products is many to many.
So there is 3 tables:
- users;
- products
- user_product (pivot)
When a user successfully buys a product, the product is attached to the user.
But now i have a new challenge:
We sold some virtual products outside the system. So now for each purchase made outside of the system, i need to give the user access to the purchased products.
The thing is: the majority of these users dont have an account yet. The only thing i have is their email.
What could be the best solution to attach products to a user that doesnt exist yet?
Is it a good practice to add an email column on the pivot table, and make the user foreign key nullable? This way i can attach products to emails, with no need to the user being registered yet. But i read some topics saying this is not a very good practice in terms of database.
Other solution i thought was creating another table, like gifts, with columns like gifted_email, product. And when the user registers and login, a query is performed to the gifts table, and if theres any new gift to the user email, attach the product.
Any help is appreciated!