I'm trying to create a notification system for my social network. But I'm stuck on the database design. so when a user comments on another user I want to display "X commented on your post." or when someone follows another I want to display a notification.
This is my table so far:
CREATE TABLE IF NOT EXISTS `notifications` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`notification_id` int(11) NOT NULL,
`text` text NOT NULL,
`read` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
The part where I'm confused at is, Should I insert a record when someone follows another person? Like... Right after when someone clicks follow button? If so, What should I insert to the row?
And I'm using PHP with Laravel framework.
textis redundant andnotification_idshould rather becomment_id(+ somecomment_typeif comments/posts/... notifications are sent for various entities).