Vous êtes sur la page 1sur 72

INDEX

S.NO

DATE

NAME OF EXPERIMENTS Data Definition Language (DDL) commands in RDBMS. Data Manipulation Language DML) and Data Control Language (DCL) commands in RDBMS. High-level language extension with Cursors High level language extension with Triggers Procedures and Functions. Embedded SQL. Database design using E-R model and Normalization Design and implementation of Payroll Processing System. Design and implementation of Banking System. Design and implementation of Library Information System.

PAGE NO

MARK

STAFF SIGN

5 6

10

EX NO: 1 DATE: AIM:

DATA DEFINITION LANGUAGE (DDL)

To study and perform SQL commands of data definition language. ALGORITHM: 1.The data definition language consists of the following commands: Create Alter Truncate Drop 2.Create: This command is used to create the table. Syntax: The following syntax is used to create a table: Create table <table name>(column name1 data type(size of the data), column name n data type(size of the data)>); 3.Desc: This command is used to describe the structure of the database. Syntax: The following syntax is used to describe the table: Desc <table name>; 4.Alter: This command is used to alter the command(i.e either to add or modify the table) Syntax: The following syntax is used to alter the table: Alter table <table name> add/modify(<column name > datatype (size of data)); 5.Truncate: This command is used to delete the content of the table and reuse the memory location. Syntax: The following syntax is used to truncate the table: Truncate table<table name>; 6.Drop: This command is used to delete the table. Syntax: The following syntax is used to delete (or) drop the table: Drop table<table name>;

PROCEDURE: Create: SQL> create table bank(accno number(3),branch varchar(20),cname varchar(20)); Table created. SQL> desc bank; Name Null? Type ------------------------------------------- -------- -----------------------------------ACCNO NUMBER(3) BRANCH VARCHAR2(20) CNAME VARCHAR2(20) Alter: SQL> desc bank; Name Null? Type ------------------------------------------- -------- -----------------------------------ACCNO NUMBER(3) BRANCH VARCHAR2(20) CNAME VARCHAR2(20) SQL> alter table bank add(balance number(4)); Table altered. SQL> desc bank; Name Null? Type ------------------------------------------- -------- -----------------------------------ACCNO NUMBER(3) BRANCH VARCHAR2(20) CNAME VARCHAR2(20) BALANCE NUMBER(4) Truncate: SQL> truncate table bank; Table truncated. Delete: SQL> drop table bank; Table dropped. RESULT: Thus the DDL commands were studied. EX NO:2

DATA MANIPULATION LANGUAGE (DML)

DATE: AIM: To study and perform the SQL commands of data manipulation language. ALGORITHM: 1.The data manipulation language consists of the following commands: Insert. Select. Delete. Update. 2.Insert: This command is used to insert the values in the table. Syntax: The following three types of syntax can be used to insert the values into the table. SQL>insert into <table name>(column name1,...column name n)values(value 1, ..value n); [ If the data is string (or) character type ,it should be given within single quotes] SQL>inset into <table name> values (value 1,..value n); SQL>insert into <table name> values(&value1,..&value n); 3.Select: This command is used to display the values of the database or the table. Syntax: The following two types of syntax can be used to display the values from the table. SQL>select * from <table name>; The above command will display all the values in the table. SQL>select <column name1,column name n) from <table name> where <condition>; The above command is used to display some particular values from the table. 4.Delete: This command is used to delete the records of a table. Syntax: The following two types of syntax can be used to delete the record. SQL>delete from<table name> where <condition>; The above command is used to delete particular value from the table based on some condition. SQL>delete from <table name>; This command is used to delete all the records from the table. 5.Update: This command is used to modify the existing values of the table.

Syntax: The syntax for updating the existing record is as follows. SQL>Update <table name> set <column name=new value> where <condition>; PROCEDURE: Insert: SQL> insert into bank (accno, cname, branch) values (2444,'dhana','salem'); 1 row created. SQL> insert into bank values(444,'hari','chennai'); 1 row created. SQL> insert into bank values(&accno,'&cname','&branch'); Enter value for accno: 100 Enter value for cname: arun Enter value for branch: erode old 1: insert into bank values(&accno,'&cname','&branch'); new 1: insert into bank values(100,'arun','erode') select: SQL> select*from bank; ACCNO --------2444 444 100 CNAME -------------------dhana hari arun BRANCH -------------------salem Chennai erode

SQL>select cname,branch where accno=444; ACCNO --------444 CNAME BRANCH -------------------- -------------------hari Chennai

SQL>select branch where accno=100 and branch=Chennai; ACCNO CNAME BRANCH ---------------------------- -------------------100 arun erode

Update:

SQL>update bank set accno=244 where accno=2444; 1 row updated; SQL>select*from bank; ACCNO --------244 444 100 Delete: SQL>delete from bank where cname=dhana; SQL>select*from bank; ACCNO --------444 100 CNAME -------------------hari arun BRANCH -------------------Chennai erode CNAME -------------------dhana hari arun BRANCH -------------------salem Chennai erode

RESULT: Thus the DML commands were studied.

EX NO:3 DATE: AIM:

HIGH LEVEL LANGUAGE EXTENSION WITH CURSORS

To write and execute a PL/SQL program using cursors. ALGORITHM: 1.create a cursor 2.declare the variables required. 3.perform the various cursor commands (i)open (ii)fetch. (iii)close 4.open: syntax: open<cursor name> 5.Create the cursor without any errors and perform necessary PL/SQL operations. 6.FETCH: syntax: fetch<cursor name>into<attribute name> 7.CLOSE: syntax: <cursor name> 8.Execute the cursor and validate the result. 9.End the program.

PROGRAM 1:
1 declare 2 cursor s is select regno,name,mark1,mark2 from ugr; 3 sregno ugr.regno % type; 4 sname ugr.name% type; 5 smark1 ugr.mark1 % type; 6 smark2 ugr.mark2 % type; 7 stot ugr.total% type; 8 begin 9 open s; 10 loop 11 fetch s into sregno,sname,smark1,smark2; 12 exit when s % notfound; 13 stot:=(smark1+smark2); 14 update ugr set total=stot where regno=sregno; 15 end loop; 16 close s; 17* end; SQL> /

PL/SQL procedure successfully completed. SQL> set serveroutput on; SQL> / PL/SQL procedure successfully completed. SQL> select*from ugr; REGNO --------1 2 NAME MARK1 -------------------- --------Rahul 100 Rohith 90 MARK2 --------100 90 TOTAL --------200 180

PROGRAM 2:
1 declare 2 cursor emp_cur is select * from emp where dno=10 or dno=20; 3 vemp emp % rowtype; 4 begin 5 open emp_cur; 6 dbms_output.put_line(' dno ' || ' eno ' || ' ename ' || ' salary ' ); 7 loop 8 fetch emp_cur into Vemp; 9 if Vemp.salary>=100 then 10 dbms_output.put_line(vemp.dno|| ' ' || vemp.eno || ' ' || vemp.ename || ' '||vemp.salary); 11 end if; 12 exit when emp_cur % NOTFOUND; 13 end loop; 14 dbms_output.put_line('no of employees:'||emp_cur % rowcount); 15 close emp_cur; 16* end; 17 / PL/SQL procedure successfully completed. SQL> set serveroutput on; SQL> / OUTPUT: dno eno ename salary 209 523 raja 5000 No of employees:1 RESULT: Thus the above program was executed and verified.

EX NO:4 DATE: AIM:

HIGH LEVEL LANGUAGE EXTENSION WITH TRIGGER

To write and execute a PL/SQL program using Trigger. ALGORITHM: 1.Create a trigger. 2.Declare the variables required. 3.Specify the triggering condition using following syntax: create or replace trigger <trigger name><before or after><insert or delete><table name> 4.Perform the necessary PL/SQL operations 5.Execute the program and if there is any error display the error message using following syntax: raise_application_error(error no,error message); 20000 to 20999(range for error merssage) 6.validate the result 7.End the program. PROGRAM: 1 create or replace trigger acc_up_bal after insert on acctrans for each row 2 declare 3 vaccno acctrans.accno%type; 4 vtrans acctrans.transamt%type; 5 vtranstype acctrans.transtype%type; 6 begin 7 vaccno:=:new.accno; 8 vtrans:=:new.transamt; 9 vtranstype:=:new.transtype; 10 if vtranstype='d' then 11 update accmaster set bal=bal+vtrans where accno=vaccno; 12 elsif vtranstype='w' then 13 update accmaster set bal=bal-vtrans where accno=vaccno; 14 end if; 15* end; SQL> / Trigger created. SQL> insert into acctrans values(1001,123,'09dec08',7000,'d'); 1 row created.

Error at line 1 ORA 20010:Withdraw is not possible. ORA 06512:At SCOTT.acc_update_bal,line14 ORA 04088:error during execution of trigger SCOTT.acc_update_bal SQL> create or replace trigger acc_trig before delete on emp 2 begin 3 raise_application_error(-20001,'details record may be present'); 4 end; 5 / Trigger created. SQL> delete from emp where sal=3000; delete from emp where sal=3000 * ERROR at line 1: ORA-20001: details record may be present ORA-06512: at "SCOTT.ACC_TRIG", line 2 ORA-04088: error during execution of trigger 'SCOTT.ACC_TRIG'

RESULT: Thus the above program was executed and verified.

EX NO:5 DATE: AIM:

PROCEDURE AND FUNCTIONS

To write and execute a PL/SQL program to implement Procedure and function. ALGORITHM: 1.Create a Procedure and Function 2.Declare the variables required. 3.Perform Procedure and Function using commands/query in its main parts. 4.Main parts of function,procedure are (i) Declaration part. (ii) Execution part. (iii) Exception part. 5.Syntax for procedure: create or replace procedure < procedure name>[argument[IN/OUT/INOUT] data type[IS/AS] variable data type begin PL/SQL coding; Execution part;(optional) End 6. Syntax for Function create or replace function< function name>return data type[IS/AS] fullname variable data type;(optional) begin PL/SQL part Exception part(optional) End 7.Execution the result 8.Stop the program. PROCEDURE: 1 create or replace procedure acc_detail(accno1 in number) is 2 cname varchar2(15); 3 balamt number(6,2); 4 b number(6,2); 5 name varchar2(15); 6 balance number(6,2); 7 minbal number(6,2); 8 begin 9 select name,balance into cname,balamt from bankdet where accno=accno1; 10 minbal:=5000; 11 if balamt>minbal then 12 b:=balamt-minbal; 13 dbms_output.put_line('possible withdraw amount is'||b);

14 else 15 dbms_output.put_line('withgdraw is not possible'); 16 end if; 17* end; SQL> / Procedure created. SQL> exec acc_detail(111); possible withdraw amount is 2000. PL/SQL procedure successfully completed. FUNCTION: 1 create or replace function acc_detailfun(accno1 number) return number is 2 cname varchar2(15); 3 balamt number(6,2); 4 b number(5); 5 balance number(6,2); 6 minbal number(6,2); 7 begin 8 select cname,balance into cname,balamt from bdet where accno=accno1; 9 minbal:=5000; 10 if balamt>minbal then 11 b:=balamt-minbal; 12 return b; 13 else 14 dbms_output.put_line('withdraw is not possible'); 15 end if; 16* end; SQL> / Function created. SQL> declare 2 a number(5); 3 b number(5); 4 begin 5 a:=&accno; 6 b:=acc_detailfun(a); 7 dbms_output.put_line('possible withdraw amt is'||b); 8 end; 9 / Enter value for accno: 112 old 5: a:=&accno; new 5: a:=112; possible withdraw amt is2000

PL/SQL procedure successfully completed.

RESULT: Thus the above program was executed and verified.

EX.NO:6

EMBEDDED SQL

DATE:

import java.sql.*; class Emp { public static void main(String args[]) { try { Class.forName("sun.jdbc.odbc.jdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:emp","k6500","k6500"); Statement stmt=con.CreateStatement(); ResultSet rs=stmt.execute Query("select * from emp1"); while(rs.next()) { System.out.print("Employee No = " + rs.getInt (1) ); System.out.print("Employee Name = " + rs.getString (2) ); System.out.print(Salary = " + rs.getInt (3) ); System.out.print("\n"); } stmt.close(); con.close(); } catch (java.lang.Exception ex) { System.out.println("Error:"+ex); } } } OUTPUT: To Compile: Z:\> set path = z:\jdk1.3\bin; Z:\> javac emp.java To Run: Z:\> java emp Employee No=11 Employee No=12 Employee No=13

Employee Name =a Employee Name =b Employee Name =c

Salary= 6500.5 Salary= 4500 Salary= 10000

SQL> select * from employees; NO NAME --------- ------------------------11 a 12 b 13 c DEPTNO --------101 101 110 SALARY JOB COMM -------------------------6500.5 clerk 10 4500 tech 10 10000 manager 50

RESULT: Thus the above program was executed and verified.

EX.NO:7 DATE:

DATABASE DESIGN USING E-R MODEL AND NORMALIZATION

TABLE EPROJECT IN FIRST NORMAL FORM NOT IN SECOND NORMAL FORM SQL> create table eproject(ssn number(5) primary key, pnumber number(3),hours number(5), ename varchar(10), pname varchar(10), plocation varchar(10)); Table created. SQL>desc eproject; Name Null? ------------------------------SSN NOT NULL PNUMBER HOURS ENAME PNAME PLOCATION Type -------- ---NUMBER(5) NUMBER(3) NUMBER(5) VARCHAR2(10) VARCHAR2(10) VARCHAR2(10)

SQL>insert into eproject values(&ssn, &pnumber, &hours, &ename, &pname, &plocation); SQL>select * from eproject; SQL> select * from eproject; SSN PNUMBER --------- --------111 100 112 101 113 110 HOURS ENAME --------- ---------3 Raj 4 Kavitha 5 Manish PNAME ---------WAP1X SAP1X SAP1X PLOCATION ---------Dehradun Varanasi Varanasi

NORMALIZING EPROJECT INTO SECOND NORMAL FORM SQL>create table eproject1(ssn number(5) primary key, pnumber number(5), hours number(5)); Table created. SQL>desc eproject1;

Name Null? Type ------------------------- ------------- ---SSN NOT NULL NUMBER(5) PNUMBER NUMBER(5) HOURS NUMBER(5) SQL>insert into eproject1 values(&ssn,&pnumber,&hours); SQL>select * from eproject1; SSN PNUMBER --------- --------111 100 112 101 113 110 HOURS --------3 4 5

SQL>create table eproject2(ssn number(5) primary key, ename varchar(10)); Table created. SQL>desc eproject2; Name Null? Type ------------------------------- -------- ---SSN NOT NULL NUMBER(5) ENAME VARCHAR2(10) SQL>insert into eproject2 values(&ssn,&ename); SQL>select * from eproject2; SSN ----111 112 113 ENAME ---------Raj Kavitha Manish

SQL>create table eproject3(pnumber number(5) primary key,pname varchar(10),plocation varchar(10)); Table created. SQL>desc eproject3;

Name ----------------------PNUMBER PNAME PLOCATION

Null? Type --------------- ---NOT NULL NUMBER(5) VARCHAR2(10) VARCHAR2(10)

SQL>insert into eproject3 values(&pnumber,&pname,&plocation); SQL>select * from eproject3; PNUMBER PNAME PLOCATION -------- ------------------100 WAP1X Dehradun 101 SAP1X Varanasi 110 WAP1X Dehradun TABLE EDEPT IN FIRST NORMAL FORM NOT IN THIRD NORMAL FORM SQL>create table edept(ename varchar(10),ssn number(5),address varchar(10),dno number(5), dname varchar(10),dmgrssn number(5)); Table created. SQL>desc edept; Name Null? Type ------------------------------- -------- ---ENAME VARCHAR2(10) SSN NUMBER(5) ADDRESS VARCHAR2(10) DNO NUMBER(5) DNAME VARCHAR2(10) DMGRSSN NUMBER(5) SQL>insert into edept values (&ename,&ssn,&address,&dno,&dname, &dmgrssn);

SQL> select * from edept; ENAME ---------Raj Kavitha Manish SSN ADDRESS --------- ---------111 Northst 112 Souhtst 113 Westst DNO DNAME DMGRSSN --------- -----------------900 EDP 200 901 MAT 201 902 IT 202

NORMALIZING EDEPT INTO THIRD NORMAL FORM SQL>create table edept1(ename varchar(10),ssn number primary key,address varchar(10),dno number(5)); Table created. SQL>desc edept1; Name -------------------ENAME SSN ADDRESS DNO Null? ----------Type -------- ---VARCHAR2(10) NOT NULL NUMBER VARCHAR2(10) NUMBER(5)

SQL>insert into edept1 values(&ename,&ssn,&address,&dno); ENAME ---------- Raj Kavitha Manish SSN ADDRESS -------- ---------111 Northst Southst 901 Westst 902 DNO --------900

112 113

SQL>select * from edept1; SQL>create table edept2(dno number(5)primary key,dname varchar(20),dmgrssn number(5)); Table created. SQL>desc edept2; Name ----------------------DNO DNAME Null? Type --------------- ---NOT NULL NUMBER(5) VARCHAR2(20)

DMGRSSN

NUMBER(5)

SQL>insert into edept2 values(&dno, &dname, &dmgrssn); SQL>select * from edept2; DNO DNAME DMGRSSN ------------------------------900 EDP 200 901 MAT 201 902 IT 202

RESULT: Thus the above program was executed and verified.

EX.NO:8 DATE :

DESIGN & IMPLEMENTATION OF PAYROLL PROCESSING SYSTEM

SQL> create table payroll( name varchar(20), no number(10), des varchar(10), dept varchar(10), basicpay number(10,3), da number(10,3), hra number (10,3), pf number(10,3), grosspay number(10,3), netpay number(10,3)); SQL> desc payroll; Name Null? Type ------------------------------- -------- ---NAME VARCHAR2(20) NO NUMBER(10) DES VARCHAR2(10) DEPT VARCHAR2(10) BASICPAY NUMBER(10,3) DA NUMBER(10,3) HRA NUMBER(10,3) PF NUMBER(10,3) GROSSPAY NUMBER(10,3) NETPAY NUMBER(10,3) Form name: Payroll System Canvas name: Canvas2 Type: Trigger Function name: when_mouse_click PL/SQL CODING: Move to the First record: FIRST_RECORD; COMMIT; Move to the Last record: LAST_RECORD; COMMIT; Move to the Next record: NEXT_RECORD; COMMIT; Move to the Previous record:

PREVIOUS_RECORD; COMMIT; Execute Record: EXECUTE_QUERY(ALL_RECORDS); COMMIT; Save a record: BEGIN COMMIT; NEXT_RECORD; END; Delete a record: DELETE_RECORD; COMMIT; Clear the Form: CLEAR_FORM(DO_COMMIT); To Exit: EXIT_FORM; Calculate: BEGIN IF :BASICPAY >= 10000 THEN :DA := 0.5 * :BASICPAY; :HRA := 0.1 * :BASICPAY; ELSIF :BASICPAY < 1000 AND :BASICPAY >= 5000 THEN :DA := 0.4 * :BASICPAY; :HRA := 0.1 * :BASICPAY; ELSE :DA := 0.2 * :BASICPAY; :HRA := 0.1 * :BASICPAY;

END IF; :PF := 0.2 * :BASICPAY; :GROSSPAY := :BASICPAY + :DA + :HRA; :NETPAY := :GROSSPAY - :PF; END;

SQL> select * from payroll; NAME NO DES DEPT BASICPAY DA HRA -------- ---------- ---------------------------------- --------MSS 113 PA EDP 500 100 50 SIVA GANGA PF ---100 1000 2000 112 111 CLERK MANAGER EDP OFFICE 5000 10000 1000 500

5000 1000

GROSSPAY NETPAY -------------------650 550 6500 5500 16000 14000

PAYROLL PROCESSING SYSTEM - DESIGN AND OUTPUT

RESULT: Thus the above program was executed and verified.

EX.NO: 9 DATE :

DESIGN & IMPLEMENTATION OF BANKING SYSTEMS

SQL> create table accounts(Acno number(5),CustomerName varchar(25),Branch varchar(25),City varchar(25),Balance number(10,2),Amount number(10,2)); Table created. SQL> desc accounts; Name Null? Type ------------------------------- -------- ---ACNO NUMBER(5) CUSTOMERNAME VARCHAR2(25) BRANCH VARCHAR2(25) CITY VARCHAR2(25) BALANCE NUMBER(10,2) AMOUNT NUMBER(10,2) Form name: Account Details Canvas name: Canvas2 Type: Trigger Function name: when_mouse_click PL/SQL CODING: Move to the First record: FIRST_RECORD; COMMIT; Move to the Last record: LAST_RECORD; COMMIT; Move to the Next record: NEXT_RECORD; COMMIT; Move to the Previous record: PREVIOUS_RECORD;

COMMIT; Execute Record: EXECUTE_QUERY (ALL_RECORDS); COMMIT; Save a record: BEGIN COMMIT; NEXT_RECORD; END; Delete a record: DELETE_RECORD; COMMIT; Clear the Form: CLEAR_FORM (DO_COMMIT); To Exit: EXIT_FORM; Deposit: BEGIN IF :AMOUNT > 0 AND :BALANCE > 0 THEN :BALANCE := :BALANCE + :AMOUNT; END IF; END; WithDraw: BEGIN IF :AMOUNT > 0 AND :BALANCE > 0 THEN :BALANCE := :BALANCE - :AMOUNT;

END IF; END;

SQL> select * from accounts; ACNO CUSTOMERNAME BRANCH --------- ------------------------- -----------------101 102 SIVA PREM AMOUNT -----------100 1000 SRIRANGAM BHEL CITY ----------TRICHY TRICHY

BALANCE ------------4900 6000

BANKING SYSTEMS - DESIGN AND OUTPUT

Result: Thus the program was verified successfully verified and executed.

EX.NO:10 DATE:

DESIGN & IMPLEMENTATION OF LIBRARY INFORMATION SYSTEM.

SQL> create table library(Bookno number(5),Bookname varchar(25),Authorname varchar(25),Price number(4),Publication varchar(25),Edition number(5),EntryDate date,Returndate date,Duedate date,Fine number(4)); Table created. SQL>desc library; Name Null? Type ------------------------------- -------- ---BOOKNO NUMBER(5) BOOKNAME VARCHAR2(25) AUTHORNAME VARCHAR2(25) PRICE NUMBER(4) PUBLICATION VARCHAR2(25) EDITION NUMBER(5) ENTRYDATE DATE RETURNDATE DATE DUEDATE DATE FINE NUMBER(4) Form name: Library Details Canvas name: Canvas2 Type: Trigger Function name: when_mouse_click PL/SQL CODING: Move to the First record: FIRST_RECORD; COMMIT; Move to the Last record: LAST_RECORD; COMMIT; Move to the Next record: NEXT_RECORD; COMMIT;

Move to the Previous record: PREVIOUS_RECORD; COMMIT; Execute Record: EXECUTE_QUERY (ALL_RECORDS); COMMIT; Save a record: BEGIN COMMIT; NEXT_RECORD; END; Delete a record: DELETE_RECORD; COMMIT; Clear the Form: CLEAR_FORM (DO_COMMIT); To Exit: EXIT_FORM; Calculate: BEGIN :DUEDATE := :ENTRYDATE + 30; IF :DUEDATE < :RETURNDATE THEN :FINE := ( :RETURNDATE - :DUEDATE ) * 3; END IF; END; LIBRARY INFORMATION SYSTEM - DESIGN AND OUTPUT

RESULT: Thus the above program was executed and verified.

S.NO

DATE

NAME OF EXPERIMENTS Data Definition Language (DDL) commands in RDBMS. Data Manipulation Language DML) and Data Control Language (DCL) commands in RDBMS. High-level language extension with Cursors High level language extension with Triggers Procedures and Functions. Embedded SQL. Database design using E-R model and Normalization Design and implementation of Payroll Processing System. Design and implementation of Banking System. Design and implementation of Library Information System.

PAGE NO

MARK

STAFF SIGN

5 6

10

EX NO: 1 DATE: AIM:

DATA DEFINITION LANGUAGE (DDL)

To study and perform SQL commands of data definition language. ALGORITHM: 1.The data definition language consists of the following commands: Create Alter Truncate Drop 2.Create: This command is used to create the table. Syntax: The following syntax is used to create a table: Create table <table name>(column name1 data type(size of the data), column name n data type(size of the data)>); 3.Desc: This command is used to describe the structure of the database. Syntax: The following syntax is used to describe the table: Desc <table name>; 4.Alter: This command is used to alter the command(i.e either to add or modify the table) Syntax: The following syntax is used to alter the table: Alter table <table name> add/modify(<column name > datatype (size of data)); 5.Truncate: This command is used to delete the content of the table and reuse the memory location. Syntax: The following syntax is used to truncate the table: Truncate table<table name>; 6.Drop: This command is used to delete the table. Syntax: The following syntax is used to delete (or) drop the table: Drop table<table name>;

PROCEDURE: Create: SQL> create table bank(accno number(3),branch varchar(20),cname varchar(20)); Table created. SQL> desc bank; Name Null? Type ------------------------------------------- -------- -----------------------------------ACCNO NUMBER(3) BRANCH VARCHAR2(20) CNAME VARCHAR2(20) Alter: SQL> desc bank; Name Null? Type ------------------------------------------- -------- -----------------------------------ACCNO NUMBER(3) BRANCH VARCHAR2(20) CNAME VARCHAR2(20) SQL> alter table bank add(balance number(4)); Table altered. SQL> desc bank; Name Null? Type ------------------------------------------- -------- -----------------------------------ACCNO NUMBER(3) BRANCH VARCHAR2(20) CNAME VARCHAR2(20) BALANCE NUMBER(4) Truncate: SQL> truncate table bank; Table truncated. Delete: SQL> drop table bank; Table dropped. RESULT: Thus the DDL commands were studied. EX NO:2 DATA MANIPULATION LANGUAGE (DML)

DATE: AIM: To study and perform the SQL commands of data manipulation language. ALGORITHM: 1.The data manipulation language consists of the following commands: Insert. Select. Delete. Update. 2.Insert: This command is used to insert the values in the table. Syntax: The following three types of syntax can be used to insert the values into the table. SQL>insert into <table name>(column name1,...column name n)values(value 1, ..value n); [ If the data is string (or) character type ,it should be given within single quotes] SQL>inset into <table name> values (value 1,..value n); SQL>insert into <table name> values(&value1,..&value n); 3.Select: This command is used to display the values of the database or the table. Syntax: The following two types of syntax can be used to display the values from the table. SQL>select * from <table name>; The above command will display all the values in the table. SQL>select <column name1,column name n) from <table name> where <condition>; The above command is used to display some particular values from the table. 4.Delete: This command is used to delete the records of a table. Syntax: The following two types of syntax can be used to delete the record. SQL>delete from<table name> where <condition>; The above command is used to delete particular value from the table based on some condition. SQL>delete from <table name>; This command is used to delete all the records from the table. 5.Update: This command is used to modify the existing values of the table.

Syntax: The syntax for updating the existing record is as follows. SQL>Update <table name> set <column name=new value> where <condition>; PROCEDURE: Insert: SQL> insert into bank(accno,cname,branch) values(2444,'dhana','salem'); 1 row created. SQL> insert into bank values(444,'hari','chennai'); 1 row created. SQL> insert into bank values(&accno,'&cname','&branch'); Enter value for accno: 100 Enter value for cname: arun Enter value for branch: erode old 1: insert into bank values(&accno,'&cname','&branch'); new 1: insert into bank values(100,'arun','erode') select: SQL> select*from bank; ACCNO --------2444 444 100 CNAME -------------------dhana hari arun BRANCH -------------------salem Chennai erode

SQL>select cname,branch where accno=444; ACCNO --------444 CNAME BRANCH -------------------- -------------------hari Chennai

SQL>select branch where accno=100 and branch=Chennai; ACCNO CNAME BRANCH ---------------------------- -------------------100 arun erode

Update:

SQL>update bank set accno=244 where accno=2444; 1 row updated; SQL>select*from bank; ACCNO --------244 444 100 Delete: SQL>delete from bank where cname=dhana; SQL>select*from bank; ACCNO --------444 100 CNAME -------------------hari arun BRANCH -------------------Chennai erode CNAME -------------------dhana hari arun BRANCH -------------------salem Chennai erode

RESULT: Thus the DML commands were studied.

EX NO:3 DATE: AIM:

HIGH LEVEL LANGUAGE EXTENSION WITH CURSORS

To write and execute a PL/SQL program using cursors. ALGORITHM: 1.create a cursor 2.declare the variables required. 3.perform the various cursor commands (i)open (ii)fetch. (iii)close 4.OPEN: syntax: open<cursor name> 5.Create the cursor without any errors and perform necessary PL/SQL operations. 6.FETCH: syntax: fetch<cursor name>into<attribute name> 7.CLOSE: syntax: <cursor name> 8.Execute the cursor and validate the result. 9.End the program.

PROGRAM 1:
1 declare 2 cursor s is select regno,name,mark1,mark2 from ugr; 3 sregno ugr.regno % type; 4 sname ugr.name% type; 5 smark1 ugr.mark1 % type; 6 smark2 ugr.mark2 % type; 7 stot ugr.total% type; 8 begin 9 open s; 10 loop 11 fetch s into sregno,sname,smark1,smark2; 12 exit when s % notfound; 13 stot:=(smark1+smark2); 14 update ugr set total=stot where regno=sregno; 15 end loop; 16 close s; 17* end; SQL> /

PL/SQL procedure successfully completed. SQL> set serveroutput on; SQL> / PL/SQL procedure successfully completed. SQL> select*from ugr; REGNO --------1 2 NAME MARK1 -------------------- --------Rahul 100 Rohith 90 MARK2 --------100 90 TOTAL --------200 180

PROGRAM 2:
1 declare 2 cursor emp_cur is select * from emp where dno=10 or dno=20; 3 vemp emp % rowtype; 4 begin 5 open emp_cur; 6 dbms_output.put_line(' dno ' || ' eno ' || ' ename ' || ' salary ' ); 7 loop 8 fetch emp_cur into Vemp; 9 if Vemp.salary>=100 then 10 dbms_output.put_line(vemp.dno|| ' ' || vemp.eno || ' ' || vemp.ename || ' '||vemp.salary); 11 end if; 12 exit when emp_cur % NOTFOUND; 13 end loop; 14 dbms_output.put_line('no of employees:'||emp_cur % rowcount); 15 close emp_cur; 16* end; 17 / PL/SQL procedure successfully completed. SQL> set serveroutput on; SQL> / OUTPUT: dno eno ename salary 209 523 raja 5000 No of employees:1 RESULT: Thus the above program was executed and verified.

EX NO:4 DATE: AIM:

HIGH LEVEL LANGUAGE EXTENSION WITH TRIGGER

To write and execute a PL/SQL program using Trigger. ALGORITHM: 1.Create a trigger. 2.Declare the variables required. 3.Specify the triggering condition using following syntax: create or replace trigger <trigger name><before or after><insert or delete><table name> 4.Perform the necessary PL/SQL operations 5.Execute the program and if there is any error display the error message using following syntax: raise_application_error(error no,error message); 20000 to 20999(range for error merssage) 6.validate the result 7.End the program. PROGRAM: 1 create or replace trigger acc_up_bal after insert on acctrans for each row 2 declare 3 vaccno acctrans.accno%type; 4 vtrans acctrans.transamt%type; 5 vtranstype acctrans.transtype%type; 6 begin 7 vaccno:=:new.accno; 8 vtrans:=:new.transamt; 9 vtranstype:=:new.transtype; 10 if vtranstype='d' then 11 update accmaster set bal=bal+vtrans where accno=vaccno; 12 elsif vtranstype='w' then 13 update accmaster set bal=bal-vtrans where accno=vaccno; 14 end if; 15* end; SQL> / Trigger created. SQL> insert into acctrans values(1001,123,'09dec08',7000,'d'); 1 row created. Error at line 1

ORA 20010:Withdraw is not possible. ORA 06512:At SCOTT.acc_update_bal,line14 ORA 04088:error during execution of trigger SCOTT.acc_update_bal SQL> create or replace trigger acc_trig before delete on emp 2 begin 3 raise_application_error(-20001,'details record may be present'); 4 end; 5 / Trigger created. SQL> delete from emp where sal=3000; delete from emp where sal=3000 * ERROR at line 1: ORA-20001: details record may be present ORA-06512: at "SCOTT.ACC_TRIG", line 2 ORA-04088: error during execution of trigger 'SCOTT.ACC_TRIG'

RESULT: Thus the above program was executed and verified.

EX NO:5 DATE: AIM:

PROCEDURE AND FUNCTIONS

To write and execute a PL/SQL program to implement Procedure and function. ALGORITHM: 1.Create a Procedure and Function 2.Declare the variables required. 3.Perform Procedure and Function using commands/query in its main parts. 4.Main parts of function,procedure are (i) Declaration part. (ii) Execution part. (iii) Exception part. 5.Syntax for procedure: create or replace procedure < procedure name>[argument[IN/OUT/INOUT] data type[IS/AS] variable data type begin PL/SQL coding; Execution part;(optional) End 6. Syntax for Function create or replace function< function name>return data type[IS/AS] fullname variable data type;(optional) begin PL/SQL part Exception part(optional) End 7.Execution the result 8.Stop the program. PROCEDURE: 1 create or replace procedure acc_detail(accno1 in number) is 2 cname varchar2(15); 3 balamt number(6,2); 4 b number(6,2); 5 name varchar2(15); 6 balance number(6,2); 7 minbal number(6,2); 8 begin 9 select name,balance into cname,balamt from bankdet where accno=accno1; 10 minbal:=5000; 11 if balamt>minbal then 12 b:=balamt-minbal;

13 dbms_output.put_line('possible withdraw amount is'||b); 14 else 15 dbms_output.put_line('withgdraw is not possible'); 16 end if; 17* end; SQL> / Procedure created. SQL> exec acc_detail(111); possible withdraw amount is 2000. PL/SQL procedure successfully completed. FUNCTION: 1 create or replace function acc_detailfun(accno1 number) return number is 2 cname varchar2(15); 3 balamt number(6,2); 4 b number(5); 5 balance number(6,2); 6 minbal number(6,2); 7 begin 8 select cname,balance into cname,balamt from bdet where accno=accno1; 9 minbal:=5000; 10 if balamt>minbal then 11 b:=balamt-minbal; 12 return b; 13 else 14 dbms_output.put_line('withdraw is not possible'); 15 end if; 16* end; SQL> / Function created. SQL> declare 2 a number(5); 3 b number(5); 4 begin 5 a:=&accno; 6 b:=acc_detailfun(a); 7 dbms_output.put_line('possible withdraw amt is'||b); 8 end; 9 /

Enter value for accno: 112 old 5: a:=&accno; new 5: a:=112; possible withdraw amt is2000 PL/SQL procedure successfully completed.

RESULT: Thus the above program was executed and verified.

EX.NO:6 DATE:

EMBEDDED SQL

import java.sql.*; class Emp { public static void main(String args[]) { try { Class.forName("sun.jdbc.odbc.jdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:emp","k6500","k6500"); Statement stmt=con.CreateStatement(); ResultSet rs=stmt.execute Query("select * from emp1"); while(rs.next()) { System.out.print("Employee No = " + rs.getInt (1) ); System.out.print("Employee Name = " + rs.getString (2) ); System.out.print(Salary = " + rs.getInt (3) ); System.out.print("\n"); } stmt.close(); con.close(); } catch (java.lang.Exception ex) { System.out.println("Error:"+ex); } } } OUTPUT: To Compile: Z:\> set path = z:\jdk1.3\bin; Z:\> javac emp.java To Run: Z:\> java emp Employee No=11 Employee No=12 Employee No=13

Employee Name =a Employee Name =b Employee Name =c

Salary= 6500.5 Salary= 4500 Salary= 10000

SQL> select * from employees; NO NAME --------- ------------------------11 a 12 b 13 c DEPTNO --------101 101 110 SALARY JOB COMM -------------------------6500.5 clerk 10 4500 tech 10 10000 manager 50

RESULT: Thus the above program was executed and verified.

EX.NO:7 DATE:

DATABASE DESIGN USING E-R MODEL AND NORMALIZATION

TABLE EPROJECT IN FIRST NORMAL FORM NOT IN SECOND NORMAL FORM SQL> create table eproject(ssn number(5) primary key, pnumber number(3),hours number(5), ename varchar(10), pname varchar(10), plocation varchar(10)); Table created. SQL>desc eproject; Name Null? ------------------------------SSN NOT NULL PNUMBER HOURS ENAME PNAME PLOCATION Type -------- ---NUMBER(5) NUMBER(3) NUMBER(5) VARCHAR2(10) VARCHAR2(10) VARCHAR2(10)

SQL>insert into eproject values(&ssn, &pnumber, &hours, &ename, &pname, &plocation); SQL>select * from eproject; SQL> select * from eproject; SSN PNUMBER --------- --------111 100 112 101 113 110 HOURS ENAME --------- ---------3 Raj 4 Kavitha 5 Manish PNAME ---------WAP1X SAP1X SAP1X PLOCATION ---------Dehradun Varanasi Varanasi

NORMALIZING EPROJECT INTO SECOND NORMAL FORM SQL>create table eproject1(ssn number(5) primary key, pnumber number(5), hours number(5)); Table created.

SQL>desc eproject1; Name Null? Type ------------------------- ------------- ---SSN NOT NULL NUMBER(5) PNUMBER NUMBER(5) HOURS NUMBER(5) SQL>insert into eproject1 values(&ssn,&pnumber,&hours); SQL>select * from eproject1; SSN PNUMBER --------- --------111 100 112 101 113 110 HOURS --------3 4 5

SQL>create table eproject2(ssn number(5) primary key, ename varchar(10)); Table created. SQL>desc eproject2; Name Null? Type ------------------------------- -------- ---SSN NOT NULL NUMBER(5) ENAME VARCHAR2(10) SQL>insert into eproject2 values(&ssn,&ename); SQL>select * from eproject2; SSN ----111 112 113 ENAME ---------Raj Kavitha Manish

SQL>create table eproject3(pnumber number(5) primary key,pname varchar(10),plocation varchar(10)); Table created. SQL>desc eproject3;

Name ----------------------PNUMBER PNAME PLOCATION

Null? Type --------------- ---NOT NULL NUMBER(5) VARCHAR2(10) VARCHAR2(10)

SQL>insert into eproject3 values(&pnumber,&pname,&plocation); SQL>select * from eproject3; PNUMBER PNAME PLOCATION -------- ------------------100 WAP1X Dehradun 101 SAP1X Varanasi 110 WAP1X Dehradun TABLE EDEPT IN FIRST NORMAL FORM NOT IN THIRD NORMAL FORM SQL>create table edept(ename varchar(10),ssn number(5),address varchar(10),dno number(5), dname varchar(10),dmgrssn number(5)); Table created. SQL>desc edept; Name Null? Type ------------------------------- -------- ---ENAME VARCHAR2(10) SSN NUMBER(5) ADDRESS VARCHAR2(10) DNO NUMBER(5) DNAME VARCHAR2(10) DMGRSSN NUMBER(5) SQL>insert into edept values (&ename,&ssn,&address,&dno,&dname, &dmgrssn);

SQL> select * from edept; ENAME ---------Raj Kavitha Manish SSN ADDRESS --------- ---------111 Northst 112 Souhtst 113 Westst DNO DNAME DMGRSSN --------- -----------------900 EDP 200 901 MAT 201 902 IT 202

NORMALIZING EDEPT INTO THIRD NORMAL FORM SQL>create table edept1(ename varchar(10),ssn number primary key,address varchar(10),dno number(5)); Table created. SQL>desc edept1; Name -------------------ENAME SSN ADDRESS DNO Null? ----------Type -------- ---VARCHAR2(10) NOT NULL NUMBER VARCHAR2(10) NUMBER(5)

SQL>insert into edept1 values(&ename,&ssn,&address,&dno); ENAME ---------- Raj Kavitha Manish SSN ADDRESS -------- ---------111 Northst Southst 901 Westst 902 DNO --------900

112 113

SQL>select * from edept1; SQL>create table edept2(dno number(5)primary key,dname varchar(20),dmgrssn number(5)); Table created. SQL>desc edept2; Name ----------------------DNO DNAME Null? Type --------------- ---NOT NULL NUMBER(5) VARCHAR2(20)

DMGRSSN

NUMBER(5)

SQL>insert into edept2 values(&dno, &dname, &dmgrssn); SQL>select * from edept2; DNO DNAME DMGRSSN ------------------------------900 EDP 200 901 MAT 201 902 IT 202

RESULT: Thus the above program was executed and verified.

EX.NO:8 DATE :

DESIGN & IMPLEMENTATION OF PAYROLL PROCESSING SYSTEM

SQL> create table payroll( name varchar(20), no number(10), des varchar(10), dept varchar(10), basicpay number(10,3), da number(10,3), hra number (10,3), pf number(10,3), grosspay number(10,3), netpay number(10,3)); SQL> desc payroll; Name Null? Type ------------------------------- -------- ---NAME VARCHAR2(20) NO NUMBER(10) DES VARCHAR2(10) DEPT VARCHAR2(10) BASICPAY NUMBER(10,3) DA NUMBER(10,3) HRA NUMBER(10,3) PF NUMBER(10,3) GROSSPAY NUMBER(10,3) NETPAY NUMBER(10,3) Form name: Payroll System Canvas name: Canvas2 Type: Trigger Function name: when_mouse_click PL/SQL CODING: Move to the First record: FIRST_RECORD; COMMIT; Move to the Last record: LAST_RECORD; COMMIT; Move to the Next record: NEXT_RECORD; COMMIT; Move to the Previous record:

PREVIOUS_RECORD; COMMIT; Execute Record: EXECUTE_QUERY(ALL_RECORDS); COMMIT; Save a record: BEGIN COMMIT; NEXT_RECORD; END; Delete a record: DELETE_RECORD; COMMIT; Clear the Form: CLEAR_FORM(DO_COMMIT); To Exit: EXIT_FORM; Calculate: BEGIN IF :BASICPAY >= 10000 THEN :DA := 0.5 * :BASICPAY; :HRA := 0.1 * :BASICPAY; ELSIF :BASICPAY < 1000 AND :BASICPAY >= 5000 THEN :DA := 0.4 * :BASICPAY; :HRA := 0.1 * :BASICPAY; ELSE :DA := 0.2 * :BASICPAY; :HRA := 0.1 * :BASICPAY;

END IF; :PF := 0.2 * :BASICPAY; :GROSSPAY := :BASICPAY + :DA + :HRA; :NETPAY := :GROSSPAY - :PF; END;

SQL> select * from payroll; NAME NO DES DEPT BASICPAY DA HRA -------- ---------- ---------------------------------- --------MSS 113 PA EDP 500 100 50 SIVA GANGA PF ---100 1000 2000 112 111 CLERK MANAGER EDP OFFICE 5000 10000 1000 500

5000 1000

GROSSPAY NETPAY -------------------650 550 6500 5500 16000 14000

PAYROLL PROCESSING SYSTEM - DESIGN AND OUTPUT

RESULT: Thus the above program was executed and verified.

EX.NO: 9 DATE :

DESIGN & IMPLEMENTATION OF BANKING SYSTEMS

SQL> create table accounts(Acno number(5),CustomerName varchar(25),Branch varchar(25),City varchar(25),Balance number(10,2),Amount number(10,2)); Table created. SQL> desc accounts; Name Null? Type ------------------------------- -------- ---ACNO NUMBER(5) CUSTOMERNAME VARCHAR2(25) BRANCH VARCHAR2(25) CITY VARCHAR2(25) BALANCE NUMBER(10,2) AMOUNT NUMBER(10,2) Form name: Account Details Canvas name: Canvas2 Type: Trigger Function name: when_mouse_click PL/SQL CODING: Move to the First record: FIRST_RECORD; COMMIT; Move to the Last record: LAST_RECORD; COMMIT; Move to the Next record: NEXT_RECORD; COMMIT; Move to the Previous record: PREVIOUS_RECORD;

COMMIT; Execute Record: EXECUTE_QUERY (ALL_RECORDS); COMMIT; Save a record: BEGIN COMMIT; NEXT_RECORD; END; Delete a record: DELETE_RECORD; COMMIT; Clear the Form: CLEAR_FORM (DO_COMMIT); To Exit: EXIT_FORM; Deposit: BEGIN IF :AMOUNT > 0 AND :BALANCE > 0 THEN :BALANCE := :BALANCE + :AMOUNT; END IF; END; WithDraw: BEGIN IF :AMOUNT > 0 AND :BALANCE > 0 THEN :BALANCE := :BALANCE - :AMOUNT;

END IF; END;

SQL> select * from accounts; ACNO CUSTOMERNAME BRANCH --------- ------------------------- -----------------101 102 SIVA PREM AMOUNT -----------100 1000 SRIRANGAM BHEL CITY ----------TRICHY TRICHY

BALANCE ------------4900 6000

BANKING SYSTEMS - DESIGN AND OUTPUT

Result: Thus the program was verified successfully verified and executed.

EX.NO:10 DATE:

DESIGN & IMPLEMENTATION OF LIBRARY INFORMATION SYSTEM.

SQL> create table library(Bookno number(5),Bookname varchar(25),Authorname varchar(25),Price number(4),Publication varchar(25),Edition number(5),EntryDate date,Returndate date,Duedate date,Fine number(4)); Table created. SQL>desc library; Name Null? Type ------------------------------- -------- ---BOOKNO NUMBER(5) BOOKNAME VARCHAR2(25) AUTHORNAME VARCHAR2(25) PRICE NUMBER(4) PUBLICATION VARCHAR2(25) EDITION NUMBER(5) ENTRYDATE DATE RETURNDATE DATE DUEDATE DATE FINE NUMBER(4) Form name: Library Details Canvas name: Canvas2 Type: Trigger Function name: when_mouse_click PL/SQL CODING: Move to the First record: FIRST_RECORD; COMMIT; Move to the Last record: LAST_RECORD; COMMIT; Move to the Next record: NEXT_RECORD; COMMIT;

Move to the Previous record: PREVIOUS_RECORD; COMMIT; Execute Record: EXECUTE_QUERY (ALL_RECORDS); COMMIT; Save a record: BEGIN COMMIT; NEXT_RECORD; END; Delete a record: DELETE_RECORD; COMMIT; Clear the Form: CLEAR_FORM (DO_COMMIT); To Exit: EXIT_FORM; Calculate: BEGIN :DUEDATE := :ENTRYDATE + 30; IF :DUEDATE < :RETURNDATE THEN :FINE := ( :RETURNDATE - :DUEDATE ) * 3; END IF; END; LIBRARY INFORMATION SYSTEM - DESIGN AND OUTPUT

RESULT: Thus the above program was executed and verified.

VIVA QUESTIONS 1. Define database management system? Database management system (DBMS) is a collection of interrelated data and a set of programs to access those data. 2. List any eight applications of DBMS. a) Banking b) Airlines c) Universities d) Credit card transactions e) Tele communication f) Finance g) Sales h) Manufacturing i) Human resources 3. What are the disadvantages of file processing system? The disadvantages of file processing systems are a) Data redundancy and inconsistency b) Difficulty in accessing data c) Data isolation d) Integrity problems e) Atomicity problems f) Concurrent access anomalies 4. What are the advantages of using a DBMS? The advantages of using a DBMS are a) Controlling redundancy b) Restricting unauthorized access c) Providing multiple user interfaces d) Enforcing integrity constraints. e) Providing back up and recovery 5. Give the levels of data abstraction? a) Physical level b) logical level c) view level 6. Define instance and schema? Instance: Collection of data stored in the data base at a particular moment is called an Instance of the database. Schema: The overall design of the data base is called the data base schema. 7. Define the terms 1) physical schema 2) logical schema. Physical schema: The physical schema describes the database design at the physical level, which is the lowest level of abstraction describing how the data are

actually stored. Logical schema: The logical schema describes the database design at the logical level, which describes what data are stored in the database and what relationship exists among the data. 8. What is conceptual schema? The schemas at the view level are called subschemas that describe different views of the database. 9. Define data model? A data model is a collection of conceptual tools for describing data, data relationships, data semantics and consistency constraints. 10. What is storage manager? A storage manager is a program module that provides the interface between the low level data stored in a database and the application programs and queries submitted to the system. 11. What is the use of group by clause? Group by clause is used to apply aggregate functions to a set of tuples.The attributes given in the group by clause are used to form groups.Tuples with the same value on all attributes in the group by clause are placed in one group. 12. What is the use of sub queries? A sub query is a select-from-where expression that is nested with in another query. A common use of sub queries is to perform tests for set membership, make setcomparisions, and determine set cardinality. 13. What is view in SQL? How is it defined? Any relation that is not part of the logical model, but is made visible to a user as a virtual relation is called a view. We define view in SQL by using the create view command. The form of the create view command is Create view v as <query expression> 14. What is the use of with clause in SQL? The with clause provides a way of defining a temporary view whose definition is available only to the query in which the with clause occurs. 15. List the table modification commands in SQL?

_ Deletion _ Insertion _ Updates _ Update of a view 16. List out the statements associated with a database transaction? _ Commit work _ Rollback work 17. What is transaction? Transaction is a unit of program execution that accesses and possibly updated various data items. 18. List the SQL domain Types? SQL supports the following domain types. 1) Char(n) 2) varchar(n) 3) int 4) numeric(p,d) 5) float(n) 6) date. 19. What is the use of integrity constraints? Integrity constraints ensure that changes made to the database by authorized users do not result in a loss of data consistency. Thus integrity constraints guard against accidental damage to the database. 20. Mention the 2 forms of integrity constraints in ER model? _ Key declarations _ Form of a relationship What are the factors to be taken into account when choosing a RAID level? o Monetary cost of extra disk storage requirements. o Performance requirements in terms of number of I/O operations o Performance when a disk has failed. o Performances during rebuild. 22. What is meant by software and hardware RAID systems? RAID can be implemented with no change at the hardware level, using only software modification. Such RAID implementations are called software RAID systems and the systems with special hardware support are called hardware RAID systems. 23. Define hot swapping? Hot swapping permits the removal of faulty disks and replaces it by new ones without turning power off. Hot swapping reduces the mean time to repair. 24. What are the ways in which the variable-length records arise in database systems?

_ Storage of multiple record types in a file. _ Record types that allow variable lengths for one or more fields. _ Record types that allow repeating fields. 25. What is the use of a slotted-page structure and what is the information present in the header? The slotted-page structure is used for organizing records within a single block. The header contains the following information. _ The number of record entries in the header. _ The end of free space _ An array whose entries contain the location and size of each record. 26. What are the two types of blocks in the fixed length representation? Define them. Anchor block: Contains the first record of a chain. Overflow block: Contains the records other than those that are the first record of a chain. 27. What is known as heap file organization? In the heap file organization, any record can be placed anywhere in the file where there is space for the record. There is no ordering of records. There is a single file for each relation. 28. What is known as sequential file organization? In the sequential file organization, the records are stored in sequential order, according to the value of a search key of each record. 29. What is hashing file organization? In the hashing file organization, a hash function is computed on some attribute of each record. The result of the hash function specifies in which block of the file the record should be placed. 30. What is known as clustering file organization? In the clustering file organization, records of several different relations are stored in the same file. 31. What is transaction? Collections of operations that form a single logical unit of work are called transactions. 32. What are the two statements regarding transaction? The two statements regarding transaction of the form:

_ Begin transaction _ End transaction 33. What are the properties of transaction? The properties of transactions are: _ Atomicity _ Consistency _ Isolation _ Durability 34. What is recovery management component? Ensuring durability is the responsibility of a software component of the base system called the recovery management component. 35. When is a transaction rolled back? Any changes that the aborted transaction made to the database must be undone. Once the changes caused by an aborted transaction have been undone, then the transaction has been rolled back. 36. What are the states of transaction? The states of transaction are _ Active _ Partially committed _ Failed _ Aborted _ Committed _ Terminated 37. What is a shadow copy scheme? It is simple, but efficient, scheme called the shadow copy schemes. It is based on making copies of the database called shadow copies that one transaction is active at a time. The scheme also assumes that the database is simply a file on disk. 38. Give the reasons for allowing concurrency? The reasons for allowing concurrency is if the transactions run serially, a short transaction may have to wait for a preceding long transaction to complete, which can lead to unpredictable delays in running a transaction. So concurrent execution reduces the unpredictable delays in running transactions. 39. What is average response time? The average response time is that the average time for a transaction to be completed after it has been submitted. 40. What are the two types of serializability?

The two types of serializability is _ Conflict serializability _ View serializability 41.What is meant by object-oriented data model? The object-oriented paradigm is based on encapsulation of data and code related to an object in to a single unit, whose contents are not visible to the outside world. 42. What is the major advantage of object-oriented programming paradigm? The ability to modify the definition of an object without affecting the rest of the system is the major advantage of object-oriented programming paradigm. 43. What are the methods used in object-oriented programming paradigm? *read-only *update 44. What is the main difference between read-only and update methods? A read-only method does not affect the values of a variable in an object, whereas an update method may change the values of the variables. 45. What is the use of keyword ISA? The use of keyword ISA is to indicate that a class is a specialization of another class. 46. Differentiate sub-class and super-class? The specialization of a class is called subclasses.eg: employee is a subclass of person and teller is a subclass of employee.Conversely, employee is a super class of teller, and person is a super class of employee. 47. What is substitutability? Any method of a class-say A can equally well be invoked with any object belonging to any subclasses B of A. This characteristic leads to code reuse, since the messages, methods, and functions do not have to be written again for objects of class B. 48. What is multiple inheritance? Multiple inheritance permits a class to inherit variables and methods from multiple super classes. 49. What is DAG?

The class-subclass relationship is represented by a directed acyclic graph.eg: employees can be temporary or permanenet.we may create subclasses temporary and permanenet, of the class employee. 50. What is disadvantage of multiple inheritance? There is potential ambiguity if the same variable or method can be inherited from more than one superclass.eg: student class may have a variable dept identifying a student's department, and the teacher class may correspondingly have a variable dept identifying a teacher's department.

Vous aimerez peut-être aussi