.header on
.mode column

CREATE TABLE DIPENDENTE (
    Matricola int PRIMARY KEY ,
    Cognome text,
    Nome text,
    Data_Nascita date,
    Indirizzo text,
    Città text,
    CAP int,
    Professione text,
    Reddito_Lordo real,
    Numero_Familiari int,
    Totale_Trattenute real,
    Codice_Azienda int REFERENCES AZIENDA(Codice_Azienda)
);

CREATE TABLE AZIENDA (
    Codice_Azienda int PRIMARY KEY ,
    Denominazione text,
    Indirizzo text,
    Città text,
    CAP int,
    Settore_Attivita text
);

CREATE TABLE VERSAMENTO (
    Numero_Versamento int PRIMARY KEY,
    Data_Versamento date,
    Importo real,
    Matricola int REFERENCES DIPENDENTE(Matricola)
);

INSERT INTO AZIENDA (Codice_Azienda, Denominazione, Indirizzo, Città, CAP, Settore_Attivita) 
VALUES 
(1, 'TechSoft S.r.l.', 'Via Roma 45', 'Milano', 20100, 'Informatica'),
(2, 'Costruzioni Alfa S.p.A.', 'Viale Monza 120', 'Roma', 00100, 'Costruzioni'),
(3, 'Commercio Vero S.r.l.', 'Corso Garibaldi 78', 'Torino', 10100, 'Commercio'),
(4, 'Industria Metalli S.r.l.', 'Via Venezia 30', 'Genova', 16100, 'Metallurgia'),
(5, 'Servizi Consulenza Ltd', 'Via Dante 55', 'Firenze', 50100, 'Consulenza');

INSERT INTO DIPENDENTE (Matricola, Cognome, Nome, Data_Nascita, Indirizzo, Città, CAP, Professione, Reddito_Lordo, Numero_Familiari, Totale_Trattenute, Codice_Azienda) 
VALUES 
(101, 'Rossi', 'Marco', '1990-05-15', 'Via del Corso 10', 'Milano', 20100, 'Programmatore', 45000.00, 2, 8500.00, 1),
(102, 'Bianchi', 'Anna', '1988-11-22', 'Piazza Venezia 5', 'Roma', 00100, 'Architetto', 50000.00, 1, 9500.00, 2),
(103, 'Verdi', 'Giovanni', '1992-03-08', 'Via Torino 30', 'Torino', 10100, 'Commerciante', 35000.00, 3, 6200.00, 3),
(104, 'Ferrari', 'Laura', '1991-07-12', 'Via Milano 20', 'Milano', 20100, 'Analista Sistemi', 48000.00, 0, 9100.00, 1),
(105, 'Marini', 'Paolo', '1989-09-25', 'Via Nazionale 15', 'Roma', 00100, 'Ingegnere', 55000.00, 2, 10500.00, 2),
(106, 'Gallo', 'Francesca', '1993-01-30', 'Via Garibaldi 50', 'Genova', 16100, 'Operaio', 32000.00, 1, 5800.00, 4),
(107, 'Rizzo', 'Antonio', '1987-12-10', 'Via Tornabuoni 25', 'Firenze', 50100, 'Consulente Senior', 60000.00, 4, 11500.00, 5),
(108, 'Conti', 'Silvia', '1994-04-18', 'Via Roma 80', 'Milano', 20100, 'Segretaria', 28000.00, 0, 5000.00, 1),
(109, 'De Luca', 'Roberto', '1991-06-22', 'Via Vespucci 40', 'Roma', 00100, 'Tecnico', 38000.00, 2, 7100.00, 2);

INSERT INTO VERSAMENTO (Numero_Versamento, Data_Versamento, Importo, Matricola) 
VALUES 
(1001, '2026-01-20', 700.00, 101),
(1002, '2026-02-20', 720.00, 101),
(1003, '2026-03-20', 710.00, 101),
(1004, '2026-01-25', 800.00, 102),
(1005, '2026-02-25', 820.00, 102),
(1006, '2026-03-25', 810.00, 102),
(1007, '2026-01-15', 520.00, 103),
(1008, '2026-02-15', 530.00, 103),
(1009, '2026-03-15', 525.00, 103),
(1010, '2026-01-20', 750.00, 104),
(1011, '2026-02-20', 770.00, 104),
(1012, '2026-03-20', 760.00, 104),
(1013, '2026-01-25', 890.00, 105),
(1014, '2026-02-25', 910.00, 105),
(1015, '2026-03-25', 900.00, 105),
(1016, '2026-01-10', 480.00, 106),
(1017, '2026-02-10', 495.00, 106),
(1018, '2026-01-30', 1000.00, 107),
(1019, '2026-02-28', 1020.00, 107),
(1020, '2026-03-30', 1010.00, 107),
(1021, '2026-01-15', 400.00, 108),
(1022, '2026-02-15', 415.00, 108),
(1023, '2026-01-22', 600.00, 109),
(1024, '2026-02-22', 615.00, 109),
(1025, '2026-03-22', 610.00, 109);

SELECT Matricola, Cognome, Nome, Professione, Reddito_Lordo
FROM DIPENDENTE;

.print

SELECT Denominazione, Indirizzo
FROM AZIENDA
WHERE Codice_Azienda = 1;

.print

SELECT Cognome, Nome, Reddito_Lordo
FROM DIPENDENTE
WHERE Reddito_Lordo > 45000.00;

.print

SELECT Denominazione, Indirizzo, Città
FROM AZIENDA
WHERE Città = 'Milano';


Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: