.net - How to store arrays in a database? -


I have a simple messaging service that uses file-based storage so far. Because the number of users of the system is increasing gradually, I would like to switch to database based storage.

List of message server users in the code (with their credentials) and keeps a list of messages. The main field of a message object is in the form of a sender (type user), recipient (type user []) and a content (type string).
Generally, a user requests messages that they receive the server and receive all the messages in which the recipient fields contain their username.

So, I imagine the following tables for the database:
- A user table
- A message table
(- A host for each user who addressed it by message ID Specifies the message)?

I have a problem on how to store the recipient field (which includes an array) in such a way that a database query can be searched for the user who receives the addressed messages Requests for I can not get a better solution than to create a table dynamically for every new user who registers registers on the system in which there are references to messages that are listed as recipients, are other approaches possible?

Thank you very much!

I'm not a better solution than creating a table dynamically for each new user You can see ...

You should never see "dynamically created tables" from a point of view.

  • Your problem is usually resolved as follows:

    • A user table (user_id, name , Surname ...)
    • a messages_recipients table (message_id, recipient_id)
    • a message table (message_id, time_stamp, messages_recipients both
    • message table and recipient_id fields sent_by ...)
    < P> field tables should be in the user_id field in the user field.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -