0% found this document useful (0 votes)
27 views

Student Id University Name

This document contains the ERD diagram, sample data, and 24 SQL queries for a database that stores information about buildings, apartments, and owners. The ERD diagram defines 3 tables: building, apartment, and owner. Sample data is inserted into these tables. The 24 queries perform operations like selecting, updating, joining, and deleting records to retrieve information from and manipulate the data in the tables.

Uploaded by

Ikram
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)
27 views

Student Id University Name

This document contains the ERD diagram, sample data, and 24 SQL queries for a database that stores information about buildings, apartments, and owners. The ERD diagram defines 3 tables: building, apartment, and owner. Sample data is inserted into these tables. The 24 queries perform operations like selecting, updating, joining, and deleting records to retrieve information from and manipulate the data in the tables.

Uploaded by

Ikram
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/ 14

STUDENT NAME

Student id
  University name
Contents
Introduction:.........................................................................................................................................2
ERD:.......................................................................................................................................................2
Sample Data:.........................................................................................................................................3
Queries:.................................................................................................................................................3
Introduction:
In this we have given an ERD diagram and the scenario and by using that we have to
generate the database of the system. The ERD is also in this file and the execution of the database is
also present in it.

ERD:
Sample Data:

Queries:
Task 1:

create table building(build_id number(10) primary key,build_name varchar(20),built_year


number(15),buliding_capacity number(15),building address varchar(20));

create table apartment(apart_id number(10), apart_rent number(10), total_rooms number(10),


building_id number(10), owner_id number(10));

create table owner(owner_id number(10) primary key, owner_fname varchar(10), owner_lname


varchar(10),owner_email varchar(20),owner_phone varchar(20));

Task 2:

insert into owner values(1,'zaisn','adads','[email protected]','01123456');

insert into owner values(2,'dsdd','dskdjs','[email protected]','01223456');

insert into owner values(3,'dssfd','dsadass','[email protected]','01243456');

insert into owner values(4,'dssvv','asadass','[email protected]','01253456');


insert into owner values(5,'johv','ahss','[email protected]','0125333456');

insert into building values(1,'mcla',2002,500,'van strt');

insert into building values(2,'lama',2001,300,'akm strt');

insert into building values(3,'akwn',2006,400,'anu strt');

insert into building values(4,'souths',2012,230,'mintu strt');

insert into building values(5,'anks',2003,550,'monu strt');

Task 3:

insert into apartment values(1,10,20,1,1);

insert into apartment values(2,20,30,2,2);

insert into apartment values(3,30,20,3,3);

insert into apartment values(4,40,30,4,4);

insert into apartment values(5,50,40,5,5);


insert into apartment values(6,60,50,6,6);

insert into apartment values(7,70,60,7,7);

insert into apartment values(8,80,70,8,8);

insert into apartment values(9,90,80,9,9);

insert into apartment values(10,100,90,10,10);

Task 4:

Select *from building;


Task 5:

Select build_name from building;

Task 6:

select build_name, buliding_capacity from building;


Task 7:

update building

2 set buliding_capacity=2000

3 where build_name='lilly pilly';

Task 8:

select build_id,build_name from building

2 where buliding_capacity>3000;

Task 9:

update apartment

2 set apart_rent = apart_rent+0.4

3 where building_id=4;
Task 10:

select *from apartment where owner_id= 2003;

Task 11:

select distinct building_address from building;

Task 12:

select build_name, built_year from building where built_year=2001;

Task 13:

select build_name, buliding_capacity from building where buliding_capacity <=2000 AND


buliding_capacity>=1000 order by buliding_capacity DESC;
Task 14:

select max(apart_id) as total_apartments from apartment;

Task 15:

select distinct owner_id, apart_id as total_appartment from apartment;

Task 16:

delete from owner where owner_fname='james';


Task 17:

select *from apartment join owner on owner.owner_fname='hazel';

Task 18:

select *from apartment

2 join building

3 on building.build_id=apartment.apart_id;
Task 19:

Select *from apartment where building_id=6;

Task 20:

select building.build_name from building join apartment on building.build_id=apartment.apart_id


where apartment.apart_id>4;
Task 21:

SQL> select owner.owner_id, owner.owner_fname from owner join apartment on


owner.owner_id=apartment.apart_id where apart_id=0;

Task 22:

select building.build_name from building join apartment on building.build_id=apartment.apart_id


where apartment.apart_rent<40;

Task 23:

select apartment.apart_id,apartment.apart_rent, owner.owner_fname from apartment join owner


on apartment.apart_id=owner.owner_id where apartment.apart_rent>=600;

Task 24:

select apartment.apart_id,apartment.apart_rent,building.build_name,apartment.owner_id from


apartment join building on apartment.apart_id=building.build_id;
The above given screenshots are the execution of the queries which is present into the part
1.

You might also like