Skip to content

Instantly share code, notes, and snippets.

@andrewrcollins
Last active November 15, 2017 19:30
Show Gist options
  • Save andrewrcollins/cf3dc3a32136430b9da0e9cf8a49c3c4 to your computer and use it in GitHub Desktop.
Save andrewrcollins/cf3dc3a32136430b9da0e9cf8a49c3c4 to your computer and use it in GitHub Desktop.
Person, Friendship, Team, and Membership
DROP TABLE IF EXISTS `person`;
DROP TABLE IF EXISTS `friendship`;
DROP TABLE IF EXISTS `team`;
DROP TABLE IF EXISTS `membership`;
CREATE TABLE `person` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`birthday` DATE NOT NULL,
`height` int NOT NULL,
`wears_glasses` tinyint(1) NOT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE `friendship` (
`id` int NOT NULL AUTO_INCREMENT,
`a_id` int NOT NULL,
`b_id` int NOT NULL,
`started_at` DATETIME NOT NULL,
`ended_at` DATETIME NOT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE `team` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE `membership` (
`id` int NOT NULL AUTO_INCREMENT,
`team_id` int NOT NULL,
`person_id` int NOT NULL,
PRIMARY KEY (`id`)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment