0% found this document useful (0 votes)
88 views4 pages

Car Tables-SQL

The document outlines the creation of a database schema for a car rental service, including tables for brands, models, cars, clients, and rental transactions. It includes SQL commands to create these tables and insert sample data for various car brands, models, and client information. The rental table records transactions with details such as document number, car ID, rental dates, and client IDs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views4 pages

Car Tables-SQL

The document outlines the creation of a database schema for a car rental service, including tables for brands, models, cars, clients, and rental transactions. It includes SQL commands to create these tables and insert sample data for various car brands, models, and client information. The rental table records transactions with details such as document number, car ID, rental dates, and client IDs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

--

--
--CONN AUTORENTA/CAR
--
--create table "brands" ("id_brand" number(5) primary key, "name_brand"
varchar2(20));
--
create table "models" ("brand_id" number(3), "model_id" number(3), "model_name"
varchar2(20)
constraint pk_model primary key ("id_brand", "id_model");

--
Create table autos (id_auto number(5) primary key, name varchar2(30), id_brand
number(3)
number(3)
char(4)
cost number(10), rent_value number(8));
--
create table clients (id_card varchar2(14) primary key, client_name varchar(40),
nationality varchar2(20)
address
varchar2(30));
--
create table rental (document_number number(8) primary key, car_id number(5), rental_date
date
number(8)

--
INSERT INTO BRANDS VALUES (103, 'MITSUBISHI');
INSERT INTO BRANDS VALUES (110, 'TOYOTA');
INSERT INTO BRANDS VALUES (120, 'NISSAN');
INSERT INTO BRANDS VALUES (125, 'HONDA');
INSERT INTO BRANDS VALUES (130, 'HYUNDAI');

INSERT INTO MODELOS VALUES (103,100, 'MONTERO');


INSERT INTO MODELS VALUES (103, 101, 'LANCER');
INSERT INTO MODELS VALUES (110, 200, 'YARIS');
INSERT INTO MODELS VALUES (110, 201, 'RAV4');
INSERT INTO MODELS VALUES (120, 300, 'BLUEBIRD');
INSERT INTO MODELS VALUES (120, 301, 'XTRAIL');
INSERT INTO MODELOS VALUES (125, 325, 'CIVIC');
INSERT INTO MODELS VALUES (130, 326, 'SANTA FE');
INSERT INTO MODELOS VALUES (130, 330, 'ELANTRA');

--

insert into autos (id_auto, name, id_brand, id_model, year, color, status,
cost, rent_value
values (200, 'MITSUBISHI MONTERO', 103, 100, 2011, 'ROJO', 'DSP', 30000, 60);
insert into cars (car_id, name, brand_id, model_id, year, color, status,
cost, rental_value
values (201, 'MITSUBISHI LANCER', 103, 101, 2011, 'NEGRO', 'DSP', 15000, 30);
insert into cars (car_id, name, brand_id, model_id, year, color, status,
cost, rental_value
values (204, 'TOYOTA YARIS', 110, 200, 2011, 'DORADO', 'DSP', 12750, 30);
insert into autos (id_auto, name, id_brand, id_model, year, color, status,
cost
values (203, 'TOYOTA RAV4', 110, 201, 2012, 'ROJO', 'DSP', 22500, 55);
insert into cars (car_id, name, brand_id, model_id, year, color, status,
cost
values (208, 'TOYOTA YARIS', 110, 200, 2011, 'BLANCO', 'DSP', 12500, 35);
insert into autos (id_auto, name, id_brand, id_model, year, color, status,
cost
values (205, 'NISSAN TIIDA', 120, 405, 2012, 'ROJO', 'DSP', 17500, 40);
insert into cars (car_id, name, brand_id, model_id, year, color, status,
cost
values (209, 'NISSAN XTRAIL', 120, 405, 2012, 'ROJO', 'DSP', 27000, 50);
insert into cars (car_id, name, brand_id, model_id, year, color, status,
cost
values (301, 'HYUNDAI SANTA FE', 130, 326, 2013, 'AZUL', 'DSP', 27000, 55);
insert into autos (id_auto, name, id_brand, id_model, year, color, status,
cost
values (302, 'HYUNDAI ELANTRA', 130, 330, 2013, 'AZUL', 'DSP', 27000, 40)

insert into clients (id_card, name_client, nationality, address, phone,


cell phone, email
values ('4-231-5423', 'JUAN PEREZ', 'PANAME A', 'DAVID', '765-3244', '6764-4340',
NULL);
insert into clients (id_card, name_client, nationality, address, phone,
cell phone, email
values ('4-234-52423', 'ROSA AGUIRRE', 'COSTARRICENSE', 'SAN VITO', '765-3244',
6764-4341, NULL);
insert into clients (id_card, name_client, nationality, address, phone,
cell phone, email
values ('4-236-51423', 'ESTELA ARAUZ', 'PANAME A', 'PASO CANOAS', '765-3244',
6764-4342, NULL);
insert into clients (id_card, client_name, nationality, address, phone,
cell phone, email
4-231-56421
4345', NULL);
insert into clients (id_card, name_client, nationality, address, phone,
cell phone, email
4-435-5429
4344', NULL);
insert into clients (id_card, name_client, nationality, address, phone,
cell phone, email
5-631-5423
4347', NULL);
--
insert into clients (id_card, name_client, nationality, address, phone,
cell phone, email
values ('4-731-5423', 'JUAN PEREZ', 'PANAME A', 'SAN ANDRES', '765-3244', '6754-
4360', NULL);
insert into clients (id_card, name_client, nationality, address, phone,
cell phone, email
values ('4-634-52423', 'ROSA AGUIRRE', 'COSTARRICENSE', 'SAN VITO', '765-3244',
'6764-4361', NULL);
insert into clients (id_card, client_name, nationality, address, phone,
cell phone, email
values ('4-636-51423', 'ESTELA ARAUZ', 'PANAME A', 'PASO CANOAS', '765-3244',
6764-4362, NULL;
insert into clients (id_card, name_client, nationality, address, phone,
cell phone, email
4-631-56421
4363', NULL);
insert into clients (id_card, name_client, nationality, address, phone,
cell phone, email
4-535-5429
4364', NULL);
insert into clients (id_card, client_name, nationality, address, phone,
cell phone, email
values ('5-531-5423', 'JUAN PEREZ', 'PANAME A', 'DAVID', '765-3244', '6764-4367',
NULL);
--
--
INSERT INTO RENTAL VALUES (1020, 200, '12/20/2012', 2, 80, '4-234-52423','A',
22/12/2012
INSERT INTO RENTAL VALUES (1021, 201, '12/22/2012', 1, 30, '4-234-52423', 'A',
23/12/2012
INSERT INTO RENTAL VALUES (1022, 204, '12/28/2012', 2, 80, '4-234-52423','A',
22/03/2013
INSERT INTO RENTAL VALUES (1023, 205, '10/01/2013', 3, 80, '4-234-52423','A',
12/06/2013
INSERT INTO RENTAL VALUES (1024, 201, '01/15/2013', 3, 80, '4-234-52423','A',
16/07/2013
INSERT INTO RENTAL VALUES (1025, 200, '03/20/2013', 2, 80, '4-234-52423','A',
July 22, 2013
INSERT INTO RENTAL VALUES (1026, 209, '06/22/2013', 2, 80, '4-234-52423', 'A',
24/08/2013
INSERT INTO RENTAL VALUES (1027, 208, '24/06/2013', 2, 80, '4-234-52423','A',
'25/08/2013');
INSERT INTO RENTAL VALUES (1028, 201, '06/25/2013', 2, 80, '4-234-52423','A',
27/08/2013
INSERT INTO RENTAL VALUES (1029, 205, '06/28/2013', 2, 80, '4-234-52423', 'A'
29/08/2013
--
INSERT INTO RENTAL VALUES (1030, 200, '07/03/2013', 2, 80, '4-234-52423','A'
04/09/2013
INSERT INTO RENTAL VALUES (1031, 201, '07/05/2013', 1, 30, '4-234-52423', 'A')
06/09/2013
INSERT INTO RENTAL VALUES (1032, 204, '10/07/2013', 2, 80, '4-234-52423','A',
11/09/2013
INSERT INTO RENTAL VALUES (1033, 205, '10/07/2013', 3, 80, '4-234-52423','A',
11/09/2013
INSERT INTO RENT VALUES (1034, 205, '07/15/2013', 3, 80, '4-234-52423','A',
09/16/2013
INSERT INTO RENTAL VALUES (1035, 205, '07/20/2013', 2, 80, '4-234-52423','A',
22/09/2013
INSERT INTO RENTAL VALUES (1036, 205, '07/21/2013', 2, 80, '4-234-52423', 'A',
22/09/2013
INSERT INTO RENTAL VALUES (1037, 208, '01/08/2013', 2, 80, '4-234-52423', 'A')
02/10/2013
INSERT INTO RENT VALUES (1038, 204, '04/08/2013', 2, 80, '4-234-52423','A',
05/10/2013
INSERT INTO RENTAL VALUES (1039, 205, '08/05/2013', 2, 80, '4-234-52423','A',
07/10/2013
INSERT INTO RENT VALUES (1040, 205, '28/08/2013', 2, 80, '4-234-52423','A',
02/10/2013
INSERT INTO RENTAL VALUES (1041, 301, '01/09/2013', 2, 80, '4-234-52423','A',
05/10/2013
INSERT INTO RENTAL VALUES (1042, 205, '03/09/2013', 2, 80, '4-234-52423', 'A')
07/10/2013
--
INSERT INTO RENTAL VALUES (1040, 302, '28/08/2013', 2, 80, '4-234-52423','A',
02/10/2013
INSERT INTO RENTAL VALUES (1041, 205, '01/09/2013', 2, 80, '4-234-52423','A',
05/10/2013
INSERT INTO RENTAL VALUES (1042, 301, '03/09/2013', 2, 80, '4-234-52423','A',
07/10/2013
--
INSERT INTO RENTAL VALUES (1040, 205, '28/08/2013', 2, 80, '4-234-52423','A',
02/10/2013
INSERT INTO RENTAL VALUES (1041, 302, '01/09/2013', 2, 80, '4-234-52423','A'
05/10/2013
INSERT INTO RENTAL VALUES (1042, 302, '09/03/2013', 2, 80, '4-234-52423','A',
07/10/2013
--
commit;

You might also like