This document outlines the creation of a database called "ClientRent" to store information about properties rented by clients. It describes creating tables for clients, owners, properties, and rentals with primary and foreign keys. Data is inserted into the tables and some sample queries are provided to count rentals by owner and property, select client and property pairs, and group properties by count of rentals.
This document outlines the creation of a database called "ClientRent" to store information about properties rented by clients. It describes creating tables for clients, owners, properties, and rentals with primary and foreign keys. Data is inserted into the tables and some sample queries are provided to count rentals by owner and property, select client and property pairs, and group properties by count of rentals.
This document outlines the creation of a database called "ClientRent" to store information about properties rented by clients. It describes creating tables for clients, owners, properties, and rentals with primary and foreign keys. Data is inserted into the tables and some sample queries are provided to count rentals by owner and property, select client and property pairs, and group properties by count of rentals.
-insert into cliente values ('CR76', 'John Kay'); -insert into cliente values ('CR56', 'Aline Stewat'); 7. Insertamos datos a la tabla owner. -insert into owner values ('C040', 'Tina Murphy'); -insert into owner values ('C093', 'Tony Shaw');
8. Insertamos datos en la tabla property.
-insert into property values ('PG4', '6 Lawrence St, Glasgow', 350, 'C040'); -insert into property values ('PG16', '5 Novar Dr, Glasgow', 450, 'C093'); -insert into property values ('PG36', '2 Manor Rd, Glasgow', 375, 'C093'); 9. Insertamos datos en la tabla rental. - insert into rental values ('CR76','C040','PG4','2003-06-01','2004-08-31'); -insert into rental values ('CR76','C093','PG16','2004-09-01','2005-09-01'); - insert into rental values ('CR56','C040','PG4','2002-09-01','2003-06-10'); - insert into rental values ('CR56','C093','PG36','2003-10-10','2004-12-01'); - insert into rental values ('CR56','C093','PG16','2005-11-01','2006-08-10'); CONSULTAS
1. Select propertyNo,ownerNo from property;
3. select count('PG16') from rental,owner where rental.ownerNo = owner.ownerNO
and owner.oName = 'Tony Shaw';
4. select clientNo, propertyNo from rental;
5. select cliente.cName, rental.propertyNo from rental, cliente where ownerNo='C040' and rental.clientNo=cliente.clientNo;
6. insert into cliente values('CR80','Andrea Rios');
insert into owner values('C07','Antonio Ramirez');
insert into rental values ('CR80','C093','PG36','2022-05-11','2023-05-10'); insert into rental values ('CR80','C093','PG36','2024-05-11','2025-05-10'); INSERT INTO property values('PG37','Juan Ruiz de Alarcon No.820',null,'C07');
7. select propertyNo , count(propertyNo) AS TOTAL FROM rental group by
propertyNo ORDER BY total DESC; 8. select propertyNo , count(propertyNo) AS TOTAL FROM rental group by propertyNo ORDER BY total DESC;