0% found this document useful (0 votes)
87 views7 pages

Ejercicio Base Datos Clientes

The document describes creating several tables in a SQLite database for an office and sales management system. It creates tables for clients, sales reps, offices, products, and orders. Data is inserted into each table with sample records.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views7 pages

Ejercicio Base Datos Clientes

The document describes creating several tables in a SQLite database for an office and sales management system. It creates tables for clients, sales reps, offices, products, and orders. Data is inserted into each table with sample records.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

EJERCICIO 1

CREE LA BASE DE DATOS OFICINA Y MUESTRE LA INFORMACION EN SQLITE

CREATE TABLE clientes 


(
Num_clie   integer not null PRIMARY KEY,
Empresa    char (20) not null,
Repclie    integer,
Limite_credito numeric
);

INSERT INTO clientes VALUES (2101,'Jomes Mfg.',106, 65000);


INSERT INTO clientes VALUES (2102,'First. Corp. ', 101, 65000);
INSERT INTO clientes VALUES (2103,'Acme Mfg.', 105 ,50000); 
INSERT INTO clientes VALUES (2105,'AAA Investments', 101 ,45000);
INSERT INTO clientes VALUES (2106,'Fred Lewis Corp.',102 ,65000);
INSERT INTO clientes VALUES (2107,'Ace International', 110, 35000);
INSERT INTO clientes VALUES (2108,'Holm Landis', 109, 55000);
INSERT INTO clientes VALUES (2109,'Chen Associates', 103 , 25000);
INSERT INTO clientes VALUES (2111,'JCP Inc.', 103, 50000);
INSERT INTO clientes VALUES (2112,'Zetacorp', 108, 50000);
INSERT INTO clientes VALUES (2113,'Ian Schmidt', 104, 20000);
INSERT INTO clientes VALUES (2114,'Orion Corp.', 102,2000);
INSERT INTO clientes VALUES (2115,'Smithson Corp.', 101,20000);
INSERT INTO clientes VALUES (2117,'J.P. Sinclair', 106, 35000);
INSERT INTO clientes VALUES (2118,'Midwest Systems', 108, 60000);
INSERT INTO clientes VALUES (2119,'Solomon Inc.', 109, 25000);
INSERT INTO clientes VALUES (2120,'Rico Enterprises', 102, 50000);
INSERT INTO clientes VALUES (2121,'QMA Assoc.', 103, 45000);
INSERT INTO clientes VALUES (2122,'Three-Way Lines', 105, 30000);
INSERT INTO clientes VALUES (2123,'Carter Sons', 102, 40000);
INSERT INTO clientes VALUES (2124,'Peter Brothers', 107, 40000);

select * from clientes

CREATE TABLE repventas


(
Num_empl    integer not null PRIMARY KEY,
Nombre      Char(15) not null,
Edad        integer,
Oficina_rep integer,
Titulo      Char(10),
Contrato    date not null,
Director    Integer,
Cuota       numeric,
Ventas      numeric not null
);

INSERT INTO repventas VALUES (101,'Dan Roberst',45,12,'Rep Ventas', '20-10-1986', 104, 300000,
305673);
INSERT INTO repventas VALUES (102,'Sue Smith', 48, 21, 'Rep Ventas', '12-12-1986', 108, 350000,
474050);
INSERT INTO repventas VALUES (103, 'Paul Cruz', 29, 12, 'Rep Ventas', '01-04-1987', 104, 275000,
286775);
INSERT INTO repventas VALUES (104, 'Bob smith', 33, 12, 'Dir Ventas', '19-05-1987', 106, 200000,
142594);
INSERT INTO repventas VALUES (105, ' Bill Adams', 37, 13,'Rep ventas','12-02-1988', 104, 350000,
367911);
INSERT INTO repventas VALUES (106, 'Sam Clark', 52, 11,'Vp Ventas', '14-06-1988',null,275000,
299912);
INSERT INTO repventas VALUES (107, 'Nancy Angelli', 49, 22, 'Rep Ventas', '14-11-
1988',108,300000,1986042);
INSERT INTO repventas VALUES (108, 'Larry Fitch', 65, 21, 'Dir Ventas ' , '12-10-1989', 106, 350000,
361865);
INSERT INTO repventas VALUES (109, 'Mary Jones', 31,11, 'Rep Ventas', '12-10-1999', 106,
300000, 392725);
INSERT INTO repventas VALUES (110, 'Tom Snyder', 41 , null, 'Rep Ventas ', '14-01-1990', 101, null,
75985);

CREATE TABLE oficinas


(
Oficina       Integer not null PRIMARY KEY,
Ciudad        Char(15) not  null,
Region        Char (10) not null,
Dir           Integer  REFERENCES repventas (Num_empl),
Objetivo      float,
Ventas        float not null
);

INSERT INTO oficinas VALUES (11, 'New York','Este', 106, 575000, 692637); 
INSERT INTO oficinas VALUES (12, 'Chicago','Este', 104, 800000, 735042);
INSERT INTO oficinas VALUES (13, 'Atlanta', 'Este', 105, 350000, 367911);
INSERT INTO oficinas VALUES (21, 'Los Angeles', 'Oeste', 108, 725000, 835915);
INSERT INTO oficinas VALUES (22, ' Denver', 'Oeste', 108, 30000, 186042);

CREATE TABLE productos

(
Id_fab         Char(3) not null,
Id_producto    Char (5) not null,
Descripcion    Char (20) not null,
Precio         float not null,
Exixtencias Integer not null, 
CONSTRAINT productos_Id_fab_Id_producto 
PRIMARY KEY  ( Id_fab, Id_producto)
);

INSERT INTO productos VALUES  ('ACI',  '41001','Articulo Tipo 1 ', 55, 277);
INSERT INTO productos VALUES  ('AC',  '41002', 'Articulo  Tipo 2 ' , 76, 167);
INSERT INTO productos VALUES  ('ACI',  '41003', 'Articulo Tipo 3 ', 107 , 207);
INSERT INTO productos VALUES  ('ACI',  '41004',  'Articulo Tipo 4', 117, 207);
INSERT INTO productos VALUES  ('ACI',  '4100X',  'Ajustador', 25, 37);
INSERT INTO productos VALUES  ('ACI',  '4100Y', 'Extractor', 2.750, 28);
INSERT INTO productos VALUES  ('ACI',  '4100Z',  ' Montador',  2.5000, 28);
INSERT INTO productos VALUES  ('BIC',  '41003', 'Manivela ', 652, 3);
INSERT INTO productos VALUES  ('BIC',  '41089', ' Retn', 225, 78);
INSERT INTO productos VALUES  ('BIC',  '41672', 'Plate', 180, 0);
INSERT INTO productos VALUES  ('FEA',  '112', 'Cubierta',  148, 115);
INSERT INTO productos VALUES  ('FEA',  '114 ', 'Bancada Motor', 243, 15);
INSERT INTO productos VALUES  ('IMM',  '773C', 'Riostra 1/2 Tm' , 975, 28);
INSERT INTO productos VALUES  ('IMM',  '775C', 'Rioastra 1- Tm' ,1.425, 5);
INSERT INTO productos VALUES  ('IMM',  '779C', 'Rioastra 2- Tm', 1.875, 9);
INSERT INTO productos VALUES  ('IMM',  '878H', 'Soporte Riostra' ,54, 223); 
INSERT INTO productos VALUES  ('IMM',  '887P', 'Perno Riostra', 250, 24);
INSERT INTO productos VALUES  ('IMM',  '887X', 'Retenedor Riostra', 475,32);
INSERT INTO productos VALUES  ('QSA',  'XK47', 'Reductor', 355,38);
INSERT INTO productos VALUES  ('QSA',  'XK48', 'Reductor', 134,203);
INSERT INTO productos VALUES  ('QSA',  'XK48A', 'Reductor', 117,37);
INSERT INTO productos VALUES  ('REI',  '2A44G', 'Pasador bisagra', 350,14);
INSERT INTO productos VALUES  ('REI',  '2A44L', 'Bisagra Izda.', 4.500, 12);
INSERT INTO productos VALUES  ('REI',  '2A44R', 'Bisagra Dcha.', 4.500,12);
INSERT INTO productos VALUES  ('REI',  '2A44C', 'V stago Trinquete', 79,210);

CREATE TABLE pedidos 


(
Num_pedido  integer not null PRIMARY KEY,
Fecha_pedido date not null,
Clie   integer not null REFERENCES clientes (Num_clie),
Rep   integer REFERENCES repventas (Num_empl),
Fab  char (3)not null,
Producto char (5)not null,
Cant  integer not null,
Importe float not null
);

INSERT INTO pedidos VALUES (110036, '30-01-1990', 2107, 110, 'ACI', '4100Z', 9, 22500);
INSERT INTO pedidos VALUES (112961, '17-12-1989', 2117, 106, 'REI', '2a44l', 7, 31500);
INSERT INTO pedidos VALUES (112963, '17-12-1989', 2103, 101, 'ACI', '4100Z', 9, 3276);
INSERT INTO pedidos VALUES (112968, '12-10-1989', 2102, 101, 'ACI', '41004', 34, 3978);
INSERT INTO pedidos VALUES (112975, '12-10-1989', 2111, 103, 'REI', '2A44G', 6, 2100);
INSERT INTO pedidos VALUES (112979, '12-10-1989', 2114, 102, 'ACI', '4100Z', 6, 15000);
INSERT INTO pedidos VALUES (112983, '27-12-1989', 2103, 105, 'ACI', '41004', 6, 702);
INSERT INTO pedidos VALUES (112987, '31-12-1989', 2103, 105, 'ACI', '4100Y', 11, 27500);
INSERT INTO pedidos VALUES (112989, '04-01-1990', 2101, 106, 'FEA', '114', 6, 1458);
INSERT INTO pedidos VALUES (112992, '04-11-1989', 2118, 108, 'ACI', '41002', 10, 760);
INSERT INTO pedidos VALUES (112993, '04-01-1989', 2106, 102, 'REI', '2A45C', 24, 1896);
INSERT INTO pedidos VALUES (112997, '08-01-1990', 2124, 107, 'BIC', '41003', 1, 652);
INSERT INTO pedidos VALUES (113003, '25-01-1990', 2108, 109, 'IMM', '779C', 3, 5625);
INSERT INTO pedidos VALUES (113007, '08-01-1990', 2112, 108, 'IMM', '773C', 3, 2925);
INSERT INTO pedidos VALUES (113012, '11-01-1990', 2111, 105, 'ACI', '41003', 35, 3745);
INSERT INTO pedidos VALUES (113013, '14-01-1990', 2118, 108, 'BIC', '41003', 1, 652);
INSERT INTO pedidos VALUES (113024, '20-01-1990', 2114, 108, 'QSA', 'XK47', 20, 7100);
INSERT INTO pedidos VALUES (113027, '22-01-1990', 2103, 105, 'ACI', '41002', 54, 4104);
INSERT INTO pedidos VALUES (113034, '29-01-1990', 2107, 110, 'REI', '2A45C', 8, 632);
INSERT INTO pedidos VALUES (113042, '02-02-1990', 2113, 101, 'REI', '2A44R', 5, 22500);
INSERT INTO pedidos VALUES (113045, '02-02-1990', 2112, 108, 'REI', '2A44R', 10, 45000);
INSERT INTO pedidos VALUES (113048, '10-02-1990', 2120, 102, 'IMM', '779C', 2, 3750);
INSERT INTO pedidos VALUES (113049, '10-02-1990', 2118, 108, '0SA', 'XK47', 6, 2130);
INSERT INTO pedidos VALUES (113051, '10-02-1990', 2118, 108, 'QSA', 'XK47', 4, 1420);
INSERT INTO pedidos VALUES (113055, '15-02-1990', 2108, 101, 'ACI', '4100X', 6 , 150);
INSERT INTO pedidos VALUES (113057, '18-02-1990', 2111, 103, 'ACI', '4100X', 24, 600);
INSERT INTO pedidos VALUES (113058, '24-02-1990', 2108, 109, 'FEA', '112', 10, 1480);
INSERT INTO pedidos VALUES (113062, '24-02-1990', 2124, 107, 'FEA', '114', 10, 2430);
INSERT INTO pedidos VALUES (113065, '27-02-1990', 2106, 102, 'QSA', 'XK47', 6, 2130);
INSERT INTO pedidos VALUES (113069, '02-04-1990', 2109, 107, 'IMM', '775C', 22, 31350);

select * from pedidos


EJERCICIO 2
CREE LA BASE DE DATOS COLEGIO Y MUESTRE LA INFORMACION EN SQLITE

 
CREATE  TABLE departamento 
(
Dept    char (4) not null PRIMARY KEY,
Dedif   char (2) not null, 
Ddespacho integer not null,
Dchfno   char(3)

);

INSERT INTO departamento VALUES ('THEO','HU',200,'10');


INSERT INTO departamento VALUES ('CIS','SC',300,'80');
INSERT INTO departamento VALUES ('D.G.','SC',100,'');
INSERT INTO departamento VALUES ('PHIL','HU',100,'60'); 
 
SELECT * from departamento

CREATE TABLE curso


(
Cno      Char(3) not null PRIMARY KEY,
Cnombre  Char (22) not null,
Cdescp   Char (25) not null, 
Cred     integer not null,
Ctarifa  float null,
Cedpt    Char (4) not null REFERENCES departamento ( Dept)
);

select * from curso

INSERT INTO curso VALUES ('C11', 'INTROD. A LAS CC.', ' PARA NOVATOS', 3, 100, 'CIS'); 
INSERT INTO curso VALUES ('C22', 'ESTRUC. DE DATOS', 'MUY UTIL', 3, 50, 'CIS'); 
INSERT INTO curso VALUES ('C33', 'MATEMÁTICAS DISCRETAS', 'ABSOLUTAMENTE
NECESARIO', 3, 0, 'CIS');
INSERT INTO curso VALUES ('C44', 'CIRCUITOS DIGITALES', 'AH HA!', 3, 0, 'CIS');
INSERT INTO curso VALUES ('C55', 'ARQUITECT. COMPUTADOR', 'MAQ. VON NEUMANN', 3,
100, 'CIS');
INSERT INTO curso VALUES ('C66', 'BASES DE DATOS RELAC.', 'IMPRESCINDIBLE', 3, 500,
'CIS');
INSERT INTO curso VALUES ('P11', 'EMPIRISMO', 'VERLO PARA CREERLO', 3, 100, 'PHIL');
INSERT INTO curso VALUES ('P22', 'RACIONALISMO', 'PARA USARLOS CIS', 3 , 50, 'CIS');
INSERT INTO curso VALUES ('P33', 'EXISTENCIALISMO', 'PARA USARLOS CIS', 3, 200, 'PHIL');
INSERT INTO curso VALUES ('P44', 'SOLIPSISMO', 'PARA MI MISMO', 6, 0, 'PHIL');
INSERT INTO curso VALUES ('T11', 'ESCOLASTICISMO', 'PARA BEATOS', 3 , 150, 'THEO');
INSERT INTO curso VALUES ('T22', 'FUNDAMENTALISMO', 'PARA DESCUIDADDOS', 3, 90,
'THEO');
INSERT INTO curso VALUES ('T33', 'HEDONISMO', 'PARA SANOS' , 3, 0, 'THEO');
INSERT INTO curso VALUES ('T44 ',' COMUNISMO', 'PARA AVAROS', 6, 200, 'THEO');

CREATE TABLE claustro


(

Fno    Char (3) not null PRIMARY KEY,


Fnombre Char (15) not null,
Fdomi   Char (20)not null,
Ffcanti date not null,
Fnumdep integer,
Fsueldo float not null,
Fdept   Char (4) not null REFERENCES departamento (Dept)
);

select * from claustro

INSERT INTO  claustro VALUES ('06', 'KATHY PEPE', 'CALLE LA PIEDRA, 7', '15-01-1979', 2,
35000, 'PHIL');
INSERT INTO  claustro VALUES ('10', 'JESSIE MARTIN', 'Dr. DEL ESTE, 4', '01-09-1969', 2, 45000,
'THEO');
INSERT INTO  claustro VALUES ('08', 'JOSE COHN', 'AP. CORREOS 1138', '09-07-1979', 2, 35000,
'CIS');
INSERT INTO  claustro VALUES ('85', 'AL HARTLEY', 'CALLE DE LA PLATA', '05-09-1979', 7,
45000, 'CIS');
INSERT INTO  claustro VALUES ('60', 'JULIA MARTIN', 'Dr. DEL ESTE, 4', '01-09-1969', 1, 45000,
'PHIL');
INSERT INTO  claustro VALUES ('65', 'LISA BOBAK', 'CAMINO RISA, 77', '06-09-1981', 0, 36000,
'THEO');
INSERT INTO  claustro VALUES ('80', 'BARB HLAVATY', 'CALLE DEL SUR, 489', ' 16-07-1982', 3,
35000, 'CIS'); 

CREATE TABLE  clase


(
Cno      Char (3) not null REFERENCES curso (Cno),
Sec      Char (2) not null,
Cinstrfno Char (2) not null,
Cdia      Char (2) not null,
Chora     Char (14) not null,
Cedif     Char (2) not null,
Cdespacho integer not null,
CONSTRAINT clase_Cno_Sec PRIMARY KEY (Cno, Sec) 
);
select * from clase

INSERT INTO clase VALUES ('C11', '01', '08', 'LU', '08:00-09:00 AM', 'SC', 305);
INSERT INTO clase VALUES ('C11', '02', '08', 'MA', '08:00-09:00 AM', 'SC', 306);
INSERT INTO clase VALUES ('C33', '01', '80', 'MI', '09:00-10:00 AM', 'SC', 305);
INSERT INTO clase VALUES ('C55', '01', '85', 'JU', '11:00-12:00 AM', 'HU', 306);
INSERT INTO clase VALUES ('P11', '01', '06', 'JU', '09:00-10:00 AM', 'HU', 102);
INSERT INTO clase VALUES ('P33', '01', '06', 'VI', '11:00-12:00 AM', 'HU', 201);
INSERT INTO clase VALUES ('T11', '01', '10', 'LU', '10:00-11:00 AM', 'HU', 101);
INSERT INTO clase VALUES ('T11', '02', '65', 'LU', '10:00-11:00 AM', 'HU', 102);
INSERT INTO clase VALUES ('T33', '01', '65', 'MI', '11:00:12:00 AM', 'HU', 101);

CREATE  TABLE  estudiante


(
Sno         Char (3) not null PRIMARY KEY,
Snombre     Char (30) not null, 
Sdomi       Char (15) not null, 
Stlfno      Char (12) not null,
Sfnacim     Char (6) not null,
Siq         integer not null,
Sadvfno     Char (3) not null,
Sesp        char (4) not null REFERENCES departamento (Dept)
);

select * from estudiante

INSERT INTO estudiante VALUES ('325', 'CRUEY DUBAY', 'CONNECTICUT', '204-124-4567',


'780517', 122, '10','THEO');
INSERT INTO estudiante VALUES ('150', 'LARRY DUBAY', 'CONNECTICUT', '204-124-4567',
'780517', 121, '80','CIS');
INSERT INTO estudiante VALUES ('100', 'MOE DUBAY', 'CONNECTICUT', '204-124-4567', '780517',
120, '10','THEO'); 
INSERT INTO estudiante VALUES ('800', 'ROCKY BALBOA', 'PENSYLVANIA', '112-112-1122',
'461004', 99, '60','PHIL');

CREATE TABLE matricula(


Cno         Char (3) not null,
Sec         Char (2) not null,
Sno         Char (3) not null REFERENCES estudiante (Sno),
Fecha_mat  date not null, 
Hora_mat    Char (10) not null
CONSTRAINT matricula_Cno_Sec_Sno PRIMARY KEY (Cno, Sec, Sno)
);

SELECT * FROM matricula

INSERT INTO matricula VALUES ('C11', '01', '325', '04-01-1987', '09.41.30');


INSERT INTO matricula VALUES ('C11', '01', '800', '15-12-1987', '11.49.00');
INSERT INTO matricula VALUES ('C11', '02', '100', '17-12-1987', '09.32.00');
INSERT INTO matricula VALUES ('C11', '02', '150', '17-12-1987', '09.32.30');
INSERT INTO matricula VALUES ('P33', '01', '100', '24-12-1987', '11.30.00');
INSERT INTO matricula VALUES ('P33', '01', '800', '24-12-1987', '11.23.00');
INSERT INTO matricula VALUES ('T11', '01', '100', '24-12-1987', '11.21.00');
INSERT INTO matricula VALUES ('T11', '01', '150', '15-12-1987', '11.35.30');
INSERT INTO matricula VALUES ('T11', '01', '800', '15-12-1987', '14.00.00');

CREATE TABLE personal


(
Enombre     Char (15) not null PRIMARY KEY,
Cargo       Char (10) not null,
Esueldo     integer not null,
Dept        Char (4)
);
select * from personal

INSERT INTO personal VALUES ('LUCAS', 'EVANG1', 53, 'THEO');


INSERT INTO personal VALUES ('MARCOS', 'EVANG2',52, 'THEO');
INSERT INTO personal VALUES ('MATEO', 'EVANG3',51, 'THEO');
INSERT INTO personal VALUES ('DICK NIX', 'LADRÓN', 25001, 'PHIL');
INSERT INTO personal VALUES ('HANK KISS', 'BUFÓN', 25000, 'PHIL');
INSERT INTO personal VALUES ('JUAN', 'EVANG4', 54, 'THEO');
INSERT INTO personal VALUES ('EUCLIDES', 'AYTE. LAB', 1000, 'MATH');
INSERT INTO personal VALUES ('ARQUIMEDES', 'AYTE . LAB', 200, 'ENG');
INSERT INTO personal VALUES ('DAVINCI', 'AYTE . LAB', 500, ' ');

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy