Table Relationships

Options

Just something i am considering for my setup.

When sharing relationships between 2 tables do you guys store both values into both tables? Example:

You have a table of items, lets say hats. You've decided to integrate a like button for each item on the front end in which the user would "like" that specific hat.

Do you store both values inside both tables (users table with an array of hats "liked hats") & (hats table with an array of likes "users" ) or do you ONLY store one of those arrays inside 1 of those tables?

Comments

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options

    Hi @JayyyTeee I'd actually recommend another set up: a "Likes" table that contains a table reference to the user_id and the hat_id. This tends to make things more manageable if a user can end up liking a large number of things. We use this set up in our Photo-Sharing template, which similar to an Instagram application. You could take a look at that template as an example.

    Here's also a video around Basic Likes: