Skip to content

Instantly share code, notes, and snippets.

@robfallows
Last active January 24, 2017 11:25
Show Gist options
  • Save robfallows/d42e402c84fcb01c44d56331e1536ac8 to your computer and use it in GitHub Desktop.
Save robfallows/d42e402c84fcb01c44d56331e1536ac8 to your computer and use it in GitHub Desktop.
CREATE DATABASE `mordor`;
USE `mordor`;
CREATE TABLE `hobbits` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `hobbits` VALUES
(1, 'Bilbo'),
(2, 'Frodo'),
(3, 'Smeagol'),
(4, 'Sam');
CREATE TABLE `items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`owner` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`),
KEY `owner` (`owner`),
CONSTRAINT `fk_owner` FOREIGN KEY (`owner`) REFERENCES `hobbits` (`id`) ON DELETE SET NULL ON UPDATE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `items` VALUES
(1, 'ring', 3);
CREATE USER 'sauron'@'localhost' IDENTIFIED BY 'theonetruering';
GRANT ALL ON `mordor`.* TO 'sauron'@'localhost';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment