Jump to content

data structure for n:n relation


herr rilke
 Share

Recommended Posts

Hello all,

I am thinking about the following requirement:

there are documents (pages) and users.

the user should now be able to mark a document as "read" by pressing a button.
when he then calls up the document again, he finds a "read" marking - so he knows that he has done everything here.

do i now create a new subpage via API, which only has the fields "pageID" and "userID" for that?

and would that be an extra query on each page load to see if the combination of userID and pageID already exists to display a marker?

 

Link to comment
Share on other sites

1 hour ago, herr rilke said:

there are documents (pages) and users.

How many documents? How many users?

If you only have a limited number then a simple page reference field would be all you need. Just add a field "readby" to your documents page and add users to that field via API.

You just need to make sure that you don't have too many pages stored in the page reference field. So if you have many documents but just a few users add the page field to documents. If you have many users but just a few documents add the page field to the user template and add read documents to the field.

If you have many documents and many users go with the custom table solution that I showed here: 

 

  • Like 3
Link to comment
Share on other sites

On 9/9/2023 at 9:31 AM, bernhard said:

So if you have many documents but just a few users add the page field to documents. If you have many users but just a few documents add the page field to the user template and add read documents to the field.

Alternatively do both and use @Robin S’s ConnectPageFields module. Then you can access the link in either direction without a foreach loop. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...