Proyecto Media tecnica julian

Matias Areiza Puerta
Samuel Estrada
Carlos Mario Taborda
Laura Estrada
11*2

Julian Arboleda

Objetivos:

  1. Saber que usuarios reciclan mas que otros
  2. Saber en que sectores o lugares se recolecta mas basura
  3. Identificar cuantos son los usuarios que mas ingresan a la pagina en un determinado tiempo
  4. Tener registro de las personas que hacen registro de este qr
  5. Tener registro de las compras y puntos del usuario
  6. Hacer un conteo de los puntos gastados y ganados por el usuario
  7. Saber que productos se escanean más que otros
  8. Saber que productos son los más y menos canjeados en la tienda por los usuarios
  9. Saber que producto se recicla más y menos
  10. Cual es la maquina que mas qr recibe
  11. Tener registro de las personas que se hacen usuarios
  12. Tener registro de las tiendas que hacen parte de la pagina

Consultas

select v.descuento,p.nombre_p from tblventas v inner join tblp_t pt on(v.codp_t=pt.codp_t) inner join tblproductos p on (p.codproducto=pt.codproducto) where v.descuento >200 group by p.nombre_p; SELECT u.nombre_u, SUM(p.puntos_gastados) FROM tblpuntos p INNER JOIN tblusuarios u ON u.codusuario = p.codusuario GROUP BY u.nombre_u; SELECT u.nombre_u ,count(pt.codproducto) from tblusuarios u inner join tblpuntos p on (u.codusuario=p.codusuario) inner join tblventas pt on (u.codpunto=pt.codpunto) GROUP by nombre_u

Codigo SQL

create TABLE tblproductos(
        codproducto int(11) PRIMARY KEY AUTO_INCREMENT not null,
        nombre_p varchar(30) not null,
        precio int(11) not null
    );
    
    create TABLE tbltiendas(
        codtiendas int(11) PRIMARY KEY AUTO_INCREMENT not null,
        nombre_v varchar(30) not null,
        direccion_t varchar(30) not null
    );
    
    create TABLE tblusuarios(
        codusuario int(11) PRIMARY KEY AUTO_INCREMENT not null,
        nombre_u varchar(30) not null,
        telefono varchar(20) not null,
        direccion_u varchar(30) not null
    );
    
    create TABLE tblpuntos(
        codpunto int(11) PRIMARY KEY AUTO_INCREMENT not null,
        puntos_gastados int(11) not null, 
        puntos_totales int(11) not null,
        puntos_actuales int(11) not null,
        codusuario int(11) not null
    );
    
    create TABLE tblp_t(
        codp_t int(11) PRIMARY KEY AUTO_INCREMENT not null,
        codproducto int(11) not null,
        codtienda int(11) not null
    );
    
    
    create TABLE tblventas(
        codventa int(11) PRIMARY KEY AUTO_INCREMENT not null,
        descuento int(11) not null,
        precio_punto int(11) not null,
        codpunto int(11) not null,
        codp_t int(11) not null  
    );
    
    ALTER TABLE tblp_t ADD CONSTRAINT producto_fk 
    FOREIGN KEY (codproducto) 
    REFERENCES tblproductos(codproducto);
    
    ALTER TABLE tblp_t ADD CONSTRAINT tienda_fk 
    FOREIGN KEY (codtienda) 
    REFERENCES tbltiendas(codtiendas);
    
    ALTER TABLE tblventas ADD CONSTRAINT pt_fk 
    FOREIGN KEY (codp_t) REFERENCES tblp_t(codp_t);
    
    ALTER TABLE tblventas ADD CONSTRAINT puntos_fk 
    FOREIGN KEY (codpunto) 
    REFERENCES tblpuntos(codpunto);
    
    ALTER TABLE tblpuntos ADD CONSTRAINT usuario_fk 
    FOREIGN KEY (codusuario) 
    REFERENCES tblusuarios(codusuario);
    
     ALTER TABLE tblventas 
    ADD fecha DATE;
    
    
    
    INSERT INTO tblproductos VALUES
(1, 'Camisa', 50000),
(2, 'Pantalón', 70000),
(3, 'Zapatos', 120000),
(4, 'Chaqueta', 100000),
(5, 'Bufanda', 25000);
(6, 'Bufanda de Lana', 35000),
(7, 'Gorra Deportiva', 25000),
(8, 'Cinturón de Cuero', 45000),
(9, 'Reloj de Pulsera', 120000),
(10, 'Collar de Perlas', 80000),
(11, 'Guantes de Cuero', 40000),
(12, 'Billetera de Piel', 60000),
(13, 'Gafas de Sol', 70000),
(14, 'Calcetines de Algodón', 15000),
(15, 'Bufanda de Seda', 50000),
(16, 'Sombrero Panamá', 90000),
(17, 'Paraguas Plegable', 3000000),
(18, 'Portafolios de Cuero', 15000000),
(19, 'Lentes de Lectura', 3500000),
(20, 'Pulsera de Plata', 6000000),
(21, 'Mochila Escolar', 7000000),
(22, 'Maletín Ejecutivo', 120000),
(23, 'Corbata de Seda', 250000),
(24, 'Bufanda Infinita', 400000);
(25, 'Esperanza gomez', 4323400)

INSERT INTO tblusuarios VALUES
(1, 'Juan Pérez', 'Calle 123, Bogotá', '1234567890'),
(2, 'María López', 'Carrera 456, Medellín', '0987654321'),
(3, 'Carlos Gómez', 'Avenida 789, Cali', '5678901234'),
(4, 'Ana Martínez', 'Transversal 012, Barranquilla', '2345678901'),
(5, 'Pedro Rodríguez', 'Calle 345, Cartagena', '7890123456');
(6, 'Laura González', 'Carrera 789, Pereira', '3456789012'),
(7, 'Andrés Hernández', 'Avenida 901, Bucaramanga', '6789012345'),
(8, 'Sofía Ramírez', 'Calle 234, Villavicencio', '9012345678'),
(9, 'Jorge Díaz', 'Transversal 567, Cúcuta', '1234567890'),
(10, 'Luisa Vargas', 'Carrera 123, Armenia', '4567890123'),
(11, 'Diego Castro', 'Avenida 890, Manizales', '7890123456'),
(12, 'Valentina Sánchez', 'Calle 456, Pasto', '0123456789'),
(13, 'Gabriel Ramírez', 'Transversal 789, Santa Marta', '3456789012'),
(14, 'Ana María Gutiérrez', 'Carrera 234, Sincelejo', '6789012345'),
(15, 'Mateo Rojas', 'Avenida 567, Tunja', '9012345678'),
(16, 'Camila López', 'Calle 789, Popayán', '1234567890'),
(17, 'Daniel Martínez', 'Transversal 123, Riohacha', '4567890123'),
(18, 'Carolina Ruiz', 'Carrera 456, Quibdó', '7890123456'),
(19, 'Martín Gómez', 'Avenida 234, Montería', '0123456789'),
(20, 'Isabella Jiménez', 'Calle 567, Ibagué', '3456789012'),
(21, 'Simón Pérez', 'Transversal 789, Neiva', '6789012345'),
(22, 'Luciana Herrera', 'Carrera 123, Florencia', '9012345678'),
(23, 'David Soto', 'Avenida 456, Tunja', '1234567890'),
(24, 'Fernanda Castro', 'Calle 789, Arauca', '4567890123'),
(25, 'Sebastián Gómez', 'Transversal 123, Mocoa', '7890123456');

INSERT INTO tblpuntos VALUES
(1, 100, 500, 400, 7),
(2, 50, 300, 250, 23),
(3, 200, 800, 600, 6),
(4, 150, 600, 450, 5),
(5, 300, 1000, 700, 6);
(6, 80, 400, 320, 7),
(7, 30, 200, 170, 7),
(8, 150, 600, 450, 23),
(9, 100, 500, 400, 22),
(10, 200, 800, 600, 11),
(11, 50, 300, 250, 21),
(12, 120, 700, 580, 15),
(13, 180, 900, 720, 16),
(14, 250, 1000, 750, 12),
(15, 90, 400, 310, 25),
(16, 300, 1200, 900, 16),
(17, 70, 300, 230, 18),
(18, 200, 800, 600, 12),
(19, 150, 600, 450, 21),
(20, 50, 200, 150, 19),
(21, 180, 700, 520, 10),
(22, 120, 500, 380, 1),
(23, 80, 300, 220, 3),
(24, 220, 900, 680, 12),
(25, 30, 100, 70, 6);

INSERT INTO tbltiendas (codtiendas, nombre_v, direccion_t) VALUES
(1, 'Tienda A', 'Carrera 123, Bogotá'),
(2, 'Tienda B', 'Avenida 456, Medellín'),
(3, 'Tienda C', 'Calle 789, Cali'),
(4, 'Tienda D', 'Transversal 012, Barranquilla'),
(5, 'Tienda E', 'Carrera 345, Cartagena'),
(6, 'Tienda F', 'Avenida 678, Pereira'),
(7, 'Tienda G', 'Calle 901, Bucaramanga'),
(8, 'Tienda H', 'Carrera 234, Villavicencio'),
(9, 'Tienda I', 'Avenida 567, Cúcuta'),
(10, 'Tienda J', 'Calle 890, Armenia'),
(11, 'Tienda K', 'Transversal 123, Manizales'),
(12, 'Tienda L', 'Carrera 456, Pasto'),
(13, 'Tienda M', 'Avenida 789, Santa Marta'),
(14, 'Tienda N', 'Calle 012, Sincelejo'),
(15, 'Tienda O', 'Transversal 345, Tunja'),
(16, 'Tienda P', 'Carrera 678, Popayán'),
(17, 'Tienda Q', 'Avenida 901, Riohacha'),
(18, 'Tienda R', 'Calle 234, Quibdó'),
(19, 'Tienda S', 'Transversal 567, Montería'),
(20, 'Tienda T', 'Carrera 789, Ibagué'),
(21, 'Tienda U', 'Avenida 012, Neiva'),
(22, 'Tienda V', 'Calle 345, Florencia'),
(23, 'Tienda W', 'Transversal 678, Tunja'),
(24, 'Tienda X', 'Carrera 901, Arauca'),
(25, 'Tienda Y', 'Avenida 234, Mocoa');

INSERT INTO tblp_t (codp_t, codproducto, codtienda) VALUES
(1, 5, 1),
(2, 2, 8),
(3, 3, 3),
(4, 4, 4),
(5, 13, 5),
(6, 6, 6),
(7, 6, 7),
(8, 8, 8),
(9, 9, 9),
(10, 10, 10),
(11, 3, 2),
(12, 12, 12),
(13, 13, 13),
(14, 14, 4),
(15, 15, 15),
(16, 16, 16),
(17, 7, 1),
(18, 18, 18),
(19, 19, 19),
(20, 20, 20),
(21, 21, 21),
(22, 22, 22),
(23, 23, 23),
(24, 24, 24),
(25, 25, 25);


INSERT INTO tblventas (CodVenta, Descuento, PrecioPuntos, CodPuntos, CodP_T, Fecha) VALUES
(1, 10.00, 5000.00, 1, 1, '2024-05-01'),
(2, 15.50, 7500.00, 2, 2, '2024-05-02'),
(3, 20.00, 9600.00, 3, 3, '2024-05-03'),
(4, 5.00, 9500.00, 4, 4, '2024-05-04'),
(5, 12.00, 8800.00, 5, 5, '2024-05-05'),
(6, 8.00, 6000.00, 6, 6, '2024-05-06'),
(7, 18.00, 9200.00, 7, 7, '2024-05-07'),
(8, 9.00, 5400.00, 8, 8, '2024-05-08'),
(9, 22.50, 6750.00, 9, 9, '2024-05-09'),
(10, 13.00, 13000.00, 10, 10, '2024-05-10'),
(11, 7.50, 2250.00, 11, 11, '2024-05-11'),
(12, 25.00, 7500.00, 12, 12, '2024-05-12'),
(13, 6.50, 3250.00, 13, 13, '2024-05-13'),
(14, 30.00, 8400.00, 14, 14, '2024-05-14'),
(15, 11.00, 7700.00, 15, 15, '2024-05-15'),
(16, 14.50, 4350.00, 16, 16, '2024-05-16'),
(17, 17.00, 5100.00, 17, 17, '2024-05-17'),
(18, 9.50, 9500.00, 18, 18, '2024-05-18'),
(19, 8.00, 8000.00, 19, 19, '2024-05-19'),
(20, 21.00, 10500.00, 20, 20, '2024-05-20'),
(21, 16.50, 6600.00, 21, 21, '2024-05-21'),
(22, 28.00, 7000.00, 22, 22, '2024-05-22'),
(23, 19.50, 7800.00, 23, 23, '2024-05-23'),
(24, 10.00, 10000.00, 24, 24, '2024-05-24'),
(25, 11.50, 4600.00, 25, 25, '2024-05-25');