AIM:- To perform following queries in PL/SQL using create , insert, select,
desc, distinct command. Query: Create a table branch_master having the follwing fields. Column name Datatype Size branch_no Varchar2 10 name Varchar2 25 f_name Varchar2 25 m_name Varchar2 25 Dob Date - address Varchar2 40 City Varchar2 10 state Varchar2 12
Query: Insert 5 element & give output of following queries. SQL> insert into branch_master values ('1','Reshma','Yogeshbhai','Savitaben','01-JAN-91','Bapu Bazaar' ,'Udaipur','Rajasthan'); 1 row created.
SQL> insert into branch_master values ('2','Sweta','Rameshbhai','Kavitaben','21-FEB-96','Chetak', 'Udaipur','Rajasthan'); 1 row created.
SQL> insert into branch_master values ('3','Hetal','Vinodbhai','Ranjanben','25-OCT-89','Kalpvrux', 'Baroda','Rajasthan'); 1 row created.
SQL> insert into branch_master values ('4','Vraj','Rajdeepsinh','Varshaben','14-FEB-10','Drive-In', 'Ahmedabad','Gujrat'); 1 row created. SQL>insert into branch_master values ('5','Parth','Ravibhai','Veenaben','25-SEP-92','Dabok', 'Udaipur','Rajasthan'); 1 row created.
Query: View all the content of the table SQL> select * from branch_master; B_NO NAME F_NAME M_NAME DOB ADDRESS CITY STATE --------- ---------------- ------------------- -------------------- ----------------- --------------------- ----------------- ------------ 1 Reshma Yogeshbhai Savitaben 01-JAN-91 Bapu Bazaar Udaipur Rajasthan 2 Sweta Rameshbhai Kavitaben 21-FEB-96 Chetak Udaipur Rajasthan 3 Hetal Vinodbhai Ranjanben 25-OCT-89 Kalpvrux Baroda Rajasthan 4 Vraj Rajdeepsinh Varshaben 14-FEB-10 Drive-In Ahmedabad Gujrat 5 Parth Ravibhai Veenaben 25-SEP-92 Dabok Udaipur Rajasthan
Query: Use like operator & show name,state,& show name, state, city, of the person whose second word is _e. SQL> select name,state,city from branch_master where name like '_e%'; NAME STATE CITY ----------------------- -------------------- --------------------- Reshma Rajasthan Udaipur Hetal Rajasthan Baroda
Query: Use in operation and show name , state, city of the person who live in udaipur SQL> select name,state,city from branch_master where city in('Udaipur'); NAME STATE CITY ------------------------- --------------- ---------- Reshma Rajasthan Udaipur Sweta Rajasthan Udaipur Parth Rajasthan Udaipur
Query: Use like operator & show name,state,& show name, state, city, of the person where name start with s. SQL> select name,state,city from branch_master where name like 'S%'; NAME STATE CITY ------------------------- --------------- -------- Sweta Rajasthan Udaipur
Query: Use between operator to show name & dob of a person having dob between 1-1- 1990 and 1-1-1997. SQL> select name,dob from branch_master where dob between '1-JAN-90' and '1-JAN-97'; NAME DOB ------------------------- --------- Reshma 01-JAN-91 Sweta 21-FEB-96 Parth 25-SEP-92
Query: Use not between operator to show name & dob of a person having dob between 1- 1-1999 and 1-1-2007. SQL> select name,dob from branch_master where dob not between '1-JAN-97' and '1-JAN-07'; NAME DOB --------------------------- --------- Reshma 01-JAN-91 Sweta 21-FEB-96 Hetal 25-OCT-89 Vraj 14-FEB-10 Parth 25-SEP-92
Query: view all the existing tables in your system database. SQL> select * from tab; PRODUCT_MASTER TABLE BRANCH_MASTER TABLE CLIENT_SERVENT TABLE 3 rows selected.
Query: View all the discription of the table branch_master. SQL> DESC branch_master; Name Null? Type ----------------------------------------- -------- ---------------------------- B_NO VARCHAR2(10) NAME VARCHAR2(25) F_NAME VARCHAR2(25) M_NAME VARCHAR2(25) DOB DATE ADDRESS VARCHAR2(25) CITY VARCHAR2(10) STATE VARCHAR2(12)
Query: View all the detail from the branch_master and use distinct command in it. SQL> select distinct b_no,name,f_name,m_name, dob,address,city,state from branch_master; B_NO NAME F_NAME M_NAME DOB ADDRESS CITY STATE --------- ---------------- ------------------- -------------------- ----------------- --------------------- ----------------- ------------ 1 Reshma Yogeshbhai Savitaben 01-JAN-91 Bapu Bazaar Udaipur Rajasthan 2 Sweta Rameshbhai Kavitaben 21-FEB-96 Chetak Udaipur Rajasthan 3 Hetal Vinodbhai Ranjanben 25-OCT-89 Kalpvrux Baroda Gujrat 4 Vraj Rajdeepsinh Varshaben 14-FEB-10 Drive-In Ahmedabad Gujrat 5 Parth Ravibhai Veenaben 25-SEP-92 Dabok Udaipur Rajasthan
EXPERIMENT NO :- 2 AIM:- To Perform following SQL query using update, delete, re-name command. Creating Tables Query: Create table client_master having following fields. Coloumn Name Data Type Size client_no varchar2 6 Name varchar2 25 p_address varchar2 40 t_address varchar2 40 City varchar2 20 pin_code number 10 State varchar2 20 bal_due number 10
Query: Create table product_master having following fields. Coloumn Name Data Type Size p_no varchar2 10 Description varchar2 15 unit_mes varchar2 8 sell_price number 10 cost_price number 10
SQL> create table product_master (p_no varchar2(10),discription varchar2(15),unit_mes varchar2(8), sell_price number(10),cost_price number(10)); Table created. Query: Create table client_master having following fields. Coloumn Name Data Type Size s_no varchar2 10 Name varchar2 25 p_address varchar2 30 t_address varchar2 30 pin_code number 10 State varchar2 20
Inserting Values into the table product_master. SQL> insert into product_master values ('p001','T-shirt','M',750,350); 1 row created. SQL> insert into product_master values ('p002','Jeans','30in',1500,750); 1 row created. SQL> insert into product_master values ('p003','Dress','S',900,350); 1 row created. SQL> insert into product_master values ('p004','Shirt','M',799,265) 1 row created. SQL> insert into product_master values ('p005','AXE Body Spray','100ml',180,100); 1 row created.
Inserting Values into the table sell_master SQL>insert into sell_master values ('s001','Jaykant','Aamchi mumbai','Goa',254625,'Maharastra', 10000); 1 row created. SQL> insert into sell_master values ('s002','Gautam','Chatak','Goa',362542,'Rajasthan',20000); 1 row created. SQL> insert into sell_master values ('s003','Raviraj','Udaipur','Ratlam',362549,'Rajasthan', 25000); 1 row created. SQL>insert into sell_master values ('s004','Vraj','Ahmedabad','Udaipur',382426,'Gujrat', 100000000); 1 row created. SQL> insert into sell_master values ('s005','Vijay','Godhavi','Ahmedabad',382469,'Gujrat',1 0000); 1 row created.
Retriving Values from the tables. Query : Find out name of all the clients. SQL> select name from client_master; NAME ------------------------- Rocky Gaurav Gunjan Satyam Bajirav
Query : Retrive the entire components of client_master. SQL> select * from client_master; CLIENT_NO NAME P_ADDRESS T_ADDRESS CITY PINCODE STATE BAL_DUE ------------------------------------------------------------------------------------------------------------------------------- c001 Rocky Ahmedabad Udaipur Udaipur 363521 Rajasthan 10000 c002 Gaurav Baroda Bapu Bazaar Udaipur 362535 Rajasthan 12000 c003 Gunjan Udaipur Mumbai Mumbai 362549 Maharastra 15000 c004 Satyam Aamchi mumbai Juhu Mumbai 365423 Maharastra 12300 c005 Bajirav Shivghadh Goa Nashik 362548 Maharastra 15300
Query : Retrive list of the name,state & city of all the clients. SQL> select name,state,city from client_master; NAME STATE CITY ------------------------- -------------------- -------------------- Rocky Rajasthan Udaipur Gaurav Rajasthan Udaipur Gunjan Maharastra Mumbai Satyam Maharastra Mumbai Bajirav Maharastra Nashik Query : List various product available from product_master table. SQL> select discription from product_master; DISCRIPTION --------------- T-shirt Jeans Dress Shirt AXE Body Spray
Query : List all the clients who are located in Udaipur. SQL> select name from client_master where city='Udaipur'; NAME ------------------------- Rocky Gaurav
Query : Find the name of salesmen whose salary is 10000. SQL> select name from sell_master where salary=10000; NAME ------------------------- Jaykant Vijay Updating tables Query : Change the city of client whose client_no is c005 to Jaipur. SQL> update client_master set city='Jaipur' where client_no='c005'; 1 row updated. Query : Change the bal_due of client whose client_no is c001 to 1000rs. SQL> update client_master set bal_due=1000 where client_no='c001'; 1 row updated. Query : Change the cost_price of the T-shirt to 1000 . SQL> update product_master set cost_price=1000 where discription='T-shirt'; 1 row updated. Query : Change the city of client whose client_no is c003 to Pune SQL> update client_master set city='Pune' where client_no='c003'; 1 row updated.
Deleting Query : Delete all the salesmen from sell_master whose salary is 10000. SQL> delete from sell_master where salary=10000; 2 rows deleted. Query : Delete all the product from client_master where state having the value Maharastra SQL> delete from client_master where state='Maharastra'; 3 rows deleted.
Altering Tables Query : Add coloumn telephone number of datatype number and size 10 to client_master table. SQL> alter table client_master add (t_no number(15)); Table altered. Query : Change the size of sell_price in product_master table to 12. SQL> alter table product_master modify (sell_price number(12)); Table altered.
Deleting Tables Query : Delete the table sell_master also with its data. SQL> drop table sell_master; Table dropped.
Renaming Tables Query : Change the name of table client_master to client_servent. SQL> rename client_master to client_servent; Table renamed.
EXPERIMENT NO 3 AIM: To perform SQL query using join.
Create table product having following fields: Coloum name Datatype Size Constrains Serial_no Number 8 Primary key Description Varchar2 10 Name Varchar2 10 Unique City Varchar2 10 State Varchar2 10 Pincode Number 8
Create table product_detail having follwing fields: Coloum name Datatype Size Constrains Serial_no Number 8 Foreign key, reference product (serial_no) Name Varchar2 10 Product_sp Number 8 Product_cp Number 8
Insert values into the product and product_detail table. SQL>insert into product values(1,'T-shirt','DJ','Udaipur','Rajasthan',356482); 1 row created.
SQL>insert into product values(2,'Shirt','Pooma','Udaipur','Rajasthan',356482); 1 row created.
SQL>insert into product values(3,'Dress','Levis','Ahmedabad','Gujrat',382426); 1 row created.
SQL>insert into product_detail values(1,'DJ',1000,600); 1 row created.
SQL>insert into product_detail values(2,'Spikers',1500,900); 1 row created.
SQL>insert into product_detail values(3,'Raymond',2000,1100); 1 row created.
Join the table with equive join and retrive the table.
SQL> select * from product, product_detail where product.serial_no = product_detail.serial_no ; SERIAL DESCRIPTION NAME CITY STATE PINCODE SERIAL NAME PRODUCT PRODUCT _NO _NO _SP _CP
1 T-shirt DJ Udaipur Rajasthan 356482 1 DJ 1000 600 2 Shirt Pooma Udaipur Rajasthan 356482 2 Spikers 1500 900 3 Dress Levis Amedabad Gujrat 382426 3 Raymond 2000 1100
Using equive join display serial_no, name, description from table product and product_cp and product_sp from product_detail table. SQL> select product.serial_no, product.name, product.description, product_detail .product_cp, product_detail.product_sp from product, product_detail where produc t.serial_no = product_detail.serial_no ;
SERIAL_NO NAME DESCRIPTIO PRODUCT_CP PRODUCT_SP ---------- ---------- ---------- ---------- -------------------------------------------------------- 1 DJ T-shirt 600 1000
2 Pooma Shirt 900 1500 3 Levis Dress 1100 2000
EXPERIMENT NO - 4 AIM:- Write a program to implement Data Smoothening techniques using following methods on n elements. Also partition the Data into even depth bucket based on user choice.
Bin by boundary Bin by Mean Bin by Median
Code :-
#include<stdio.h> #include<conio.h>
void main() { int j,n,a,b[30],b1[30],b2[30],b3[30],k,i; clrscr(); printf("Enter no. of elements\n"); scanf("%d",&n); printf("Enter elements\n"); for(i=0;i<n;i++) { printf("Enter value for element %d ",i+1); scanf("%d",&b[i]); } for(i=0;i<n;i++) { for(j=0;j<n-i;j++) { if(b[j]>b[j+1]) { a=b[j]; b[j]=b[j+1]; b[j+1]=a; } } } printf("Sorted no. are \n"); for(i=0;i<n;i++) printf("%d\n",b[i]); printf("\nEnter size of bin"); scanf("%d",&k); for(i=0;i<n/k;i++)
{ for(j=1;j<k;j++) { if((b[j+(i)*k]-b[(i)*k])<(b[(i)*k+k-1]-b[(i)*k+j])) b1[(i)*k+j]=b[(i)*k]; else b1[(i)*k+j]=b[(i)*k+k-1]; } b1[(i)*k]=b[(i)*k]; b1[(i+1)*k]=b[(i)*k+k-1]; } printf("\nBy bin boundary no.s are\n"); for(i=0;i<n/k;i++) { for(j=0;j<k;j++) printf("%d",b1[(i)*k+j]); printf("\t"); } printf("\n"); for(i=0;i<n/k;i++) { for(j=0,a=0;j<k;j++) a=a+b[(i)*k +j]; a=a/5; for(j=0;j<k;j++) b2[(i)*k+j]=a; } printf("\nBy mean method no are \n"); for(i=0;i<n/k;i++) { for(j=0;j<k;j++) printf("%d",b2[(i)*k+j]); printf("\t"); } for(i=0,a=0;i<n/k;i++) { if(k%2==0) a=((b[(i)*k+k/2])+(b[(i)*k+k/2+1]))/2; else a=b[(i)*k+(k+1)/2]; for(j=0;j<k;j++) b3[(i)*k+j]=a; } printf("\nBy median method no are \n"); for(i=0;i<n/k;i++) { for(j=0;j<k;j++) printf("%d",b3[(i)*k+j]); printf("\t"); } getch();
}
OUTPUT Enter no. of elements 10 Enter elements Enter value for element 1 5 Enter value for element 2 2 Enter value for element 3 8 Enter value for element 4 12 Enter value for element 5 45 Enter value for element 6 2 Enter value for element 7 7 Enter value for element 8 1 Enter value for element 9 9 Enter value for element 10 10 Sorted no. are 1 2 2 5 7 8 9 10 12 45
Enter size of bin5
By bin boundary no.s are 11177 888845
By mean method no are 33333 1616161616 By median method no are 55555 1212121212
EXPERIMENT NO - 5 AIM:- Write a program to implement the data transformation techniques on given array.
Enter no.of elements : 5 Enter elements Enter Value for Element 0:12 Enter Value for Element 1:3 Enter Value for Element 2:67 Enter Value for Element 3:1 Enter Value for Element 4:2 Enter Normalisation limits: Min limit:0 Max limit:3 0.500000 0.090909 3.000000 0.000000 0.045455
by Z-score method : -0.197581 -0.553226 1.975806 -0.632258 -0.592742
EXPERIMENT NO - 6
AIM:- Write a program to check that two attributes are correlated using Pearson product coefficient.
CODE: #include <stdio.h> #include <conio.h> #include <math.h> void main() { int i,j; float a[100],b[100],n,am,bm,sa,sb,r; clrscr(); printf("enter no. of elements: "); scanf("%f" ,&n); printf("enter elements for a \n"); for(i=1;i<=n;i++) { printf("Elements %d: ",i); scanf("%f",&a[i]); }
if(r>0) printf("\n a & b are positively correlated \n"); else if(r==0) printf("a & b are independent"); else printf("\n a & b are negatively independent"); printf("\n %f",r); getch(); }
OUTPUT
enter no. of elements: 4 enter elements for a Elements 1: 12 Elements 2: 2 Elements 3: 3 Elements 4: 4 Enter elements for b Elements 1: 4 Elements 2: 6 Elements 3: 7 Elements 4: 9
a & b are negatively independent -0.682741
EXPERIMENT NO - 7 AIM:- Write a program to implement the Concept Hierarchy.
OBJECT: CODE: #include<stdio.h> #include<conio.h> int roundmin(int); int roundmax(int);
int itr(char *tab,char *str) { int i,j,count=0; for(i=0;i<9;i++) for(j=0;(j<5 && *(tab + 5*i+j))!='\0';j++) if(*(tab + 5*i+j)==str[0]) count++; return count; }
int itr2(char *tab, char a, char b) { int i,j,count=0,match; for(i=0;i<9;i++) { for(j=0,match=0;*(tab+i*5+j)!='\0';j++) { if(*(tab+i*5+j)==a) match++; else if(*(tab+i*5+j)==b) match++; } if(match==2) count++; } return count; }
int itr3(char *tab, char a, char b,char c) { int i,j,count=0,match; for(i=0;i<9;i++) { for(j=0,match=0;*(tab+i*5+j)!='\0';j++) { if(*(tab+i*5+j)==a) match++;