Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

MOBILE MANAGEMENT SYSTEM

DDL COMMANDS
-- Distributor Info table

CREATE DATABASE mobile_db;

USE mobile_db;

create table Distributor

Distributor_ID varchar(10) ,

Distributor_Name varchar(20),

Address varchar(100),

Mobile BIGINT(10),

Email varchar(30), constraint pk_distributor primary key(Distributor_ID) );


-- Mobile master table

create table Mobile_Master

IME_No varchar(10), Model_Name varchar(20), Manufacturer varchar(20), Date_Of_Manufac date,

Warranty_in_Years INT, Price DECIMAL(7,2), Distributor_ID varchar(10),

constraint pk_ime primary key(IME_No),foreign key(Distributor_ID) references


Distributor(Distributor_ID)

);

-- Mobile specification table

create table Mobile_Specification

IME_No varchar(10), Dimension varchar(20), Weight varchar(20),Display_Type varchar(20),


Display_Size varchar(20),

Internal_mem_in_MB INT, Memory_Card_Capacity_GB INT, Network_3G varchar(5),GPRS varchar(5),


EDGE varchar(5), Bluetooth varchar(5),

Camera varchar(5), Camera_Quality varchar(5) , OS varchar(20), Battery_Life_Hrs INT ,

constraint fk_ime foreign key(IME_No) references Mobile_Master(IME_No)

);

-- Customer Information table

create table Customer_Info

Customer_ID varchar(10) ,

Customer_Name varchar(20),
Address varchar(100),

Mobile BIGINT(10),

Email varchar(30),constraint pk_customer primary key(Customer_ID));

-- Sales information table

create table Sales_Info

SalesId INT,

Sales_Date date,IME_No varchar(10),Price INT,Discount INT,Net_Amount INT,Customer_ID


varchar(10),Model_Name varchar(20),

constraint fk_sales primary key(SalesId),foreign key(Customer_ID) references


Customer_Info(Customer_ID), foreign key(IME_No) references Mobile_Master(IME_No));

DML COMMANDS

-- Data for Distributor table

insert into Distributor values('D001','AXA Ltd','4th Floor CDG


Avenue',9897874563,'[email protected]');

insert into Distributor values('D002','KK Ditributors','Rajiv Gandhi


Salai,Chennai',9112225632,'[email protected]');

insert into Distributor values('D003','Vasanth Traders','NDR


Building,Chennai',9844555883,'[email protected]');

-- Data for Mobile_Master table

insert into Mobile_master values('MC1000100','Nokia C5-03','Nokia','2005-05-11',1,9500,'D001');

insert into Mobile_master values('MC1000102','Nokia Lumia','Nokia','2011-08-16',2,35350,'D001');

insert into Mobile_master values('MC1000103','Samsung GalaxyTAB','Samsung','2010-05-


06',2,32338,'D001');

insert into Mobile_master values('MC1000104','Samsung Galaxy Y','Samsung','2010-05-


19',1,24569,'D001');
insert into Mobile_master values('MC1000105','Nokia 5230','Nokia','2003-03-09',1,6123,'D002');

insert into Mobile_master values('MC1000106','Samsung C3010','Samsung','2005-04-


19',1,4000,'D002');

insert into Mobile_master values('MC1000107','Sony Experia','Sony Erricson','2011-05-


30',1,16500,'D003');

insert into Mobile_master values('MC1000108','Nokia 1100','Nokia','2001-03-01',1,2100,'D003');

insert into Mobile_master values('MC1000109','Nokia C5-03','Nokia','05-03-09',1,9500,'D001');

insert into Mobile_master values('MC1000110','Samsung GalaxyTAB','Samsung','2010-06-


05',2,32338,'D002');

insert into Mobile_master values('MC1000111','Nokia C5-03','Nokia','2005-03-09',1,9500,'D001');

-- Data for Mobile_Specification

insert into Mobile_Specification values('MC1000100','105.8 x 51 x 13.8 mm','93g','TFT


touchscreen','360 x 640 pixels',128,16,'Yes','Yes','Yes','Yes','Yes','5MP','Symbian OS v9.4',600);

insert into Mobile_Specification values('MC1000102','116.5 x 61.2 mm','142g','AMOLED


touchscreen','480 x 800 pixels',512,16,'Yes','Yes','Yes','Yes','Yes','8MP','Windows 7.5 Mango',210);

insert into Mobile_Specification values('MC1000103','256.6x175.3 x 9.7 mm','581g','PLS TFT


touchscreen','800 x 1280 pixels',1024,32,'Yes','Yes','Yes','Yes','Yes','3.5MP','Android OS, v4.0.3',320);

insert into Mobile_Specification values('MC1000104','109.8 x 60 x 12 mm','109g','TFT


touchscreen','240 x 320 pixels',160,32,'Yes','Yes','Yes','Yes','Yes','3.5MP','Android OS, v2.3',360);

insert into Mobile_Specification values('MC1000105','108 x 43.5 x 10.5 mm','78g','TFT, 256K


colors','240 x 320 pixels',30,8,'No','Yes','Yes','Yes','Yes','2MP','Nokia OS',406);

insert into Mobile_Specification values('MC1000106','76 x 43.5 x 7.5 mm','82g','TFT,65K colors','120 x


120 pixels',10,2,'No','Yes','Yes','Yes','Yes','VGA','SOS',1200);

insert into Mobile_Specification values('MC1000107','256.6x175.3 x 9.7 mm','95g','TFT


touchscreen','240 x 320 pixels',160,16,'Yes','Yes','Yes','Yes','Yes','5MP','Android OS, v2.3',390);

insert into Mobile_Specification values('MC1000108','76 x 43.5 x 7.5 mm','82g','TFT,65K colors','120 x


120 pixels',10,2,'No','No','No','No','No','VGA','Nokia OS',1200);

-- Data for Customer_Info table


insert into Customer_Info values('C001','Shyam',' No.3/5,serene flats Chennai-
96',9962100341,'[email protected]');

insert into Customer_Info values('C002','Asha',' No.6/2, Gandhi Nagar, Adyar Chennai-


20',8952100123,'[email protected]');

insert into Customer_Info values('C003','Mano',' No.12, Camp Road,Tambaram Chennai-


80',9841400341,'[email protected]');

insert into Customer_Info values('C004','Naresh',' No.46,Lotus Garden,Kilpauk Chennai-


32',8962122346,'[email protected]');

-- Data for Sales_Info table

insert into Sales_Info values(1001,'2012-04-20','MC1000100',9500,2000,7500,'C001','Nokia C5-03');

insert into Sales_Info values(1002,'2012-04-21','MC1000102',35350,350,35000,'C001','Nokia Lumia');

insert into Sales_Info values(1003,'2012-04-21','MC1000103',32338,338,32000,'C002','Samsung


GalaxyTAB');

insert into Sales_Info values(1004,'2012-04-22','MC1000104',32338,338,32000,'C003','Samsung Galaxy


Y');

insert into Sales_Info values(1005,'2012-04-23','MC1000105',6123,123,6000,'C004','Nokia 5230');

insert into Sales_Info values(1006,'2012-04-23','MC1000108',2100,100,2000,'C003','Nokia 1100');

insert into Sales_Info values(1007,'2012-04-23','MC1000109',2100,100,2000,'C003','Nokia C5-03');

insert into Sales_Info values(1008,'2012-04-23','MC1000111',2100,100,2000,'C003','Nokia C5-03');

QUESTIONS AND ANSWERS


Simple Questions:

Problem # 1: WAQ to Display the mobile details such as IMENO, Model Name produced by the
manufacturer "Nokia".

Solution: select IME_NO,Model_Name from mobile_master where manufacturer='Nokia';

Problem # 2: WAQ to display IMENO, Model Name,Manufacturer,Camerea Quality of mobiles whose


camera quality is 5MP.
Solution: select m1.ime_no,m1.model_name,m1.manufacturer,m2.camera_quality from
mobile_master m1 join mobile_specification m2 on m1.ime_no=m2.ime_no where
m2.camera_quality='5MP';

Problem # 3: WAQ to display Model Name,Quantity sold on the date 25-APR-12.

Solution: select model_name,count(ime_no) from sales_info where sales_date='23-APR-12' group by


model_name;

Problem # 4: WAQ to display distributor id ,mobile supply details such as mobile model name, quantity
supplied in sorted order of distributor id.

Solution: select Distributor_ID,Model_Name,count(Model_Name) from Mobile_Master group by


Distributor_ID,Model_Name order by Distributor_id;

Problem # 5: WAQ to display the IMENO,model name,manufacturer,price and discount of all mobiles
regardless of whether the mobile is sold or not.

Solution: select m1.ime_no,m1.model_name,m1.manufacturer,m1.price,s.discount from


mobile_master m1 left outer join sales_info s on m1.ime_no=s.ime_no;

Problem # 6: WAQ to display the distributor details such as distributor name,mobile number and email
of the model 'Nokia 1100'.

Solution: select Distributor_Name,Mobile from Distributor where Distributor_Id=(select distributor_id


from mobile_master where model_name='Nokia 1100');

Problem # 7: WAQ to display the Ime No and Model Name of mobiles which are not sold(Hint : use
minus operator)

Solution: select ime_no ,model_name from mobile_master minus select ime_no ,model_name from
sales_info;

Problem # 8: WAQ to display the Ime No and Model Name of mobiles which are sold(Hint : use intersect
operator)

Solution: select ime_no ,model_name from mobile_master intersect select ime_no ,model_name from
sales_info;

Problem # 9: WAQ to display the ImeNO, Model Name,Manufacturer, Price and NewPrice of all mobiles.

(Hint : find new price as 10% of the price with column name "New Price")

Solution: select ime_no,model_name,manufacturer,price,price+(price*10/100) "New Price" from


mobile_master;
Problem # 10: WAQ to display mobile model, manufacturer and price for the mobiles having a price
range from 8500 to 25300.

Solution: select model_name,manufacturer,price from mobile_master where price between 8500 and
25300;

Average Questions:

Problem # 1: WAQ to display the Model Name,Manufacturer, Price , Warranty , Internal memory,
memory card capacity,gprs support,bluetooth,camera quality and OS for the mobile with IME NO
"MC1000104" .

Solution: select
m1.model_name,m1.manufacturer,m1.warranty_in_years,m1.price,m2.Internal_mem_in_MB,m2.Mem
ory_Card_Capacity_GB, m2.GPRS,m2.Bluetooth,m2.Camera_Quality,m2.OS from mobile_master m1
join mobile_specification m2 on m1.IME_No=m2.IME_No where m1.IME_no='MC1000104';

Problem # 2: WAQ to display IMENO, Model Name,Manufacturer,Price ,GPRS information,Memory card


support of mobiles which has GPRS support with memory card capacity 16GB or above.

Solution: select
m1.ime_no,m1.model_name,m1.manufacturer,m1.price,m2.gprs,m2.Memory_Card_Capacity_GB from
mobile_master m1 join mobile_specification m2 on m1.ime_no=m2.ime_no where m2.GPRS='Yes' and
m2.Memory_Card_Capacity_GB>=16;

Problem # 3: WAQ to display the customer name ,mobile purchase details such as IMENO,Model
Name ,Purchase Date,Net amount paid in sorted order of customer name.

Solution: select c1.Customer_Name,m1.IME_NO,m1.Model_Name,m1.Sales_Date,m1.Net_Amount


from Customer_Info c1 join Sales_info m1 on m1.Customer_ID=c1.Customer_ID order by
c1.Customer_Name;

Problem # 4: WAQ to display the distributor details such as distributor id ,name ,address,contact no who
has supplied the maximum number of mobiles.

Solution: select distributor_id,distributor_name,address,mobile,email from distributor where


distributor_id=(select distributor_id from mobile_master having count(distributor_id)=(select
max(count(distributor_id)) from mobile_master group by distributor_id ) group by distributor_id);

Problem # 5: WAQ to display the IMENO,model name,manufacturer,price and discount of all mobiles
regardless of whether the mobile is sold or not.

[Hint: If not sold, display discount as "Not Sold"]


Solution: select m1.ime_no,m1.model_name,m1.manufacturer,m1.price,nvl(to_char(m2.discount),'Not
Sold') "discount" from mobile_master m1 left outer join sales_info s on m1.ime_no=s.ime_no;

Problem # 6: WAQ to display the report containing the sales date and total sales amount of the dates
between 20-APR-12 and 25-APR-12.

(Hint : total sales amount column should be displayed as "Total Sales Amount" )

Solution: select sales_date,sum(net_amount) "Total Sales Amount" from sales_info

where sales_date between '20-APR-12' and '25-APR-12' group by sales_date;

Problem # 7: WAQ to display mobile imeno,model name,manufacturer and price of the mobiles which
are having the longest battery life.

Solution: select ime_no,model_name,manufacturer,price from mobile_master where ime_no in(select


ime_no from mobile_specification where battery_life_hrs=(select max(battery_life_hrs) from
mobile_specification));

Problem # 8: WAQ to display the ImeNO, Model Name,Manufacturer, Price of mobiles having the
maximum price.

Solution: select ime_no,model_name,manufacturer,price from mobile_master where ime_no in(select


ime_no from mobile_master where price=(select max(price) from mobile_master));

Problem # 9: WAQ to display the customer details such as Customer ID,Customer Name, Address, Total
Purchase amount.

Solution: select c1.Customer_ID,c1.Customer_Name,c1.Address,(select sum(Net_Amount) from


sales_info where Customer_id=c1.Customer_ID) ”Total Purchase Amount" from Customer_info c1;

Problem # 10: WAQ to display the most costly mobile information such as mobile model, manufacturer
and price manufactured by "Samsung".

Solution: s

Complex Questions:

•Problem # 1: WAQ to display the customer details such as Customer ID,Customer Name, Address and
Total Purchase amount having the maximum purchase amount.

Solution: select Customer_ID,Customer_Name,Address from customer_info where customer_id=(select


customer_id from sales_info having sum(Net_Amount)=(select max(sum(net_amount)) from sales_info
group by customer_id) group by customer_id);
Problem # 2: WAQ to determine whether the mobile with ime no "MC1000105" is been sold out or not
and display the model name,sales status.(Hint: If sold display status as "Sold Out" with column name
"Sales Status").

Solution: select model_name,(select 'Sold Out' from sales_info where ime_no='MC1000105')"Sales


Status" from mobile_master where ime_no='MC1000105' ;

Problem # 3: WAQ to display the mobile information such as ime no,model


name,manufacturer ,distributor id ,distributor name and price supplied by the distributor named
'AXA Ltd' .

Solution: select
m1.ime_no,m1.model_name,m1.manufacturer,d1.distributor_id,d1.distributor_name,m1.price from
mobile_master m1 join distributor d1 on m1.distributor_id=d1.distributor_id and
d1.distributor_id=(select distributor_id from distributor where distributor_name='AXA Ltd');

Problem # 4: WAQ to display distributor details who supplies mobile with the following speficiations
such as 3G Network, Android OS, 5 MP Camera.

Solution: select distributor_id,distributor_name,address,mobile from distributor where distributor_id


IN (select distributor_id from mobile_master where ime_no IN (select ime_no from mobile_specification
where network_3g='Yes' and os LIKE '%Android%' and camera_quality='3.5MP' ));

Problem # 5: WAQ to Display the maximum sold mobile model name and manufacturer .

Solution: select distinct model_name,manufacturer from mobile_master where model_name=(select


model_name from sales_info having count(model_name)=(select max(count(model_name))from
sales_info group by model_name)group by model_name)

You might also like