Professional Documents
Culture Documents
BY
Mrs. UMADEVI M
LECTURER
COMPUTER SCIENCE & ENGINEERING
RJS POLYTECHNIC
BANGALORE-34.
1
DBMS & GUI LAB 3rd Sem CS 15CS36P
Exercise- 1 & 2
CREATE THE FOLLOWING TABLES FOR A COMPANY DATA BASE &
ILLUSTRATE THE USE OF CONSTRAINTS
1. EMPLOYEE 4. PROJECT
create table employee create table project
(fname varchar(9) not null, (pname varchar(9) not null,
minit char, pnumber int not null,
lname varchar(9) not null, plocation varchar(9),
ssn char(6) not null, dnum int not null,
bdate date, primary key(pnumber),
address varchar(20), unique (pname),
sex char, foreign key(dnum) references
salary int, department(dnumber));
superssn char(6) not null,
dno int not null, Table created
primary key(ssn),
foreign key(superssn) references 5. WORKS_ON
employee(ssn)); create table workson
(essn char(6) not null,
Table created pnumber int not null,
hours decimal(3,1) not null,
2. DEPARTMENT foreign key(essn) references employee(ssn));
create table department
( dname varchar(9) not null, Table created
dnumber int not null,
mgrssn char(6) not null, 6. DEPENDENT
mgrstartdate date, create table dependent
primary key(dnumber), (essn char(6) not null,
foreign key (mgrssn) references employee(ssn)); dependentname varchar(9) not null,
sex char,
Table created
bdate date,
3. DEPTLOCATION relationship varchar(8),
create table deptlocation primary key(essn,dependentname),
(dnumber int not null, foreign key(essn) references employee(ssn));
dlocation varchar(10) not null,
primary key(dnumber,dlocation), Table created
foreign key (dnumber) references
department(dnumber));
Table created
2
DBMS & GUI LAB (15CS36P) 2015 CURRICULLUM
SQL>desc employee
Table Column Data Type Length Precision Scale Primary Key Nullable Default Comment
EMPLOYEE FNAME Varchar2 9 - - - - - -
MINIT Char 1 - - - - -
LNAME Varchar2 9 - - - - - -
SSN Char 6 - - 1 - - -
BDATE Date 7 - - - - -
ADDRESS Varchar2 20 - - - - -
SEX Char 1 - - - - -
SALARY Number - - 0 - - -
SUPERSSN Char 6 - - - - - -
DNO Number - - 0 - - - -
1 - 10
Table Column Data Type Length Precision Scale Primary Key Nullable Default Comment
DNUMBER Number - - 0 1 - - -
MGRSSN Char 6 - - - - - -
MGRSTARTDATE Date 7 - - - - -
1-4
Commen
Table Column Data Type Length Precision Scale Primary Key Nullable Default t
DLOCATION Varchar2 10 - - 2 - - -
1-2
1-4
Desc dependent
SEX Char 1 - - - - -
BDATE Date 7 - - - - -
RELATIONSHIP Varchar2 8 - - - - -
1-5
Desc workson
PNUMBE
Number - - 0 - - - -
R
HOURS Number - 3 1 - - - -
1-3
1. EMPLOYEE
SQL> insert into employee values('Ajay','d','kiran','12341','01-sep-97','Bangalore','M',19000,'12341',1);
SQL> insert into employee values('Usman','d','khan','12342','15-sep-99','Patna','M',19500,'12342',2);
SQL> insert into employee values('Rohan','a','rohith','12343','01-jan-2000','Hampi','M',20000,'12343',3);
SQL>insert into employee values('Mallik','a','arjun','12344','06-sep-99','Udupi','M',20500,'12344',4);
SQL>insert into employee values('shashi','P','shinde','12345','14-feb-97','kolar','M',21000,'12345',5);
SQL>insert into employee values('Srikant','k','s.m','12346','10-dec-98','hubli','M',21500,'12346',6);
SQL>insert into employee values('rajshekar','s','guna','12347','13-june-90','goa','M',22000,'12347',7);
SQL>insert into employee values('Venkatesh','g','anku','12348','19-aug-2000', 'chennai',22500', '12348', 8);
SQL> insert into employee values(‘harshak’,’b’,’reddy’,’12349’,’16-jun-99’,’hyderabad’,’m’,25500,’12350’,9);
SQL> insert into employee values ('harini','v','shet','12350','11-mar -98','shivajinagar','f',25500,'12350',10);
2. DEPARTMENT
SQL> insert into department values('CS',101,'12341','01-JAN-90');
SQL> insert into department values('ME',102,'12342','20-MAR-91');
SQL> insert into department values('CE',103,'12343','30-JUN-92');
SQL> insert into department values('AM',104,'12344','15-AUG-94');
SQL> insert into department values('CP',105,'12345','26-SEP-95');
SQL> insert into department values('FD',106,'12346','30-DEC-96');
SQL> insert into department values('EEE',107,'12347','14-JAN-97');
SQL> insert into department values('MC',108,'12348','18-FEB-98');
SQL> insert into department values('EC',109,'12349','24-MAR-99');
3. deptlocation
SQL> insert into deptlocation values('101','bangalore');
SQL>insert into deptlocation values('102','mangalore');
SQL>insert into deptlocation values('102','mysore');
SQL>insert into deptlocation values('103','chennai');
SQL>insert into deptlocation values('104','jayanagar');
SQL>insert into deptlocation values('105','delhi');
SQL>insert into deptlocation values('106','kolar');
SQL>insert into deptlocation values('107','tumkur');
SQL>insert into deptlocation values('108','mandya');
SQL>insert into deptlocation values('109','tumkur');
SQL>insert into deptlocation values('109','koramangal');
4. Project
5. WORKSON
6. DEPENDENT
DNUMBER DLOCATION
101 bangalore
103 chennai
105 delhi
104 jayanagar
106 kolar
109 koramangal
108 mandya
102 mangalore
102 mysore
107 tumkur
DNO SUM(SALARY)
1 19000
6 21500
2 19500
4 20500
5 21000
8 22500
3 20000
7 22000
9 25000
10 25500
NO AVG(SALARY)
2 19500
RELATIONAL OPERATORS(>,<,>=,<=,==,!=)
select fname,salary,address from employee where salary between 20000 and 24000;
FNAME SALARY ADDRESS
Rohan 20000 Hampi
Mallik 20500 Udupi
shashi 21000 kolar
Srikant 21500 hubli
rajshekar 22000 goa
Venkatesh 22500 chennai
FNAME MINIT LNAME SSN BDATE ADDRESS SEX SALARY SUPERSSN DNO
Usman d khan 12342 15-SEP-99 Patna M 19500 12342 102
UPDATE:
update employee set salary=20000 where dno=2;
ALTER:
alter table employee add eid number(10);
Table altered.
Desc employee;
Data Lengt Precisio Scal Primary Nullabl Defaul Comme
Table Column Type h n e Key e t nt
EMPLOYEE FNAME Varchar2 9 - - - - - -
MINIT Char 1 - - - - -
LNAME Varchar2 9 - - - - - -
SSN Char 6 - - 1 - - -
BDATE Date 7 - - - - -
ADDRES
Varchar2 20 - - - - -
S
SEX Char 1 - - - - -
SALARY Number - - 0 - - -
SUPERSS
Char 6 - - - - - -
N
DNO Number - - 0 - - - -
EID Number - 10 0 - - -
1 - 11
desc department;
Data Lengt Precisi Scal Primary Nullab Defau Comme
Table Column Type h on e Key le lt nt
DEPARTMEN
DNAME Varchar2 20 - - - - - -
T
DNUMBER Number - - 0 1 - - -
MGRSSN Char 6 - - - - - -
MGRSTARTD
Date 7 - - - - -
ATE
1-4
desc employee;
Data Lengt Precisio Scal Primary Nullabl Defaul Commen
Table Column Type h n e Key e t t
EMPLOYEE FNAME Varchar2 9 - - - - - -
MINIT Char 1 - - - - -
LNAME Varchar2 9 - - - - - -
SSN Char 6 - - 1 - - -
BDATE Date 7 - - - - -
ADDRES
Varchar2 20 - - - - -
S
SEX Char 1 - - - - -
SALARY Number - - 0 - - -
SUPERSS
Char 6 - - - - - -
N
DNO Number - - 0 - - - -
1 - 10
Table created.
SQL> commit;
Commit complete.
PART – B
GUI PROGRAMS
EXERCISE-2
Design a form to find the greatest of two numbers using text box and label
box
Dim a As Integer
Dim b As Integer
OUTPUT
EXERCISE-3
Generate a report for student’s results or employee details or shopping list
or any other example
OUTPUT
EXERCISE-4
Design a form to make use of Horizontal and Vertical scroll bar
OUTPUT
EXERCISE-5
Design a student registration form to use various tools like label, text,
command, option box.
OUTPUT
EXERCISE-6
Design a menu driven form to process student result or a shopping list or
any other example
Private Sub details_Click()
form2.Show
End Sub
Private Sub EXIT_Click()
End
End Sub
Private Sub result_Click()
form3.Show
End Sub