Jump to content

Simple database question


pianoman993

Recommended Posts

Hello, I am creating a private messaging system and I am having trouble figuring out how to allow for a person to send a message to multiple people. Here's an example of what I mean.

 

If I sent a message (I have an ID of lets say 3) and I would like to send my message to a group of people (IDS of 4, 5 and 6), I would insert the numbers 3,4,5,6 into a recipient field and 3 into an author_id field. Is that a good method for allowing multiple recipients? I ask this because it defies the rules of normalization.

 

Also, if this is the correct method, then how do I insert multiple values into a database and have them seperated by something like a ; and how do i search the database to find if a number in the array exists?

 

Any help would be greatly appreciated! Thanks!

- Mark

Link to comment
https://forums.phpfreaks.com/topic/121552-simple-database-question/
Share on other sites

As Mchl has said, just make sure your tables are properly indexed. 

 

I think it helps to have a unique ID autonumbering column in each of your tables which you can index on. 

 

If you have designed your relational database properly, i.e. fully relational, linking tables via row ID numbers, searches involving large numbers of records should be performed reasonably quickly.

 

Rgds

Sorry, I just have one more question that just crept into my head and that is, how do forums ( like this one for instance) make it in their database so that the user ( me ) knows what thread was viewed since it was last modified and which thread was not. It would be a complete waist for the database to make a table containing a row for each user correlating to each thread in the forum so how do they do it?! I'm quite puzzled on this

 

:(

 

Any ideas?

 

- Mark

I'd expect to see something like this in the DB

[pre]

 

thread              thread_view              user

----------          -------------            -------------

threadID    ---+    viewID          +----    userID

date_posted    |    userID      ----+        profile_stuff

etc            +--  threadID

                    view_time

[/pre]

For SMF you're not far away

 

There's

[pre]

table (prefix)_log_topics

ID_MEMBER

ID_TOPIC

ID_MSG

[/pre]

 

ID_MEMBER indicates forum user of course

ID_TOPIC indicates a topic

ID_MSG indicates last message in topic that user has read

 

Or so I understand from quick examination of database structure and forum code. ;)

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.