So, Lets say you are working on a messaging system. A really basic one, you want to keep it simple so its easy to back up, easy to code, etc. Also Fast and allows for expansion over time. What do you think about a stack based system for handling this? For example, you have a message which is made up of the To, From, Timestamp, and a Message. All you need to do is stack those messages and when a user is signed in and wants to check their messages all you need to do is loop through the list and find all the instances where To == the currently logged in user. Do you think this is a good way to handle this? or do you think there is a better way? Suggestions?
Bad idea, since SQL itself is more than enough to "loop through" the database and get all that user's messages (and sort them if you want to do that). One simple SELECT statement will do it. Tell it the To (which is the user) and, if you want, what to sort on (timestamp, from, your or your user's choice) and it'll return a dataset of all the messages for that user, optionally sorted in the order you tell it. Then all you have to do is give the user the messages. All at once or one at a time, depending on how you want to show it.