database - mysql trigger after insert update value on different table -


i'm trying song voting system:

imagine have these tables in database:

table 'songs' song_id(primary) song_name song_artist song_votes

table 'votes' vote_id(primary) iddevice song_id

table 'users' iddevice(primary)

the table users, register id of device.

the table sonts, register info songs.

the table votes, created make sure every unique device can vote once each song.

what want achieve that, when device votes song, new row inserted on votes table, registering iddevice of person votes, , song_id of song receives vote. @ same time, field song_votes on songs table, has updated new vote, , assume has done trigger.

so, when insert row on votes table, song referenced song_id, has song_votes field updated.

if experience in mysql appreciate it. thx.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -