I've been doing some researches about how to build a wall system similar to FB in PHP.
We planned to use an ODM (Mandango, MongoDB) instead of a regular ORM (MySQL) to achieve this. Some friend told me about inbox/outboxes system.
Inbox are all the messages that friends posts to your wall
Outbox are all the message you post
Why that ? Because it'll be simplier if you follow an user, you'll follow only his "outbox"
Each time i'll post something to my wall, this message will be duplicated to each of my followers (which will generate a lot of data).
But what about when a friend comments my post. On which entity is he going to comment my post ? Mine or his (because the content is duplicated) ?
What do you think ?
Have you already thought of this kind of question ? Have you any answers ?
Thanks
This is all about how you set up your database. I only have limited experience with MySql, so my answer relates to that. In this situation I would have at least these three tables:
-Users (with a unique id associated with each one)
-Messages: this includes both "inbox" and "outbox" messages. The reason you can put them all in one table is because if you're following someone, it will only pull those messages that have the (this is once column) "originating user id" and (this could be another column) "receiving user id" or some such thing. How you handle the data would all be done with php or asp or what have you.
-Comments: this holds all comments for all posts, and includes a column for the unique id of the message it relates to.
One thing to keep in mind when developing your system is that you never want to duplicate data. So, when you post to your wall, you don't want to actually create duplicate messages in your database for all the people who are following you, you want php to handle disseminating that information for you.
Related
I would like to create e-learning platform. So users will have a lot of things to choose (mostly available to view only for them) like:
add note
add movies to favorite
rate the instructor
And few options that auto save for each user like:
unanswered questions
wrong answer questions
movies in progress (user saw only 2 min from 5)
So what database or method I schould use for store that kind of data?
I do not want to use cookies because it needs to be save on user account and not on browser. User need to have that all on every browser or mobile device.
I wondering about json but...if I do so each user I'd will be available to view...so schould I use MySQL?
I would recommend that you build your own data logger, what i mean by this is build yourself a place to store every users data like an eManager if you would like.
Once this has been built you can then assign the eLearning courses using an ID to each of the users profile on your "eManager". Allowing you too keep track of each users progress etc.
The "eManager" could also save the users notes/wrong answers/unanswered questions, you could create surveys with a slider rating to rate the user. Honestly the limit is endless.
You can receive the data in two different ways:
(Personal) Either you can request that your users email you requesting a username and you generate a password and send it out to the user.
(Commercial) You build your eManager to recieve the data from the website which isnt too difficult to do.
It will be a long process and to answer your question in a different view practice SQL/PHP that would be your base make sure you can run more advanced query's and can confidently edit your DB etc.
Anymore questions just let me know, thanks.
I have a simple php user profile system that works like this: When user is registered he gets a specific url ?user. Therefore, other visitors can access his page.
What I want it to include chat application on users profile pages. But, every single user should have its own chat.
Which approach is the best, as I am a beginner in this? Should I put the messages from chat into the database or should I work with some log.txt files?
Any good tutorial for this would be helpful.
I found some tutorial for you: http://tutorialzine.com/2010/10/ajax-web-chat-php-mysql/
- looks like it could help you.
The only thing you need to adjust is to add room column in WEBCHAT_LINES table - that will be the unique name of the user, into which's chat room the chat line belongs. Then, when new chat line will be sent, you must save it to DB with apropriate room identificator. When you display the messages in chat, you must filter the results in each room to show only the lines for this particular room.
If you haven't use database before, there are plenty tutorials about mysql around the internet - it's not that difficult.
Good luck! And use Google when you'll have some doubts.
I'm trying to integrate a rating and like system as part of a package to send to the end user (with unknown progamming skill).
My problem is how to manage the users (registered or not) that have already done an action.At this moment I'm using PHP session to keep stored for a week the information, but this isn't a good solution.Is it a good solution creating 2 tables (one for rating and one for like) to store the information? If I use this solution what's the most useful and "correct" information to retrieve if the user is not registered? And is it user-friendly?I have thought to store: username and the ip
I would extend the members's table with at least two new columns, likes and rating or create a new table (as you said) including the memberID with a reference(and an index) to store and select the data. I believe it's the best way. Unfortunately, in this case non-members cannot press like or rate, but it is a good reason for one to register. –
i have a development blog in my project.i want add facility of set comment as unread for user until he/she see the comment.
suppose admin post a comment so for all users in that project should get that comment as unread
can anyone help
should i use $_SESSION or i have to use database tables?
You should use Database. Create 3 tables at least: user, comment, userReadComment since user read comment is a multi-to-multi relationship.
This calls for a proper design of the project.
What do you mean by :
i want it in php code...can any one help....i m totally stuck
?
You have to use Database only. It is as simple as this, once you have the comment table where you refer its ID and along with that you do user ID... if it is present, its read else, it isn't!
Or
You can set an enum of read or unread.
Can you show what have you done so far?
I want to be able to have notifications on my site, similar to the way SO does it. I have looked for a good table structure to do this, but I cant seem to figure it out.
I was thinking something like this.
Notifications
id, notification_type_id, user_id, type_id
Notification Types
id, notification_text
Where the notification type would relate to either a new post, a new comment, or whatever features I add later down the line... User Id would relate to whoever the notification is for. Type_id and notification type would go hand in hand, so if the notification_type was a new comment, the type_id would be the comment_id to go to.
This seems good to me, but i want to be able to notify ALL users when something changes.. like on facebook when you comment on something, you get a notification that someone else has also commented on the same thing after you.
I cant seem to figure this out... Help wanted
Thanks
EDIT: The way I thought about it was, the notification_type_id would map to the notification_type table, which would hold the text for each notification ("You have a new comment", "blah blah blah has also commented on blah blah blah", etc.), type_id would map to the primary_id of whatever the comment is about. for example, if the notification is saying you have a new comment on your post, then the type_id would be the primary id of the post for easy linking.. IDK, it was just a thought.
I know the question is about database structure for the notification systems, but I don't think any of the systems you mentioned doesn't have notification tables similar to the ones you mentioned.
Usually, to do such notifications, you are using triggers and a queue system to process them and send them to the correct people and channels.
So how I would design it is having tables in the SQL:
Event_type, message text (with any substitution template variables), channel (SMS/Email/Push), parameters
Then when you have commentPost() function, you run the trigger "commentPost", and in parameters, you can already send user_ids that commented before or user_ids that are watching that issue - but that can be checked by some function later too.
So then trigger is sent to some type of queue (SQS/RabbitMQ etc) and there is the processor that is reading that queue, checking event Type, and accordingly can send notifications based on events, but can also retrieve data from post if needed (like all users that commented post).
Then if you want to log it, you just send a message to some other queue that will write logs to the database.
sending notifications to user X by a push message should be just another queue that the browser is constantly reading for notifications.