Created
October 5, 2012 15:24
-
-
Save kejyun/3840477 to your computer and use it in GitHub Desktop.
Kohana Relationship Test Table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE IF NOT EXISTS `musics` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '編號', | |
`name` varchar(100) COLLATE utf8_unicode_ci NOT NULL COMMENT '姓名', | |
PRIMARY KEY (`id`) | |
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='音樂單曲資訊' AUTO_INCREMENT=7 ; | |
INSERT INTO `musics` (`id`, `name`) VALUES | |
(1, '愛在西元前'), | |
(2, '爸 我回來了'), | |
(3, '陽光宅男'), | |
(4, '稻香'), | |
(5, 'Bad Romance'), | |
(6, 'Poker Face'); | |
CREATE TABLE IF NOT EXISTS `users` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '編號', | |
`name` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT '姓名', | |
`email` varchar(200) COLLATE utf8_unicode_ci NOT NULL COMMENT 'email', | |
PRIMARY KEY (`id`) | |
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='使用者資料表' AUTO_INCREMENT=3 ; | |
INSERT INTO `users` (`id`, `name`, `email`) VALUES | |
(1, '周杰倫', '[email protected]'), | |
(2, 'Lady Gaga', '[email protected]'); | |
CREATE TABLE IF NOT EXISTS `user_owner_musics` ( | |
`user_id` int(11) NOT NULL COMMENT '使用者編號', | |
`music_id` int(11) NOT NULL COMMENT '音樂單曲編號', | |
`note` text COLLATE utf8_unicode_ci NOT NULL COMMENT '心得', | |
UNIQUE KEY `user_id` (`user_id`,`music_id`) | |
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='使用者收藏的音樂'; | |
INSERT INTO `user_owner_musics` (`user_id`, `music_id`, `note`) VALUES | |
(1, 1, '好聽1'), | |
(1, 2, '好聽2'), | |
(1, 3, '好聽3'), | |
(1, 4, '好聽4'), | |
(2, 5, '好聽5'), | |
(2, 6, '好聽7'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment