-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
53 lines (48 loc) · 1.23 KB
/
schema.sql
File metadata and controls
53 lines (48 loc) · 1.23 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
CREATE TABLE Tesseramenti (
anno INTEGER PRIMARY KEY,
apertura TEXT NOT NULL,
chiusura TEXT
);
CREATE TABLE Soci (
numeroTessera INTEGER NOT NULL,
tesseramento INTEGER NOT NULL,
corsoDiLaurea TEXT,
matricola TEXT NOT NULL,
nome TEXT NOT NULL,
cognome TEXT NOT NULL,
professione TEXT,
email TEXT NOT NULL,
quota INTEGER NOT NULL,
cellulare TEXT,
dataTesseramento TEXT,
cestinato INTEGER NOT NULL DEFAULT 0,
blacklist INTEGER NOT NULL DEFAULT 0,
FOREIGN KEY (tesseramento) REFERENCES Tesseramenti(anno),
FOREIGN KEY (corsoDiLaurea) REFERENCES CorsiDiLaurea(id),
PRIMARY KEY (numeroTessera, tesseramento)
);
CREATE TABLE CorsiDiLaurea (
id TEXT PRIMARY KEY,
nomeCorso TEXT NOT NULL,
storico INTEGER NOT NULL DEFAULT 0
);
CREATE TABLE Admin (
username TEXT PRIMARY KEY,
passwordHash TEXT NOT NULL,
canCreateUsers INTEGER NOT NULL,
active INTEGER NOT NULL
);
CREATE TABLE Sessioni (
auth_token TEXT PRIMARY KEY,
creazione TEXT NOT NULL,
scadenza TEXT NOT NULL,
utente TEXT NOT NULL,
FOREIGN KEY (utente) REFERENCES Admin(username)
);
CREATE TABLE Azioni (
id TEXT PRIMARY KEY,
moment TEXT NOT NULL,
action TEXT NOT NULL,
user TEXT NOT NULL,
FOREIGN KEY (user) REFERENCES Admin(username)
);