@UDvoid
2014-12-28T18:54:42.000000Z
字数 855
阅读 2146
未分类
composer 0:作词人 1:作曲人
1.add_collect()
描述:
进行收藏操作时要把用户表项中的收藏数+1, 维护数据正确性
CREATE DEFINER=`root`@`localhost`
PROCEDURE `add_collect`(IN `username` VARCHAR(50))
NO SQL
begin
UPDATE user_info
SET user_collect = user_collect + 1
WHERE user_name LIKE username ;
end
2.sub_collect()
描述:
删除歌单中的歌曲时要相应的将用户数据表项中的收藏数减一,以维护数据的正确性
CREATE DEFINER=`root`@`localhost`
PROCEDURE `sub_collect`(IN `username` VARCHAR(50))
NO SQL
begin
UPDATE user_info
SET user_collect = user_collect - 1
WHERE user_name LIKE username;
end
1.del_collect_song
描述:在删除某个歌曲表项时,我们需要将所有包含了了这首歌的收藏信息删除,以保证数据完整性;
CREATE TRIGGER `del_collect_song`
BEFORE DELETE
ON `song_info`
FOR EACH ROW DELETE FROM collect_info
WHERE collect_info.song_name LIKE old.song_name
2.del_collect_user
描述:删除用户信息时,要将该用户的收藏信息删除,以维护数据完整性和数据的有效性;
CREATE TRIGGER `del_collect_user`
BEFORE DELETE
ON `user_info`
FOR EACH ROW DELETE FROM collect_info
WHERE collect_info.user_name LIKE old.user_name