Lets say I have two tables:
books
authors
The relation between books and authors is 1:n (each book can be written by more than one author). I'd like to display it the following way:
book_name
author_name1, author_name2 and author_name3
book_name
author_name1, author_name2 and author_name3
book_name
author_name1, author_name2 and author_name3
Question is, what is the best way to present such view? I see the following optoins:
1) Make one big query which gets data from both tables. Run in one loop over the rows and collect all the needed info.
2) Make two queries, one for books and for the authors (select * from authors where book_id IN (...)). Then run over the list of the books in one loop and in it run in another loop over the result of the authors.
For now I am tending for option 2 as option one causes duplicate data in rows, however, both ways are possible and both are quite annoying to write.
I wonder if there is another solution to this. I tried looking in DB_DatabaseObject but didn't find it useful in this specific case as well.
Anyone has ideas?