Forum Academy Marketplace Showcase Pricing Features

Should I still put user as datatype even though created by is the user?


I wish to understand how to structure my database for best performance.
So I have this meal planning app which I’m working on. I have a user data type as usual, and a ‘Plan’ datatype. A user can add a meal to a plan, which means that there is a list of entries(meals) in the plan data type which belong to a particular user.

Now I’m thinking that there’s no need for a user column in the plan datatype if ‘created by’, which is an automatically generated column exists. If i need to link the user’s meal to the user, I can just use the ‘created by’ column to do that. Am I wrong in thinking like that? will that be better for performance or do I need to exclusively add a user column to my plan datatype? Note that I will have to make that link between users and their meal plans dozens of times in my app.

Great question! You’re correct, if a user is creating a “meal”, then the “created by” field will automatically link that meal to the user. It may also be a good idea to have a “meal” data type and create a field on your User that is a “List of Meals”. This way, every time a user creates a meal it is possible to add it to their individual list.

If you have any further questions, feel free to email us at [email protected] and we’d be happy to help!

This topic was automatically closed after 70 days. New replies are no longer allowed.