Mapping of list with sub list of tables for class

0

Hello; I have always had a question in this mapping, but in the current project I need to resolve it.

It's the following, I have a Message table and a user table. I need to relate the users to the messages seen, to detect if it is a new message or not.

Basically this would be the modeling of the Bank

| MensagemID | Mensagem   | <- Tabela Mensagem

| UsuarioID  | Nome       | <- Tabela Usuários

| UsuarioID  | MensagemID | <- Tabela Usuarios X Mensagens

So far so good, it works. However, when I map I need to fill a list containing the instances with the data of the messages, and in one of these properties of the class, a list with the ids of the users that they have viewed (visualizations).

Only by running a query to get the messages, suppose I would have a result of 1000 messages.

Assuming also that each message has 100 different views of users, there would be 100000 results, as well as 1000 different queries (one to get the viewers of each message).

Is this certainly not right?

Could anyone give me a light to optimize this process? How could I implement?

Thanks in advance for any help.

    
asked by anonymous 19.08.2018 / 17:04

0 answers