83 lines
2.9 KiB
SQL
83 lines
2.9 KiB
SQL
-- 1. CREAZIONE DEL DATABASE (Opzionale, decommenta se necessario)
|
|
CREATE DATABASE IF NOT EXISTS GenZ_Usage_Stats;
|
|
USE GenZ_Usage_Stats;
|
|
|
|
-- 2. CREAZIONE DELLE TABELLE
|
|
|
|
-- Tabella delle fasce d'età per normalizzare i dati
|
|
CREATE TABLE Fasce_Eta (
|
|
id_fascia INT PRIMARY KEY AUTO_INCREMENT,
|
|
range_eta VARCHAR(10) NOT NULL,
|
|
descrizione VARCHAR(50)
|
|
);
|
|
|
|
-- Tabella per l'utilizzo dei dispositivi
|
|
CREATE TABLE Statistiche_Dispositivi (
|
|
id_stat_device INT PRIMARY KEY AUTO_INCREMENT,
|
|
id_fascia INT,
|
|
tipo_dispositivo VARCHAR(30),
|
|
ore_medie_giornaliere DECIMAL(4,2),
|
|
FOREIGN KEY (id_fascia) REFERENCES Fasce_Eta(id_fascia)
|
|
);
|
|
|
|
-- Tabella per l'utilizzo dei Social Media
|
|
CREATE TABLE Statistiche_Social (
|
|
id_stat_social INT PRIMARY KEY AUTO_INCREMENT,
|
|
id_fascia INT,
|
|
piattaforma VARCHAR(30),
|
|
minuti_medi_giornalieri INT,
|
|
percentuale_penetrazione INT, -- % di giovani che lo usano in quella fascia
|
|
FOREIGN KEY (id_fascia) REFERENCES Fasce_Eta(id_fascia)
|
|
);
|
|
|
|
-- Tabella per l'autenticazione
|
|
CREATE TABLE Utenti(
|
|
id_utente INT PRIMARY KEY AUTO_INCREMENT,
|
|
nome VARCHAR(30),
|
|
cognome VARCHAR(18),
|
|
email VARCHAR(255) UNIQUE NOT NULL,
|
|
password VARCHAR(255) NOT NULL
|
|
);
|
|
|
|
-- 3. INSERIMENTO DATI (INSERT INTO)
|
|
|
|
-- Popolamento Fasce d'Età
|
|
INSERT INTO Fasce_Eta (range_eta, descrizione) VALUES
|
|
('12-15', 'Primi adolescenti / Scuole Medie'),
|
|
('16-19', 'Tardo adolescenti / Scuole Superiori'),
|
|
('20-23', 'Giovani Adulti / Università'),
|
|
('24-27', 'Giovani Professionisti / Post-Laurea');
|
|
|
|
-- Popolamento Statistiche Dispositivi (Media ore giornaliere)
|
|
INSERT INTO Statistiche_Dispositivi (id_fascia, tipo_dispositivo, ore_medie_giornaliere) VALUES
|
|
(1, 'Smartphone', 4.50), (1, 'Console Gaming', 1.50), (1, 'Tablet', 0.50),
|
|
(2, 'Smartphone', 6.00), (2, 'PC/Laptop', 1.50), (2, 'Console Gaming', 1.00),
|
|
(3, 'Smartphone', 5.50), (3, 'PC/Laptop', 2.50), (3, 'Smart TV', 1.00),
|
|
(4, 'Smartphone', 4.50), (4, 'PC/Laptop', 4.00), (4, 'Smart TV', 1.50);
|
|
|
|
-- Popolamento Statistiche Social (Dati basati su trend 2023-2024)
|
|
INSERT INTO Statistiche_Social (id_fascia, piattaforma, minuti_medi_giornalieri, percentuale_penetrazione) VALUES
|
|
-- Fascia 12-15
|
|
(1, 'TikTok', 110, 85),
|
|
(1, 'YouTube', 90, 92),
|
|
(1, 'Roblox/Discord', 60, 50),
|
|
-- Fascia 16-19
|
|
(2, 'TikTok', 120, 80),
|
|
(2, 'Instagram', 80, 88),
|
|
(2, 'Snapchat', 45, 60),
|
|
-- Fascia 20-23
|
|
(3, 'Instagram', 90, 90),
|
|
(3, 'TikTok', 80, 70),
|
|
(3, 'YouTube', 60, 85),
|
|
-- Fascia 24-27
|
|
(4, 'Instagram', 70, 85),
|
|
(4, 'WhatsApp', 60, 95),
|
|
(4, 'LinkedIn', 25, 45);
|
|
|
|
-- Inserimento utenti per autenticazione
|
|
-- Login utente esempio
|
|
-- Email: jeevacation@gmail.com
|
|
-- Password: changeme
|
|
INSERT INTO Utenti(nome,cognome,email,password) VALUES
|
|
('Jeffrey', 'Epstein', 'jeevacation@gmail.com', '$2y$10$1ZILQ71xxMjaAxDs2A6/Iut8UJfBPEGkeEuZgoIkVDapbNYUACxtW'),
|
|
('Andrea', 'Fiorencis', 'andrea@fiorencis.eu','$2y$10$y7fs8u4UOFJW5ds/dO84KumTxG2kh4jCubb1W0mAHzgmBZKRqA8Va'); |