Database schema of a similar system

I was thinking about a sympathy system for my website, and I cannot determine the best way to approach it. I use MySQL, and right now I have an action table for messages with text, images, videos, etc. And comment tables for comments. You can get by with comments and activity messages, so how do I go with the columns of the table? I am open to suggestions for changing the whole scheme for a more consistent design.

+5
source share
1 answer

Just create a table with a name likeswith a structure like this:

`id` int(11) NOT NULL AUTO_INCREMENT,
`userid` int(11) NOT NULL,
`post_type` varchar(10) NOT NULL,
`post_id` int(11) NOT NULL,
`date` datetime NOT NULL,
 PRIMARY KEY (`id`)

, - , , post_type , post_id ().

- , , .

, :

SELECT * FROM `likes` WHERE post_id = 'id' AND post_type = 'activity'

'id' ID.

( , post_type, ).

, , ​​ :)

+11

All Articles