Skip to content

Instantly share code, notes, and snippets.

@daum
Created March 5, 2013 12:36
Show Gist options
  • Save daum/5090032 to your computer and use it in GitHub Desktop.
Save daum/5090032 to your computer and use it in GitHub Desktop.
Quick Example
CREATE TABLE IF NOT EXISTS `post` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(32) NULL ,
PRIMARY KEY (`id`) )
ENGINE = InnoDB
CREATE TABLE IF NOT EXISTS `post_attachment` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(32) NULL ,
`url` VARCHAR(32) NULL ,
`post_id` INT NOT NULL ,
PRIMARY KEY (`id`) ,
INDEX `fk_post_attachment_post_idx` (`post_id` ASC) ,
CONSTRAINT `fk_post_attachment_post`
FOREIGN KEY (`post_id` )
REFERENCES `post` (`id` )
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment