Linking multiple records with multiple records

I have 3 tables.

User
Sites
Viewers

A user creates many construction sites under his profile.
A user creates many viewers (viewers are people with emails that will receive info from User/Site)
Sites have 1 user but many viewers
Viewers have many Users and many sites
Users have many sites and many viewers

Viewers can be created by different users (as the viewer will have the same email address)

I need to find a way of having a User link created Viewers to created sites, and have a list of all viewers on particular sites.

I have tried relations.

Do I need a table that only associates Viewers to sites so i can pull out separate rows?

I do not know what your data looks like. Are you creating unique IDs for each site and viewer so that you can add these id’ to each relation?

Yes, each site will have a RowID and each Viewer will have a RowID, I will have to figure out a way to associate a viewer with multiple users at some stage

Not row ID… relation ID… you need to copy row ID to relation ID

@Uzo thanks for the help.

Here are my tables:

Users: Can create many sites and many viewers

Sites: many Users Create many Sites

Viewers: Many users create many viewers and associate viewers to their many Sites. Other users can create the same viewer (based on the email record) for different sites they are working on.

I need to be able to display on the interface the following on each User profile:

Created Sites
Created Viewers

When I go into a site (from the Profile page), I need to be able to see the Viewers associated with that site

When I go into a viewer (from the profile page), I need to able to see the Sites associated with that viewer. I also need to use a “choose” function to choose a site to associate with that viewer (and by the same token, to disassociate a site from a viewer).

Before I start, there seems to be a red flag on your Sites and Viewers tables. The emails column should be normal columns, not user-specific columns.

Should be able to have a relation from the Users table to the Sites table with the email column (assuming “Users Email” is the creator) and display that with a collection/inline list.

Should be able to have a relation from the Users table to the Viewers table with the email column (assuming “Email” is the creator) and display that with a collection/inline list.

Create a relation from the Sites table to the Viewers table using the rowID of the Sites connecting to the “Site Row ID” column in the Viewers table.

Create a relation from the Viewers table to the Sites table using the “Site Row ID” column of Viewers to connect to the “RowID” column of Sites.

Not sure what you mean by this, you mean when you have a new Viewers row you need to have a choice component to choose what site that viewer can view?

1 Like