text: -- phpMyAdmin SQL Dump
  -- version 3.4.11.1deb1
  -- http://www.phpmyadmin.net
  --
  -- Host: localhost
  -- Generation Time: Nov 10, 2013 at 11:11 AM
  -- Server version: 5.5.32
  -- PHP Version: 5.4.9-4ubuntu2.3
  
  SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
  SET time_zone = "+00:00";
  
  
  /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
  /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
  /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
  /*!40101 SET NAMES utf8 */;
  
  --
  -- Database: `my_club`
  --
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `avatars`
  --
  
  CREATE TABLE IF NOT EXISTS `avatars` (
    `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    `path` varchar(145) NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `path_UNIQUE` (`path`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `infos`
  --
  
  CREATE TABLE IF NOT EXISTS `infos` (
    `id` int(11) unsigned NOT NULL,
    `name` varchar(45) DEFAULT NULL,
    `surname` varchar(45) DEFAULT NULL,
    `phone` int(10) DEFAULT NULL,
    `show_phone` tinyint(1) DEFAULT NULL,
    `show_email` tinyint(1) DEFAULT NULL,
    `height` tinyint(4) DEFAULT NULL,
    `weight` tinyint(4) DEFAULT NULL,
    `age` date DEFAULT NULL,
    `join_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
  --
  -- Dumping data for table `infos`
  --
  
  INSERT INTO `infos` (`id`, `name`, `surname`, `phone`, `show_phone`, `show_email`, `height`, `weight`, `age`, `join_date`) VALUES
  (4, '', '', 0, 1, 1, NULL, NULL, NULL, '2013-11-10 09:46:47');
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `photos`
  --
  
  CREATE TABLE IF NOT EXISTS `photos` (
    `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    `address` varchar(145) NOT NULL,
    `team_id` int(10) unsigned DEFAULT NULL,
    `uploaded` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
    `compressed` varchar(145) DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `address_UNIQUE` (`address`),
    KEY `fk_photos_1` (`team_id`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
  
  --
  -- Dumping data for table `photos`
  --
  
  INSERT INTO `photos` (`id`, `address`, `team_id`, `uploaded`, `compressed`) VALUES
  (1, 'upload/gallery/teams/1/1384078151.jpeg', 1, '2013-11-10 10:09:11', NULL);
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `requests`
  --
  
  CREATE TABLE IF NOT EXISTS `requests` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `user_id` int(10) unsigned NOT NULL,
    `team_id` int(10) unsigned NOT NULL,
    `date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
    `status` tinyint(4) DEFAULT NULL COMMENT 'If request is accepted set 1, if refused set 0',
    `read` timestamp NULL DEFAULT NULL COMMENT 'time when request was readed',
    `active` tinyint(4) DEFAULT '1' COMMENT 'If request is active set 1, if not active 0',
    `read_recipient` timestamp NULL DEFAULT NULL,
    PRIMARY KEY (`id`,`user_id`,`team_id`),
    UNIQUE KEY `user_id_UNIQUE` (`user_id`,`team_id`),
    KEY `fk_requests_1` (`user_id`),
    KEY `fk_requests_2` (`team_id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `roles`
  --
  
  CREATE TABLE IF NOT EXISTS `roles` (
    `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    `name` varchar(32) NOT NULL,
    `description` varchar(255) DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `name_UNIQUE` (`name`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ;
  
  --
  -- Dumping data for table `roles`
  --
  
  INSERT INTO `roles` (`id`, `name`, `description`) VALUES
  (1, 'login', 'Login privileges, granted after account confirmation'),
  (2, 'admin', 'Administrative user, has access to everything.'),
  (3, 'player', 'Player privileges, access to player options'),
  (4, 'staff', 'Staff privileges, access to staff options'),
  (5, 'accountant', 'Accountant privileges, access to accountant options'),
  (6, 'manager', 'Manager privileges, manage the club options'),
  (7, 'coach', 'Coach privileges, manage players'),
  (8, 'capitan', 'Capitan privileges, manage players');
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `role_users`
  --
  
  CREATE TABLE IF NOT EXISTS `role_users` (
    `role_id` int(11) unsigned NOT NULL,
    `user_id` int(11) unsigned NOT NULL,
    PRIMARY KEY (`role_id`,`user_id`),
    KEY `fk_role_users_users1` (`user_id`),
    KEY `fk_role_users_roles1` (`role_id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
  --
  -- Dumping data for table `role_users`
  --
  
  INSERT INTO `role_users` (`role_id`, `user_id`) VALUES
  (1, 4),
  (3, 4),
  (6, 4);
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `teams`
  --
  
  CREATE TABLE IF NOT EXISTS `teams` (
    `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    `short_name` varchar(15) NOT NULL,
    `full_name` varchar(65) NOT NULL,
    `description` varchar(255) DEFAULT NULL,
    `success` varchar(255) DEFAULT NULL,
    `training` varchar(255) DEFAULT NULL,
    `email` varchar(254) DEFAULT NULL,
    `phone` int(10) DEFAULT NULL,
    `street` varchar(45) DEFAULT NULL,
    `street_no` varchar(5) DEFAULT NULL,
    `zip_code` varchar(6) DEFAULT NULL,
    `city` varchar(45) DEFAULT NULL,
    `avatar_id` int(10) unsigned DEFAULT NULL,
    `join_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    UNIQUE KEY `short_name_UNIQUE` (`short_name`),
    UNIQUE KEY `full_name_UNIQUE` (`full_name`),
    KEY `fk_teams_1` (`avatar_id`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
  
  --
  -- Dumping data for table `teams`
  --
  
  INSERT INTO `teams` (`id`, `short_name`, `full_name`, `description`, `success`, `training`, `email`, `phone`, `street`, `street_no`, `zip_code`, `city`, `avatar_id`, `join_date`) VALUES
  (1, 'Fc Barcelona', 'FC Klub Barcelona', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2013-11-10 09:47:58');
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `training_users`
  --
  
  CREATE TABLE IF NOT EXISTS `training_users` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    `user_id` int(10) unsigned NOT NULL,
    `start` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
    `finish` timestamp NULL DEFAULT NULL,
    `type` varchar(45) DEFAULT NULL,
    `description` varchar(45) DEFAULT NULL,
    PRIMARY KEY (`id`),
    KEY `fk_training_users_1` (`user_id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `users`
  --
  
  CREATE TABLE IF NOT EXISTS `users` (
    `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    `email` varchar(254) NOT NULL,
    `username` varchar(32) NOT NULL DEFAULT '',
    `password` varchar(64) NOT NULL,
    `logins` int(10) unsigned NOT NULL DEFAULT '0',
    `last_login` int(10) unsigned DEFAULT NULL,
    `avatar_id` int(10) unsigned DEFAULT NULL,
    `team_id` int(10) unsigned DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `email_UNIQUE` (`email`),
    UNIQUE KEY `username_UNIQUE` (`username`),
    KEY `fk_users_1` (`avatar_id`),
    KEY `fk_users_2` (`team_id`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
  
  --
  -- Dumping data for table `users`
  --
  
  INSERT INTO `users` (`id`, `email`, `username`, `password`, `logins`, `last_login`, `avatar_id`, `team_id`) VALUES
  (4, 'tomek11@gmail.com', 'tomek11', '311e19286e457334ef7cde3a4df758f1bb0a995d15bcc6c01d8bba0e104a55da', 1, 1384076830, NULL, 1);
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `user_tokens`
  --
  
  CREATE TABLE IF NOT EXISTS `user_tokens` (
    `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
    `user_id` int(11) unsigned NOT NULL,
    `user_agent` varchar(40) NOT NULL,
    `token` varchar(40) NOT NULL,
    `created` int(10) unsigned NOT NULL,
    `expires` int(10) unsigned NOT NULL,
    PRIMARY KEY (`id`),
    KEY `fk_user_tokens_users1` (`user_id`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
  
  --
  -- Dumping data for table `user_tokens`
  --
  
  INSERT INTO `user_tokens` (`id`, `user_id`, `user_agent`, `token`, `created`, `expires`) VALUES
  (1, 4, '80eed272fb757a3cd8131e856120a7c4134d0a2d', '46a31e6a4df5d89bb6237f341055eb781c741e49', 1384076830, 1385286430);
  
  --
  -- Constraints for dumped tables
  --
  
  --
  -- Constraints for table `infos`
  --
  ALTER TABLE `infos`
    ADD CONSTRAINT `fk_infos_users1` FOREIGN KEY (`id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;
  
  --
  -- Constraints for table `photos`
  --
  ALTER TABLE `photos`
    ADD CONSTRAINT `fk_photos_1` FOREIGN KEY (`team_id`) REFERENCES `teams` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE;
  
  --
  -- Constraints for table `requests`
  --
  ALTER TABLE `requests`
    ADD CONSTRAINT `fk_requests_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
    ADD CONSTRAINT `fk_requests_2` FOREIGN KEY (`team_id`) REFERENCES `teams` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;
  
  --
  -- Constraints for table `role_users`
  --
  ALTER TABLE `role_users`
    ADD CONSTRAINT `fk_role_users_roles1` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
    ADD CONSTRAINT `fk_role_users_users1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;
  
  --
  -- Constraints for table `teams`
  --
  ALTER TABLE `teams`
    ADD CONSTRAINT `fk_teams_1` FOREIGN KEY (`avatar_id`) REFERENCES `avatars` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE;
  
  --
  -- Constraints for table `training_users`
  --
  ALTER TABLE `training_users`
    ADD CONSTRAINT `fk_training_users_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  
  --
  -- Constraints for table `users`
  --
  ALTER TABLE `users`
    ADD CONSTRAINT `fk_users_1` FOREIGN KEY (`avatar_id`) REFERENCES `avatars` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
    ADD CONSTRAINT `fk_users_2` FOREIGN KEY (`team_id`) REFERENCES `teams` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION;
  
  --
  -- Constraints for table `user_tokens`
  --
  ALTER TABLE `user_tokens`
    ADD CONSTRAINT `fk_user_tokens_users1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;
  
  /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
  /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
  