I have a database with a books table and a persons table with around ~100k entries in each. A third table connects the two so they have a many-to-many relationship. Besides columns for book and person id, the connection table also has a column indicating the relation type between the book and the person, fx writer, co-writer or publisher or something else.
I need to make queries that return a list of all book entries with the persons related to them and the specific relation type. When joining the two tables, SQL returns multiple rows for books that have more than one person related to it, so I sort this out in php afterwards. The number of persons related to books varies from book to book with no predictable pattern.
I need to make a pagination system.
What would be the smartest way to do pagination in this situation?
You can select all related persons per book in one row with
group_concatand then paginate the result set withlimit offset, num_rows