-- phpMyAdmin SQL Dump
-- version 5.0.3
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: May 27, 2021 at 10:31 PM
-- Server version: 5.7.33
-- PHP Version: 7.3.28

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
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 utf8mb4 */;

--
-- Database: `photo`
--

-- --------------------------------------------------------

--
-- Table structure for table `ab_bodies`
--

CREATE TABLE `ab_bodies` (
  `bodycode` varchar(3) NOT NULL,
  `bodyname` varchar(64) NOT NULL,
  `email` varchar(64) NULL,
  `bodystatus` varchar(2) NOT NULL,
  `bodycategory` varchar(25) NOT NULL,
  `bodycategoryorder` int(11) NOT NULL,
  `bodynameascii` varchar(64) NOT NULL,
  `netcomcode` char(1) NULL,
  `countrycode` varchar(3) NULL,
  PRIMARY KEY (`bodycode`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `user`
--

CREATE TABLE `user` (
  `uid` int(11) NOT NULL AUTO_INCREMENT,
  `bodycode` varchar(3) NOT NULL,
  `name` varchar(128) NOT NULL,
  `email` varchar(64) NOT NULL,
  `access` enum('user','admin','superadmin','none') NOT NULL DEFAULT 'none',
  PRIMARY KEY (`uid`),
  KEY `user_bodycode` (`bodycode`),
  CONSTRAINT `user_bodycode` FOREIGN KEY (`bodycode`) REFERENCES `ab_bodies` (`bodycode`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `event`
--

CREATE TABLE `event` (
  `eventcode` varchar(9) NOT NULL,
  `bodycode` varchar(3) NOT NULL,
  `bodycode2` varchar(3) NULL,
  `title` varchar(128) NOT NULL,
  `topic` varchar(128) NULL,
  `projectname` varchar(64) NULL,
  `location` varchar(128) NULL,
  `datestart` date NOT NULL,
  `dateend` date NOT NULL,
  `eventtype` varchar(24) NULL,
  `calofficial` enum('','yes','no','under evaluation') NOT NULL DEFAULT 'no',
  `certainty` enum('','definite','likely','preliminary','unlikely','cancelled') NOT NULL DEFAULT '',
  `area` enum('','local','national','regional','european','international') NOT NULL DEFAULT '',
  `eventrating` enum('','standard event','yearplan event','priority event','summer university') NOT NULL DEFAULT '',
  `url` varchar(64) NULL,
  PRIMARY KEY (`eventcode`),
  KEY `event_bodycode` (`bodycode`),
  CONSTRAINT `event_bodycode` FOREIGN KEY (`bodycode`) REFERENCES `ab_bodies` (`bodycode`),
  KEY `event_bodycode2` (`bodycode2`),
  CONSTRAINT `event_bodycode2` FOREIGN KEY (`bodycode2`) REFERENCES `ab_bodies` (`bodycode`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `book`
--

CREATE TABLE `book` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uid` int(11) NOT NULL,
  `eventcode` varchar(9) NOT NULL,
  `photocount` int(11) NOT NULL DEFAULT '0',
  `title` varchar(128) NOT NULL,
  `comment` text NULL,
  PRIMARY KEY (`id`),
  KEY `book_uid` (`uid`),
  CONSTRAINT `book_uid` FOREIGN KEY (`uid`) REFERENCES `user` (`uid`),
  KEY `book_eventcode` (`eventcode`),
  CONSTRAINT `book_eventcode` FOREIGN KEY (`eventcode`) REFERENCES `event` (`eventcode`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `photo`
--

CREATE TABLE `photo` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `book_id` int(11) NOT NULL,
  `nr` int(3) NOT NULL,
  `photo_big` mediumblob,
  `photo_normal` mediumblob,
  `photo_thumb` blob,
  `height_big` int(3) NULL,
  `width_big` int(3) NULL,
  `height_normal` int(3) NULL,
  `width_normal` int(3) NULL,
  `height_thumb` int(3) NULL,
  `width_thumb` int(3) NULL,
  `comment` text NULL,
  `date_add` datetime NULL,
  `filename` varchar(16) NULL,
  PRIMARY KEY (`id`),
  KEY `photo_book_id` (`book_id`,`nr`),
  CONSTRAINT `photo_book_id` FOREIGN KEY (`book_id`) REFERENCES `book` (`id`),
  KEY `photo_date_add` (`date_add`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

COMMIT;

/*!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 */;
