Here is the SQL for all the tables…
-- phpMyAdmin SQL Dump
-- version 3.3.2deb1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Nov 13, 2010 at 03:35 PM
-- Server version: 5.1.41
-- PHP Version: 5.3.2-1ubuntu4.5
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
/*!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: `xcount`
--
-- --------------------------------------------------------
--
-- Table structure for table `tbl_classifications`
--
CREATE TABLE `tbl_classifications` (
`name` char(5) NOT NULL,
`descr` varchar(50) NOT NULL,
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `tbl_classifications`
--
INSERT INTO `tbl_classifications` (`name`, `descr`) VALUES
('EX', 'Expert'),
('HM', 'High Master'),
('MA', 'Master'),
('MK', 'Marksman'),
('SS', 'Sharpshooter'),
('UM', 'Unclassified Master');
-- --------------------------------------------------------
--
-- Table structure for table `tbl_competitors`
--
CREATE TABLE `tbl_competitors` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(20) NOT NULL,
`mid_init` char(1) DEFAULT NULL,
`last_name` varchar(30) NOT NULL,
`gender` enum('M','F') NOT NULL,
`birth_date` date DEFAULT NULL,
`nra_id` varchar(10) DEFAULT NULL,
`date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
--
-- Dumping data for table `tbl_competitors`
--
-- --------------------------------------------------------
--
-- Table structure for table `tbl_competitor_category`
--
CREATE TABLE `tbl_competitor_category` (
`competitor_fk` int(11) NOT NULL,
`spec_category_fk` char(5) NOT NULL,
PRIMARY KEY (`competitor_fk`,`spec_category_fk`),
KEY `spec_category_fk` (`spec_category_fk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `tbl_competitor_category`
--
-- --------------------------------------------------------
--
-- Table structure for table `tbl_competitor_class`
--
CREATE TABLE `tbl_competitor_class` (
`competitor_fk` int(11) NOT NULL,
`classification_fk` char(5) NOT NULL,
`discipline_fk` char(5) NOT NULL,
PRIMARY KEY (`competitor_fk`,`classification_fk`,`discipline_fk`),
KEY `classification_fk` (`classification_fk`),
KEY `discipline_fk` (`discipline_fk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `tbl_competitor_class`
--
-- --------------------------------------------------------
--
-- Table structure for table `tbl_contact_info`
--
CREATE TABLE `tbl_contact_info` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`competitor_fk` int(11) NOT NULL,
`street` varchar(50) NOT NULL,
`city` varchar(50) NOT NULL,
`state_prov` char(2) NOT NULL,
`post_code` varchar(10) NOT NULL,
`country` char(3) NOT NULL DEFAULT 'USA',
`phone` varchar(10) DEFAULT NULL,
`email` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `competitor_fk` (`competitor_fk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
--
-- Dumping data for table `tbl_contact_info`
--
-- --------------------------------------------------------
--
-- Table structure for table `tbl_discipline`
--
CREATE TABLE `tbl_discipline` (
`name` char(5) NOT NULL,
`category_fk` char(5) NOT NULL,
`type_fk` char(5) NOT NULL,
`descr` varchar(50) NOT NULL,
`type` enum('sling','f-class') NOT NULL,
PRIMARY KEY (`name`),
KEY `category_fk` (`category_fk`),
KEY `type_fk` (`type_fk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `tbl_discipline`
--
INSERT INTO `tbl_discipline` (`name`, `category_fk`, `type_fk`, `descr`, `type`) VALUES
('300m', '300m', '300m', 'Int''l 300m', 'sling'),
('FB-F', 'FB', 'FB', 'Int''l Fullbore F-Class', 'f-class'),
('FB-P', 'FB', 'FB', 'Int''l Fullbore Prone', 'sling'),
('LR-F', 'HP', 'LRP', 'HP Rifle Long-Range F-Class', 'f-class'),
('LR-P', 'HP', 'LRP', 'HP Rifle LR Prone', 'sling'),
('MR-F', 'HP', 'MRP', 'HP Rifle Mid-Range F-Class', 'f-class'),
('MR-P', 'HP', 'MRP', 'HP Rifle Mid-Range Prone', 'sling'),
('XTC', 'HP', 'XTC', 'HP Rifle Conventional', 'sling');
-- --------------------------------------------------------
--
-- Table structure for table `tbl_equipment_categories`
--
CREATE TABLE `tbl_equipment_categories` (
`name` char(5) NOT NULL,
`descr` varchar(50) NOT NULL,
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `tbl_equipment_categories`
--
INSERT INTO `tbl_equipment_categories` (`name`, `descr`) VALUES
('A', 'Any Rifle'),
('AA', 'Any Rifle - Any Sight'),
('AI', 'Any Rifle - Iron Sight'),
('FO', 'F-Class Open'),
('FTR', 'F-Class TR'),
('M', 'Match Rifle'),
('MA', 'Match Rifle - Any Sight'),
('P', 'Palma Rifle'),
('S', 'Service Rifle'),
('TR', 'Target Rifle');
-- --------------------------------------------------------
--
-- Table structure for table `tbl_matches`
--
CREATE TABLE `tbl_matches` (
`match_number` int(11) NOT NULL,
`discipline_fk` char(5) NOT NULL,
`tournament_fk` int(11) NOT NULL,
`name` varchar(50) DEFAULT NULL,
PRIMARY KEY (`match_number`,`discipline_fk`,`tournament_fk`),
KEY `discipline_fk` (`discipline_fk`),
KEY `tournament_fk` (`tournament_fk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `tbl_matches`
--
-- --------------------------------------------------------
--
-- Table structure for table `tbl_sanction`
--
CREATE TABLE `tbl_sanction` (
`name` char(5) NOT NULL,
`descr` varchar(50) NOT NULL,
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `tbl_sanction`
--
INSERT INTO `tbl_sanction` (`name`, `descr`) VALUES
('A', 'NRA Approved'),
('CMP', 'Civilian Marksmanship Program'),
('P', 'Practice'),
('R', 'NRA Registered');
-- --------------------------------------------------------
--
-- Table structure for table `tbl_scores`
--
CREATE TABLE `tbl_scores` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`competitor_fk` int(11) NOT NULL,
`stage_fk` int(11) NOT NULL,
`eqpt_fk` char(5) NOT NULL,
`points` int(11) NOT NULL,
`xcount` decimal(10,0) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
--
-- Dumping data for table `tbl_scores`
--
-- --------------------------------------------------------
--
-- Table structure for table `tbl_special_categories`
--
CREATE TABLE `tbl_special_categories` (
`name` char(5) NOT NULL,
`descr` varchar(50) NOT NULL,
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `tbl_special_categories`
--
INSERT INTO `tbl_special_categories` (`name`, `descr`) VALUES
('CIV', 'Civilian'),
('COL', 'Collegiate'),
('GS', 'Grand Senior'),
('IJ', 'Intermediate Junior'),
('JR', 'Junior'),
('LE', 'Police'),
('MIL', 'Active-duty Military'),
('NG', 'National Guard'),
('RES', 'Reserve other than NG'),
('SCH', 'Primary/Secondary school students'),
('SJ', 'Sub-Junior'),
('SR', 'Senior'),
('W', 'Woman');
-- --------------------------------------------------------
--
-- Table structure for table `tbl_stages`
--
CREATE TABLE `tbl_stages` (
`stage_number` int(11) NOT NULL,
`match_fk` int(11) NOT NULL,
`name` varchar(50) DEFAULT NULL,
`shots` int(11) NOT NULL,
`distance` int(11) NOT NULL,
PRIMARY KEY (`stage_number`,`match_fk`),
KEY `match_fk` (`match_fk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `tbl_stages`
--
-- --------------------------------------------------------
--
-- Table structure for table `tbl_tournaments`
--
CREATE TABLE `tbl_tournaments` (
`id` int(11) NOT NULL,
`name` varchar(50) NOT NULL,
`descr` varchar(255) DEFAULT NULL,
`start_date` date DEFAULT NULL,
`end_date` date DEFAULT NULL,
`sanction_fk` char(5) NOT NULL,
PRIMARY KEY (`id`),
KEY `sanction_fk` (`sanction_fk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `tbl_tournaments`
--
-- --------------------------------------------------------
--
-- Table structure for table `tbl_tournament_category`
--
CREATE TABLE `tbl_tournament_category` (
`name` char(5) NOT NULL,
`descr` varchar(50) NOT NULL,
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `tbl_tournament_category`
--
INSERT INTO `tbl_tournament_category` (`name`, `descr`) VALUES
('300m', 'International 300m'),
('FB', 'International Fullbore'),
('HP', 'High Power Rifle');
-- --------------------------------------------------------
--
-- Table structure for table `tbl_tournament_type`
--
CREATE TABLE `tbl_tournament_type` (
`name` char(5) NOT NULL,
`descr` varchar(50) NOT NULL,
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `tbl_tournament_type`
--
INSERT INTO `tbl_tournament_type` (`name`, `descr`) VALUES
('300m', '300m'),
('FB', 'Fullbore'),
('LRP', 'Long-Range Prone'),
('MRP', 'Mid-Range Prone'),
('SR', 'Sporting Rifle'),
('XTC', 'Conventional');
--
-- Constraints for dumped tables
--
--
-- Constraints for table `tbl_competitor_category`
--
ALTER TABLE `tbl_competitor_category`
ADD CONSTRAINT `tbl_competitor_category_ibfk_1` FOREIGN KEY (`competitor_fk`) REFERENCES `tbl_competitors` (`id`),
ADD CONSTRAINT `tbl_competitor_category_ibfk_2` FOREIGN KEY (`spec_category_fk`) REFERENCES `tbl_special_categories` (`name`);
--
-- Constraints for table `tbl_competitor_class`
--
ALTER TABLE `tbl_competitor_class`
ADD CONSTRAINT `tbl_competitor_class_ibfk_1` FOREIGN KEY (`competitor_fk`) REFERENCES `tbl_competitors` (`id`),
ADD CONSTRAINT `tbl_competitor_class_ibfk_2` FOREIGN KEY (`classification_fk`) REFERENCES `tbl_classifications` (`name`),
ADD CONSTRAINT `tbl_competitor_class_ibfk_3` FOREIGN KEY (`discipline_fk`) REFERENCES `tbl_discipline` (`name`);
--
-- Constraints for table `tbl_contact_info`
--
ALTER TABLE `tbl_contact_info`
ADD CONSTRAINT `tbl_contact_info_ibfk_1` FOREIGN KEY (`competitor_fk`) REFERENCES `tbl_competitors` (`id`);
--
-- Constraints for table `tbl_discipline`
--
ALTER TABLE `tbl_discipline`
ADD CONSTRAINT `tbl_discipline_ibfk_1` FOREIGN KEY (`category_fk`) REFERENCES `tbl_tournament_category` (`name`),
ADD CONSTRAINT `tbl_discipline_ibfk_2` FOREIGN KEY (`type_fk`) REFERENCES `tbl_tournament_type` (`name`);
--
-- Constraints for table `tbl_matches`
--
ALTER TABLE `tbl_matches`
ADD CONSTRAINT `tbl_matches_ibfk_1` FOREIGN KEY (`discipline_fk`) REFERENCES `tbl_discipline` (`name`),
ADD CONSTRAINT `tbl_matches_ibfk_2` FOREIGN KEY (`tournament_fk`) REFERENCES `tbl_tournaments` (`id`);
--
-- Constraints for table `tbl_stages`
--
ALTER TABLE `tbl_stages`
ADD CONSTRAINT `tbl_stages_ibfk_1` FOREIGN KEY (`match_fk`) REFERENCES `tbl_matches` (`match_number`);
--
-- Constraints for table `tbl_tournaments`
--
ALTER TABLE `tbl_tournaments`
ADD CONSTRAINT `tbl_tournaments_ibfk_1` FOREIGN KEY (`sanction_fk`) REFERENCES `tbl_sanction` (`name`);