Created
January 6, 2011 17:43
-
-
Save lukemorton/768248 to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
Book Owners Table | |
*/ | |
CREATE TABLE IF NOT EXISTS `book_owners` ( | |
`book_id` int(10) NOT NULL, | |
`owner_id` int(10) NOT NULL, | |
KEY `book` (`book_id`), | |
KEY `owner` (`owner_id`), | |
CONSTRAINT `book` FOREIGN KEY (`book_id`) REFERENCES `books` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, | |
CONSTRAINT `owner` FOREIGN KEY (`owner_id`) REFERENCES `owners` (`id`) ON DELETE CASCADE ON UPDATE CASCADE | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
INSERT INTO `book_owners` (`book_id`, `owner_id`) VALUES | |
(1, 1); |
This file contains 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
/* | |
Books Table | |
*/ | |
CREATE TABLE IF NOT EXISTS `books` ( | |
`id` int(10) NOT NULL auto_increment, | |
`name` varchar(255) NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
INSERT INTO `books` (`id`, `name`) VALUES | |
(1, 'Harry Potter and the Philosophers Stone'); |
This file contains 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
/* | |
Owners Table | |
*/ | |
CREATE TABLE IF NOT EXISTS `owners` ( | |
`id` int(10) NOT NULL auto_increment, | |
`name` varchar(255) NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
INSERT INTO `owners` (`id`, `name`) VALUES | |
(1, 'Luke'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment