Hey I have here a table with user profiles and a t...
# help
j
Hey I have here a table with user profiles and a table called "products". A product can be created by a user and the other users can retrieve this product. Now the other users should know by which user the product was created. Obviously you just put the user id in there but if the other users would want the username from creator they would have to make a rest call which is not ideal. Should I just store the username in the product row itself or whats a good solution there because the username can be always updated
n
Hello @Jan Tennert! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
s
The user id reference is normally the better option, because that way if the user was to update their username you wouldn't have to worry about updating the username in two tables. This will become a hard problem to solve when you are referencing the username in more tables rather than the id only.
n
TheRealJan (2022-06-01)
j
ok then the other users should make a rest call on all products?
s
Or you can create a postgres view that will aggregate all the data you need, this would include the username based on the user id and would keep it up to date for you.
n
Thread was archived by @Jan Tennert. Anyone can send a message to unarchive it.