0% found this document useful (0 votes)
55 views16 pages

Assignment 8:: Desc Branch - Ece - 3B - 64

The document contains SQL commands to create tables for a logistics database including tables for customers, trucks, cities, parts, and shipments. Data is inserted and queries are written to retrieve shipment numbers where the start city population is

Uploaded by

Dibyajit Sen
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)
55 views16 pages

Assignment 8:: Desc Branch - Ece - 3B - 64

The document contains SQL commands to create tables for a logistics database including tables for customers, trucks, cities, parts, and shipments. Data is inserted and queries are written to retrieve shipment numbers where the start city population is

Uploaded by

Dibyajit Sen
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/ 16

ASSIGNMENT 8:

create table branch_ece_3B_64(branch_ece_3B_64_name char(20) primary key,branch_city char(20)


,assets number(20));

desc branch_ece_3B_64;

create table customer_ece_3B_64(customer_name char(20) primary key,street_name char(20) ,city


char(20));

desc customer_ece_3B_64;

create table loan_ece_3B_64(branch_name char(20) primary key,loan_no number(20) ,amount


number(20));

desc loan_ece_3B_64;

create table borrower_ece_3B_64(customer_name char(20), loan_no number(20) primary key );

desc borrower_ece_3B_64;
create table account_ece_3B_64(branch_name char(20) ,account_number number(20) primary key
,balance number(20));

desc account_ece_3B_64;

create table depositer_ece_3B_64(customer_name char(20) primary key,account_number number(20));

desc depositer_ece_3B_64;

insert into branch_ece_3B_64 values('pnb warisnagar','samastipur',20000000000000);

insert into branch_ece_3B_64 values('SBI kankarbaagh','patna',40000000000000);

insert into branch_ece_3B_64 values('ubi jamsedpur','ranchi',60000000000000);

insert into branch_ece_3B_64 values('icici cp','delhi',80000000000000);

insert into branch_ece_3B_64 values('kotak newtown','kolkata',70000000000000);

insert into branch_ece_3B_64 values('Axis','ruby', 901234);


select * from branch_ece_3B_64;

insert into customer_ece_3B_64 values('arun','a block street','samastipur');

insert into customer_ece_3B_64 values('sanju','g block street','patna');

insert into customer_ece_3B_64 values('ram','chowk street','ranchi');

insert into customer_ece_3B_64 values('shayam','b block street','delhi');

insert into customer_ece_3B_64 values('sita','z block street','kolkata');

select * from customer_ece_3B_64;

insert into loan_ece_3B_64 values('pnb warisnagar',12, 500000);

insert into loan_ece_3B_64 values('SBI kankarbaagh',14, 200000);

insert into loan_ece_3B_64 values('ubi jamsedpur',16, 700000);

insert into loan_ece_3B_64 values('icici cp',10, 800000);

insert into loan_ece_3B_64 values('kotak newtown',8, 400000);

select * from loan_ece_3B_64;


insert into borrower_ece_3B_64 values('arun',12);

insert into borrower_ece_3B_64 values('sanju',14);

insert into borrower_ece_3B_64 values('ram',16);

insert into borrower_ece_3B_64 values('shayam',10);

insert into borrower_ece_3B_64 values('sita',8);

select * from borrower_ece_3B_64;

insert into account_ece_3B_64 values('pnb warisnagar',123456,125000);

insert into account_ece_3B_64 values('SBI kankarbaagh',123457,325000);

insert into account_ece_3B_64 values('ubi jamsedpur',123458,175000);

insert into account_ece_3B_64 values('icici cp',123459,155000);

insert into account_ece_3B_64 values('kotak newtown',123450,225000);

select * from account_ece_3B_64;


insert into depositer_ece_3B_64 values('arun',123456);

insert into depositer_ece_3B_64 values('sanju',123457);

insert into depositer_ece_3B_64 values('ram',123458);

insert into depositer_ece_3B_64 values('shayam',123459);

insert into depositer_ece_3B_64 values('sita',123450);

select * from depositer_ece_3B_64;

A) Give the customer name who has an account but not any loan.

COMMANDS –

select c.customer_name as Name from customer_ece_3B_64 c left join borrower_ece_3B_64 b on


c.customer_name = b.customer_name where c.customer_name not in (select customer_name from
borrower_ece_3B_64);

output:-
B)Give the name of the customer who has entire(100000-200000) or (300000-400000) in their account.

COMMANDS-

select c.customer_name from customer_ece_3B_64 c

left join depositer_ece_3B_64 d

on d.customer_name = c.customer_name

left join account_ece_3B_64 a

on a.account_number = d.account_number

where a.balance between 100000 and 200000 or a.balance between 300000 and 400000;

output:-
C)Which branch has issued maximum amount of loan?

COMMANDS-

select branch_name from loan_ece_3B_64

where amount = (select max(amount) from loan_ece_3B_64);

output:-

D)Give the name of the customer who has maximum balance in their account.

COMMANDS-

select c.customer_name from customer_ece_3B_64 c

left join depositer_ece_3B_64 d

on d.customer_name = c.customer_name

left join account_ece_3B_64 a

on a.account_number = d.account_number

where a.balance= (select max(balance) from account_ece_3B_64);

output:-
E) Give the name of the customer who has opened an account in a city in which he is not located.

COMMANDS-

select * from customer_ece_3B_64 c

left join depositer_ece_3B_64 d

on d.customer_name = c.customer_name

left join account_ece_3B_64 a

on a.account_number = d.account_number

left join branch_ece_3B_64 b

on b.branch_name = a.branch_name

where c.city not like (b.branch_city);

output:-
ASSIGNMENT 9:

create table CUSTOMER_3B_64(cust_id number primary key,cust_name varchar(20),annual_revenue


number);

desc CUSTOMER_3B_64;

create table TRUCK_3B_64(truck_no number primary key,driver_name varchar(20));

desc TRUCK_3B_64;

create table CITY_3B_64(city_name varchar(20) primary key,population number);

desc CITY_3B_64;

create table PARTS_3B_64(p_no number primary key,p_name varchar(20),color varchar(20));

desc PARTS_3B_64;
create table SHIPMENT_3B_64(ship_no number primary key,cust_id number references
CUSTOMER_3B_64(cust_id),weight number,truck_no number references TRUCK_3B_64(truck_no),p_no
number references PARTS_3B_64(p_no),start_city varchar(20) references
CITY_3B_64(city_name),destination_city varchar(20));

desc SHIPMENT_3B_64;

insert into CUSTOMER_3B_64 values('11','maya','140000');

insert into CUSTOMER_3B_64 values('12','sita','50000');

insert into CUSTOMER_3B_64 values('13','shyam','110000');

insert into CUSTOMER_3B_64 values('14','deepak','160000');

insert into CUSTOMER_3B_64 values('55','ram','120500');

select * from CUSTOMER_3B_64 ;


insert into TRUCK_3B_64 values('101','deepu');

insert into TRUCK_3B_64 values('102','sayamu');

insert into TRUCK_3B_64 values('103','sumit');

insert into TRUCK_3B_64 values('104','ratan');

insert into TRUCK_3B_64 values('105','rohit');

insert into TRUCK_3B_64 values('106','krishna');

select * from TRUCK_3B_64 ;

insert into CITY_3B_64 values('kolkata','80000');

insert into CITY_3B_64 values('mumbai','50000');

insert into CITY_3B_64 values('SAMASTIPUR','90000');

insert into CITY_3B_64 values('patna','9000');


insert into CITY_3B_64 values('delhi','75000');

select * from CITY_3B_64 ;

insert into PARTS_3B_64 values('911','switch','red');

insert into PARTS_3B_64 values('912','switch','blue');

insert into PARTS_3B_64 values('913','leather','brown');

insert into PARTS_3B_64 values('914','leather','black');

insert into PARTS_3B_64 values('915','leather','red');

insert into PARTS_3B_64 values('916','tapes','black');

select * from PARTS_3B_64 ;

insert into SHIPMENT_3B_64 values(1001,12,600,103,914,'kolkata','mumbai');

insert into SHIPMENT_3B_64 values('1002','11','500','101','915','kolkata','chennai');


insert into SHIPMENT_3B_64 values('1003','14','200','102','916','patna','chennai');

insert into SHIPMENT_3B_64 values('1004','12','450','105','911','kolkata','mumbai');

insert into SHIPMENT_3B_64 values('1005','13','670','106','912','chennai','mumbai');

insert into SHIPMENT_3B_64 values('1006','14','300','102','913','kolkata','bhubaneswar');

insert into SHIPMENT_3B_64 values('1007','12','200','104','915','SAMASTIPUR','mumbai');

select * from SHIPMENT_3B_64 ;

A)Give shipment number for which the population of start_city is greater than the
population of the destination_city.

COMMANDS—

select s.ship_no from SHIPMENT_3B_64 s left join city_3B_64 a on s.start_city=a.city_name left join
city_3B_64 b on s.destination_city =b.city_name where a.population > b.population;
B)Give the shipment number for which the annual_revenue of the customer is greater tha
120000,part color is red and population of both the start_city and destination_city is
more than 70000.

COMMANDS—

select ship_no from SHIPMENT_3B_61,CUSTOMER_3B_61 where


CUSTOMER_3B_64.cust_id=SHIPMENT_3B_64.cust_id and annual_revenue>120000;

select ship_no from SHIPMENT_3B_64,PARTS_3B_64 where


PARTS_3B_64.p_no=SHIPMENT_3B_64.p_no and color='red';

c )Give the count of the shipments for each driver where the weight is more tha 400.

COMMANDS—

select count(*)from TRUCK_3B_64,SHIPMENT_3B_64 where


SHIPMENT_3B_61.truck_no=TRUCK_3B_61.truck_no and SHIPMENT_3B_61.weight>400;
D) Give the name of the customer who participated in maximum number of shipments.

COMMANDS—

select cust_name from CUSTOMER_3B_64 where cust_id=(select cust_id from SHIPMENT_3_64 group
by cust_id having count(ship_no)=(select max(count(ship_no))from SHIPMENT_3B_64 group by
cust_id));

E) Give the name of the cities, which has no entry in start_city

COMMANDS—

select city_name from CITY_3B_64 where city_name NOT IN(select start_city from SHIPMENT_3B_64);
UNIVERSITY OF ENGINEERING & MANAGEMENT,

KOLKATA

Database Management System Project

NAME:- Dibyajit sen


STREAM:- ECE
SEMESTER:- 5TH
SECTION:- 3B
CLASS ROLL:- 64
ENROLLMENT No:- 12017009002149

____________________
Teacher’s signature

You might also like