-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.sql
More file actions
58 lines (53 loc) · 1.53 KB
/
database.sql
File metadata and controls
58 lines (53 loc) · 1.53 KB
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
--
-- Database: clubspace
--
CREATE DATABASE IF NOT EXISTS clubspace;
USE clubspace;
--
-- Table structure for table `users`
-- Stores user credentials for authentication
--
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(191) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL
);
--
-- Table structure for table `adherents`
-- Stores club members
--
CREATE TABLE IF NOT EXISTS adherents (
id INT AUTO_INCREMENT PRIMARY KEY,
nom VARCHAR(100) NOT NULL,
prenom VARCHAR(100) NOT NULL,
email VARCHAR(191) NOT NULL UNIQUE,
telephone VARCHAR(20),
club VARCHAR(100) NOT NULL,
date_inscription DATE DEFAULT CURRENT_DATE,
statut ENUM('actif', 'inactif') DEFAULT 'actif'
);
--
-- Table structure for table `events`
-- Stores club events
--
CREATE TABLE IF NOT EXISTS events (
id INT AUTO_INCREMENT PRIMARY KEY,
titre VARCHAR(255) NOT NULL,
description TEXT NOT NULL,
date_event DATETIME NOT NULL,
club_organisateur VARCHAR(100) NOT NULL,
places_disponibles INT NOT NULL DEFAULT 50,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
--
-- Table structure for table `reservations`
-- Stores event reservations by adherents
--
CREATE TABLE IF NOT EXISTS reservations (
id INT AUTO_INCREMENT PRIMARY KEY,
event_id INT NOT NULL,
adherent_id INT NOT NULL,
date_reservation TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (event_id) REFERENCES events(id) ON DELETE CASCADE,
FOREIGN KEY (adherent_id) REFERENCES adherents(id) ON DELETE CASCADE
);