Создание веб-приложения, сочетающего в себе проектирование и создание баз данных, работу со сторонними форматами данных, программирование в NET и веб-разработку, страница 31

  CONSTRAINT `khl20122013_1_goaliestats_ibfk_1` FOREIGN KEY (`team`) REFERENCES `teams` (`id`),

  CONSTRAINT `khl20122013_1_goaliestats_ibfk_2` FOREIGN KEY (`player`) REFERENCES `players` (`id`),

  CONSTRAINT `khl20122013_1_goaliestats_ibfk_3` FOREIGN KEY (`game`) REFERENCES `khl20122013_1_calendar` (`id`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8$$

delimiter $$

CREATE TABLE `khl20122013_1_playersstats` (

  `player` int(11) NOT NULL,

  `game` int(11) NOT NULL,

  `team` int(11) NOT NULL,

  `gp` int(11) NOT NULL DEFAULT '0',

  `g` int(11) NOT NULL,

  `a` int(11) NOT NULL,

  `p` int(11) NOT NULL,

  `pl_mn` int(11) NOT NULL,

  `pim` int(11) NOT NULL,

  `g_fs` int(11) NOT NULL,

  `g_pp` int(11) NOT NULL,

  `g_sh` int(11) NOT NULL,

  `g_ot` int(11) NOT NULL,

  `g_w` int(11) NOT NULL,

  `so` int(11) NOT NULL,

  `g_so` int(11) NOT NULL,

  `g_wso` int(11) NOT NULL,

  `sh` int(11) NOT NULL,

  `fo` int(11) NOT NULL,

  `fo_w` int(11) NOT NULL,

  `toi` float NOT NULL,

  `sft` int(11) NOT NULL,

  PRIMARY KEY (`player`,`game`),

  KEY `team` (`team`),

  KEY `foreign_game` (`game`),

  KEY `foreign_player` (`player`),

  CONSTRAINT `khl20122013_1_playersstats_ibfk_1` FOREIGN KEY (`team`) REFERENCES `teams` (`id`),

  CONSTRAINT `khl20122013_1_playersstats_ibfk_2` FOREIGN KEY (`player`) REFERENCES `players` (`id`),

  CONSTRAINT `khl20122013_1_playersstats_ibfk_4` FOREIGN KEY (`game`) REFERENCES `khl20122013_1_calendar` (`id`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8$$

delimiter $$

CREATE TABLE `khl20122013_1_teamstats` (

  `game` int(11) NOT NULL,

  `team` int(11) NOT NULL,

  `rival` int(11) NOT NULL,

  `player` int(11) NOT NULL,

  `gp` int(11) NOT NULL,

  `w` int(11) NOT NULL,

  `w_ot` int(11) NOT NULL,

  `w_so` int(11) NOT NULL,

  `l_so` int(11) NOT NULL,

  `l_ot` int(11) NOT NULL,

  `l` int(11) NOT NULL,

  `p` int(11) NOT NULL,

  `gf` int(11) NOT NULL,

  `ga` int(11) NOT NULL,

  `sho_w` int(11) NOT NULL,

  `sho_l` int(11) NOT NULL,

  `pp` int(11) NOT NULL,

  `pp_w` int(11) NOT NULL,

  `pp_ga` int(11) NOT NULL,

  `pk` int(11) NOT NULL,

  `pk_w` int(11) NOT NULL,

  `pk_g` int(11) NOT NULL,

  `s_g` int(11) NOT NULL,

  `sa_g` int(11) NOT NULL,

  `g1` int(11) NOT NULL,

  `g1_w` int(11) NOT NULL,

  `ga1` int(11) NOT NULL,

  `ga1_w` int(11) NOT NULL,

  `os` int(11) NOT NULL,

  `os_g` int(11) NOT NULL,

  `osa` int(11) NOT NULL,

  `osa_g` int(11) NOT NULL,

  `fo` int(11) NOT NULL,

  `fo_w` int(11) NOT NULL,

  `date_game` datetime NOT NULL,

  `date_log` datetime NOT NULL,

  `log` varchar(255) DEFAULT NULL,

  `stats_game` varchar(255) DEFAULT NULL,

  `stats_player` varchar(255) DEFAULT NULL,

  `stats_teams` varchar(255) DEFAULT NULL,

  PRIMARY KEY (`game`,`team`),

  KEY `team` (`team`),

  KEY `foreign_player` (`player`),

  KEY `foreign_rival` (`rival`),

  CONSTRAINT `khl20122013_1_teamstats_ibfk_1` FOREIGN KEY (`game`) REFERENCES `khl20122013_1_calendar` (`id`),

  CONSTRAINT `khl20122013_1_teamstats_ibfk_2` FOREIGN KEY (`team`) REFERENCES `khl20122013_1_calendar` (`home`),

  CONSTRAINT `khl20122013_1_teamstats_ibfk_3` FOREIGN KEY (`player`) REFERENCES `auth_user` (`id`),

  CONSTRAINT `khl20122013_1_teamstats_ibfk_4` FOREIGN KEY (`rival`) REFERENCES `khl20122013_1_calendar` (`home`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8$$

delimiter $$

CREATE TABLE `log` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `user` int(11) NOT NULL,

  `ip` int(10) unsigned DEFAULT NULL,

  `action` int(11) NOT NULL,

  `note` varchar(255) DEFAULT NULL,

  PRIMARY KEY (`id`),

  KEY `user` (`user`),

  KEY `action` (`action`),

  CONSTRAINT `log_ibfk_1` FOREIGN KEY (`user`) REFERENCES `auth_user` (`id`),

  CONSTRAINT `log_ibfk_2` FOREIGN KEY (`action`) REFERENCES `type_action` (`id`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8$$

delimiter $$

CREATE TABLE `type_action` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `action` varchar(255) NOT NULL,

  PRIMARY KEY (`id`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8$$