I have 2 tables, videos
and video_views
. I have a column in videos
which must have the values from video_views
ie for all the views of a particular video in video_views
it must store it in to videos
. This should happen dynamically whenever any update happens in video_views
. I tried making stored procedures but no luck.
How should I do this?
If you have just update operation, use
ON UPDATE CASCADE
for the foreign keys so whenever there is any update in video_views, that would automatically get updated in the VIDEO table..
By the way, a good approach would be to use the foreign key of video_views table so that you don't need to update records in child table and you won't have any redundant data in the tables.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.