-- phpMyAdmin SQL Dump
-- version 5.2.0
-- https://www.phpmyadmin.net/
--
-- Hôte : 127.0.0.1
-- Généré le : mar. 17 jan. 2023 à 16:42
-- Version du serveur : 10.4.27-MariaDB
-- Version de PHP : 8.2.0

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

--
-- Base de données : `proserveapi`
--

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

--
-- Structure de la table `participates`
--

CREATE TABLE `participates` (
  `userId` int(11) NOT NULL COMMENT 'user id',
  `sessionId` int(11) NOT NULL COMMENT 'session id',
  `score` int(11) NOT NULL DEFAULT 0 COMMENT 'user score in the session',
  `firePrecision` float NOT NULL DEFAULT 0 COMMENT 'user precision during the session',
  `nbEnemyHit` int(11) NOT NULL DEFAULT 0 COMMENT 'nb of enemies hit',
  `nbCivilsSaved` int(11) NOT NULL DEFAULT 0 COMMENT 'nb of civils saved',
  `damageTaken` int(11) NOT NULL DEFAULT 0 COMMENT 'total damages taken'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Structure de la table `reactevents`
--

CREATE TABLE `reactevents` (
  `id` int(11) NOT NULL COMMENT 'event id',
  `srcEventId` int(11) NOT NULL COMMENT 'id of the triggering event that initiated this reaction event',
  `reactType` int(11) NOT NULL COMMENT 'react event type',
  `hitUserId` int(11) NOT NULL DEFAULT 0 COMMENT 'id of the user that has been hit (0 if enemy/civil/env/game)',
  `hitTargetName` varchar(255) NOT NULL COMMENT 'target hit by the event',
  `hitBoneName` varchar(255) NOT NULL COMMENT 'bone hit on the target',
  `damage` int(11) NOT NULL DEFAULT 0 COMMENT 'damage points for the event',
  `targetKilled` tinyint(1) NOT NULL COMMENT 'did target got killed by the event ?',
  `objectHitLocationX` float NOT NULL COMMENT 'when hitting a target (object) record X position on texture',
  `objectHitLocationY` float NOT NULL COMMENT 'when hitting a target (object) record Y position on texture',
  `objectHitTagLocation` varchar(255) NOT NULL COMMENT 'tag on the hit object'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Structure de la table `reacteventtypes`
--

CREATE TABLE `reacteventtypes` (
  `id` int(11) NOT NULL COMMENT 'type id',
  `displayName` varchar(255) NOT NULL COMMENT 'name',
  `description` varchar(255) NOT NULL COMMENT 'description'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Déchargement des données de la table `reacteventtypes`
--

INSERT INTO `reacteventtypes` (`id`, `displayName`, `description`) VALUES
(0, 'EnemyHit', 'An enemy has been hit'),
(1, 'CivilianHit', 'A civilian has been hit'),
(2, 'PoliceHit', 'Another player has been hit by himself'),
(3, 'ObjectHit', 'A target (object) has been hit');

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

--
-- Structure de la table `sessions`
--

CREATE TABLE `sessions` (
  `id` int(11) NOT NULL COMMENT 'session id',
  `sessionType` int(11) NOT NULL COMMENT 'session type',
  `sessionName` varchar(255) NOT NULL COMMENT 'session name',
  `sessionDate` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date/time of the session',
  `mapName` varchar(255) NOT NULL COMMENT 'map of the session',
  `scenarioName` varchar(255) NOT NULL COMMENT 'scenario name that was played',
  `success` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'was the session successful (scenario objective reached) ?',
  `timeToFinish` int(11) NOT NULL COMMENT 'session duration',
  `score` int(11) NOT NULL DEFAULT 0 COMMENT 'user score',
  `nbEnemyHit` int(11) NOT NULL COMMENT 'nb of enemies hit',
  `nbCivilsSaved` int(11) NOT NULL COMMENT 'nb of civils saved',
  `damageTaken` float NOT NULL COMMENT 'total damage taken',
  `replayFileName` varchar(255) NOT NULL COMMENT 'filename of the session replay'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Structure de la table `sessiontypes`
--

CREATE TABLE `sessiontypes` (
  `id` int(11) NOT NULL COMMENT 'session type id',
  `displayName` varchar(255) NOT NULL COMMENT 'displayed name of the session type',
  `description` varchar(255) NOT NULL COMMENT 'description of the session type'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Déchargement des données de la table `sessiontypes`
--

INSERT INTO `sessiontypes` (`id`, `displayName`, `description`) VALUES
(0, 'FireRange', ''),
(1, 'Challenge', ''),
(2, 'Protect', ''),
(3, 'De-Escalation', ''),
(4, 'Terrorism', ''),
(5, 'FireExtinction', ''),
(6, 'Recovering', '');

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

--
-- Structure de la table `triggerevents`
--

CREATE TABLE `triggerevents` (
  `id` int(11) NOT NULL COMMENT 'id',
  `timeStamp` datetime NOT NULL COMMENT 'time the event occurred at',
  `successful` tinyint(1) NOT NULL COMMENT 'was the shot (or triggered event) successful (hit a target) ?',
  `srcUserId` int(11) NOT NULL COMMENT 'id of the user that triggered the shot',
  `sessionId` int(11) NOT NULL COMMENT 'id of the user session during which the event was triggered',
  `type` int(11) NOT NULL COMMENT 'type of event'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Structure de la table `triggereventtypes`
--

CREATE TABLE `triggereventtypes` (
  `id` int(11) NOT NULL COMMENT 'event type id',
  `displayName` varchar(255) NOT NULL COMMENT 'displayed name of the event type',
  `description` varchar(255) NOT NULL COMMENT 'description of the event type'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Déchargement des données de la table `triggereventtypes`
--

INSERT INTO `triggereventtypes` (`id`, `displayName`, `description`) VALUES
(0, 'Fire', 'Player has fired');

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

--
-- Structure de la table `users`
--

CREATE TABLE `users` (
  `id` int(11) NOT NULL COMMENT 'user id',
  `username` varchar(255) NOT NULL COMMENT 'username',
  `password` varchar(255) NOT NULL COMMENT 'password',
  `firstName` varchar(255) NOT NULL COMMENT 'first name',
  `lastName` varchar(255) NOT NULL COMMENT 'last name',
  `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date/time of the creation of the user account',
  `leftHanded` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is user left handed?',
  `maleGender` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'is user a man (true) or a woman?',
  `charSkinAssetName` varchar(255) NOT NULL COMMENT 'name of the asset for the character skin',
  `weaponAssetName` varchar(255) NOT NULL COMMENT 'name of the asset for the weapon',
  `lastConnection` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date/time of the last connection',
  `avgPrecision` float NOT NULL COMMENT 'average precision when firing',
  `avgReaction` float NOT NULL COMMENT 'average reaction time',
  `avgFault` float NOT NULL COMMENT 'average error rate',
  `avgRapidity` float NOT NULL COMMENT 'average rapidity time'
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Déchargement des données de la table `users`
--

INSERT INTO `users` (`id`, `username`, `password`, `firstName`, `lastName`, `created`, `leftHanded`, `maleGender`, `charSkinAssetName`, `weaponAssetName`, `lastConnection`, `avgPrecision`, `avgReaction`, `avgFault`, `avgRapidity`) VALUES
(0, 'game', '', '', '', '2023-01-13 15:31:16', 0, 1, '', '', '2023-01-13 16:31:16', 0, 0, 0, 0),
(14, 'guigui', 'Y29udHJvbA==', 'guy', 'iom', '2023-01-11 09:10:50', 0, 1, 'cat.fbx', 'claws.fbx', '2023-01-10 12:09:22', 0.75, 0.8, 0.4, 0.9),
(15, 'édouart.toto', 'TW90MnBhc3Nlw6Btb2k=', 'Édouart', 'SAINT-ÉMILIONé', '2023-01-09 10:58:09', 0, 0, '', '', '0000-00-00 00:00:00', 0, 0, 0, 0),
(25, 'polymorph', 'Y29udHJvbDM1', 'paul', 'imorf', '2023-01-11 10:57:52', 0, 0, '', '', '2023-01-11 11:57:52', 0, 0, 0, 0),
(30, 'titi', 'dGl0aXRpdGk=', 'titi', 'titi', '2023-01-16 13:38:49', 0, 1, '', '', '2023-01-16 14:38:49', 0, 0, 0, 0),
(31, 'jerome', 'Zm91Y2hlcg==', 'tezst', 'etstrgr', '2023-01-17 15:02:07', 0, 1, '', '', '2023-01-17 16:02:07', 0, 0, 0, 0);

--
-- Index pour les tables déchargées
--

--
-- Index pour la table `participates`
--
ALTER TABLE `participates`
  ADD PRIMARY KEY (`userId`,`sessionId`),
  ADD KEY `FK_Participates_SessionId` (`sessionId`);

--
-- Index pour la table `reactevents`
--
ALTER TABLE `reactevents`
  ADD PRIMARY KEY (`id`),
  ADD KEY `FK_React_SrcEventId` (`srcEventId`),
  ADD KEY `FK_React_TypeId` (`reactType`),
  ADD KEY `FK_React_HitUserId` (`hitUserId`);

--
-- Index pour la table `reacteventtypes`
--
ALTER TABLE `reacteventtypes`
  ADD PRIMARY KEY (`id`);

--
-- Index pour la table `sessions`
--
ALTER TABLE `sessions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `FK_sessionType` (`sessionType`) USING BTREE;

--
-- Index pour la table `sessiontypes`
--
ALTER TABLE `sessiontypes`
  ADD PRIMARY KEY (`id`);

--
-- Index pour la table `triggerevents`
--
ALTER TABLE `triggerevents`
  ADD PRIMARY KEY (`id`),
  ADD KEY `FK_TriggerEvent_SrcUserId` (`srcUserId`),
  ADD KEY `FK_TriggerEvent_Type` (`type`),
  ADD KEY `FK_TriggerEvent_UserId` (`sessionId`);

--
-- Index pour la table `triggereventtypes`
--
ALTER TABLE `triggereventtypes`
  ADD PRIMARY KEY (`id`);

--
-- Index pour la table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`);

--
-- AUTO_INCREMENT pour les tables déchargées
--

--
-- AUTO_INCREMENT pour la table `reactevents`
--
ALTER TABLE `reactevents`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'event id';

--
-- AUTO_INCREMENT pour la table `sessions`
--
ALTER TABLE `sessions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'session id', AUTO_INCREMENT=42;

--
-- AUTO_INCREMENT pour la table `triggerevents`
--
ALTER TABLE `triggerevents`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id';

--
-- AUTO_INCREMENT pour la table `users`
--
ALTER TABLE `users`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'user id', AUTO_INCREMENT=32;

--
-- Contraintes pour les tables déchargées
--

--
-- Contraintes pour la table `participates`
--
ALTER TABLE `participates`
  ADD CONSTRAINT `FK_Participates_SessionId` FOREIGN KEY (`sessionId`) REFERENCES `sessions` (`id`),
  ADD CONSTRAINT `FK_Participates_UserId` FOREIGN KEY (`userId`) REFERENCES `users` (`id`);

--
-- Contraintes pour la table `reactevents`
--
ALTER TABLE `reactevents`
  ADD CONSTRAINT `FK_React_HitUserId` FOREIGN KEY (`hitUserId`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `FK_React_SrcEventId` FOREIGN KEY (`srcEventId`) REFERENCES `triggerevents` (`id`),
  ADD CONSTRAINT `FK_React_TypeId` FOREIGN KEY (`reactType`) REFERENCES `reacteventtypes` (`id`);

--
-- Contraintes pour la table `sessions`
--
ALTER TABLE `sessions`
  ADD CONSTRAINT `FK_SessionType` FOREIGN KEY (`sessionType`) REFERENCES `sessiontypes` (`id`);

--
-- Contraintes pour la table `triggerevents`
--
ALTER TABLE `triggerevents`
  ADD CONSTRAINT `FK_TriggerEvent_SrcUserId` FOREIGN KEY (`srcUserId`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `FK_TriggerEvent_Type` FOREIGN KEY (`type`) REFERENCES `triggereventtypes` (`id`),
  ADD CONSTRAINT `FK_TriggerEvent_UserId` FOREIGN KEY (`sessionId`) REFERENCES `sessions` (`id`);
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 */;
