-
Notifications
You must be signed in to change notification settings - Fork 4
/
tables.sql
93 lines (76 loc) · 2.41 KB
/
tables.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
-- phpMyAdmin SQL Dump
-- version 3.5.5
-- http://www.phpmyadmin.net
--
-- Client: localhost
-- Généré le: Lun 27 Mai 2013 à 12:08
-- Version du serveur: 5.5.29
-- Version de PHP: 5.4.10
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
--
-- Base de données: `quiz_generator`
--
-- --------------------------------------------------------
--
-- Structure de la table `categories`
--
CREATE TABLE IF NOT EXISTS `categories` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`course_id` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `course_id` (`course_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Structure de la table `courses`
--
CREATE TABLE IF NOT EXISTS `courses` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Structure de la table `questions`
--
CREATE TABLE IF NOT EXISTS `questions` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`question` text NOT NULL,
`answers` text NOT NULL,
`solution` tinyint(3) unsigned NOT NULL,
`category_id` int(10) unsigned DEFAULT NULL,
`stat_correct` int(10) unsigned NOT NULL DEFAULT '0',
`stat_total` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `category_id` (`category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Structure de la table `users_stats`
--
CREATE TABLE IF NOT EXISTS `users_stats` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`sciper` int(11) unsigned NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`questions_ids` text NOT NULL,
`user_choices` text NOT NULL,
`course_id` int(10) unsigned DEFAULT NULL,
`difficulty` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
KEY `course_id` (`course_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Contraintes pour les tables exportées
--
--
-- Contraintes pour la table `categories`
--
ALTER TABLE `categories`
ADD CONSTRAINT `categories_ibfk_2` FOREIGN KEY (`course_id`) REFERENCES `courses` (`id`) ON DELETE SET NULL;
--
-- Contraintes pour la table `questions`
--
ALTER TABLE `questions`
ADD CONSTRAINT `questions_ibfk_2` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE SET NULL;