Вы находитесь на странице: 1из 77

ANNA UNIVERSITY COIMBATORE

ACADEMIC CAMPUS, JOTHIPURAM

(3CSL301) DATABASE MANAGEMENT SYSTEMS LAB

DEPARTMENT OF INFORMATION TECHNOLOGY DECEMBER 2008

ANNA UNIVERSITY COIMBATORE


ACADEMIC CAMPUS, JOTHIPURAM

RECORD
NAME REG NO LAB : : :

..... . .

Certified that this is the bonafide record of work done by Mr./Ms.____________________________________ of __________ Semester of ______________________________ Full Time / Part Time programme during the year 2008-2009.

STAFF IN-CHARGE Name:

HOD Name:

___________________________________________________Subm itted for the Practical Examination on ___________ at Anna University Coimbatore, Academic Campus, Jothipuram.

INTERNAL EXAMINER EXAMINER Name:

EXTERNAL Name:

DATA BASE MANAGEMENT SYSTEM LAB


INDEX

S.No.

Date

Name of the Experiment

Page No.

Signature

1. 2. 3. 4. 5. 6.

20/11/08 20/11/08 23/11/08 24/11/08 04/12/08 05/12/08

DDL Commands using Oracle DML and DCL Commands Cursors Triggers Procedures and Functions Embedded SQL

7. 8. 9. 10.

09/12/08 11/12/08 13/12/08 14/12/08

Database Design Library Management System Payroll Processing System Banking System

Exp no: 01 Date: 20/11/08

DDL COMMANDS USING ORACLE

AIM:
To execute queries in the Data Definition Language (DDL) commands using oracle.

QUERIES: 1. CREATE:
PURPOSE: To create table in the database. SYNTAX: CREATE TABLE "tablename"("column 1" "data_type_for_column_1","column 2" "data_type_for_column_2",);

2. ALTER:
PURPOSE: To change the table definition. SYNTAX:

ALTER TABLE "tablename"[alter specification];


A) ADD: PURPOSE: To add a column definition to a table. SYNTAX:

ALTER table "tablename" ADD "column name" datatype;


B) DROP: PURPOSE:

To drop a column from a table. SYNTAX: ALTER TABLE "tablename" DROP column name; C) CHANGE: PURPOSE: To change the default value for a column. SYNTAX: ALTER TABLE tablename CHANGE new column name old Column name data type; D) MODIFY: PURPOSE: To change the data type of the fieldname. SYNTAX: ALTER TABLE "tablename" MODIFY column name data type;

3) DROP:
PURPOSE: To drop the table. SYNTAX: DROP table "tablename";

4) RENAME:
PURPOSE: To change the table name. SYNTAX: RENAME old table name to new table name;

5) TRUNCATE:

PURPOSE: To get rid of the data but not the table itself. SYNTAX: TRUNCATE TABLE "tablename";

OUTPUT:
CREATE: SQL> create table students (roll no number (4), name varchar2 (20), dept varchar (20)); Table created. SQL> desc students;

ALTER:
ADD: SQL> alter table students add marks number (10); Table altered. 0.02 seconds SQL> desc students;

MODIFY:
SQL> alter table students modify department varchar2 (20); Table altered. SQL> desc students;

RENAME:
SQL> rename students to BTechIT; Statement processed. SQL>desc BTechIT;

TRUNCATE:
SQL> truncate table BTechIT; Table truncated.

DROP:
SQL> drop table BTechIT; Table dropped.

RESULT:
Thus, the program for basic DDL commands is executed and output is verified.

Exp no: 02 Date: 20/11/08

DML AND DCL COMMANDS USING ORACLE

AIM:
To execute queries in the data manipulation language (DML) And data control language (DCL) commands using oracle.

QUEIRES: DML COMMANDS: 1. INSERT:


PURPOSE: For adding data to the database.

A) SINGLE-ROW INSERT STATEMENT:


PURPOSE: Adds a new row to the table. SYNTAX: Insert into table name ( columnname1,columnname2) values (value1,value2);

B) MULTI-ROW INSERT STATEMENT:


PURPOSE: Adds multiple rows of data SYNTAX: insert into tablename1 (columnname1,columnname2) select (columnname1,columnname2) from tablename2 Where columnname condition;

2. SELECT:
PURPOSE: It lists the data items from the database.

A) FROM: PURPOSE: It lists the tables that contain the data to be retrieved by the query. SYNTAX: select * from tablename; select columnname from tablename; B) WHERE: PURPOSE: It is used to specify the desired rows. SYNTAX: select columnname from tablename where columnnamecondition;

3. UPDATE:
PURPOSE: Modifies existing data in the database. SYNTAX: A) SINGLE-ROW: update tablename set columnname= [value1], columnname2= [value2] where {condition}; B) MULTI-ROW: update tablename setcolumnname= [new value] where {condition};

4. DELETE:
PURPOSE: To get rid of records from a table. SYNTAX: Delete from tablename where {condition};

DCL/TCL COMMANDS:
1. COMMIT: PURPOSE: Commit (make persistent) all changes for the current transaction, commit may cause a concurrent transaction conflict exception to be thrown. It is used to commit the database. SYNTAX: commit;

2. ROLLBACK:
PURPOSE: Rollback (rescind) all changes for the current transaction. Rollback option is used to rollback any work since the last commit. SYNTAX: A) rollback; B) rollback to savepoint [savepoint_name];

3. SAVEPOINT:
PURPOSE: The savepoint statement sets a named transaction savepoint with a name of identifier. If the current transaction has a savepoint with the same name, the old savepoint is deleted. SYNTAX: savepoint savepoint_name; 4.GRANT: PURPOSE: The grant statement enables system administrators to

create my SQL user accounts and grant rights to accounts. It gives privileges to users. SYNTAX: grant privilege on tablename to username; (For particular field) grant all on tablename to username; (For all) 5. REVOKE: PURPOSE: The revoke statement is to remove privilege from the user. SYNTAX: revoke privilege on tablename from username; (For particular field) revoke all on tablename from username; (For all) CREATE USER: PURPOSE: To create user accounts SQL. SYNTAX: Create user username identified by password;

OUTPUT:
INSERT: SQL> insert into student values ('07IT01','arun','IT','A'); SQL> insert into student values ('07IT05','brindha','IT','O'); SQL> insert into student values ('07IT10','sekar','IT','E'); 3 row(s) are inserted 0.02 seconds SELECT FROM SQL> select *from student

WHERE SQL> select name, grade from student where rollno='07IT01';

SQL> select name from student where dept='IT';

UPDATE SQL> update student set dept='CS', grade='B' where rollno='07IT01'; 1 row(s) updated SQL> select *from student

SQL> update student set dept=cs where dept=IT; 2 row(s) updated SQL> select *from student

DELETE SQL> delete from student where rollno='07IT05'; 1 row(s) deleted SQL> select *from student

COMMIT SQL> commit; All rows are committed automatically CREATE USER SQL> create user admin identified by admin; User created

REVOKE SQL> revoke all on student from admin; Statement processed;

GRANT SQL> grant all on student to admin; Statement processed;

RESULT:
Thus the basic DML and DCL commands are executed using oracle and the output is verified.

Exp no: 03 Date: 23/11/08

CURSORS

AIM:
To handle cursor commands using oracle. The commands are declare, open, fetch and close.

PROCEDURE:
1.Declare cursor with a cursor name which transferring details of the table. 2.Open the cursor. 3.After opening fetch the details in the cursor to the other table. 4.The loop is executed till the final value and exit the loop. 5.Close the cursor.

CREATING A CURSOR:
Creating a cursor involves four steps. 1. Declaring the cursor, the cursor receives a name and is assigned a select command. 2. Opening the cursor, the query is executed and the number of rows to be returned is determined. 3. Fetching the rows that is found is sent to the program in PL/SQL. 4. Closing the cursor, the oracle resources allocated to the cursor are freed.

1. DECLARING THE CURSOR:


PURPOSE: It is used to declare a cursor. SYNTAX: Declare Cursor cursor name [(parameter [, parameter])] [return return_type] is select command;

2. OPENING A CURSOR:
PURPOSE: The open command must be used to provide parameter for the cursor. SYNTAX: Open cursor name;

3. ACCESSING CURSOR ROWS:


PURPOSE: SQL uses the fetch command to read the contents of a row. Fetch reads the values of each column of the row that is specified by select command and assigns a variable. SYNTAX: Fetch cursor_name into column 1, column 2column n;

4. CLOSING A CURSOR:
PURPOSE: When a cursor is not in use, it must be closed. So oracle can free the resources that were allocated to it. SYNTAX: Close cursor_name;

OUTPUT:
1. Create a table item_master containing item id, item description, balance stock. SQL> create table item_master (item_id varchar2(20), item_desc varchar2(20), bal_stock number(20)); Table created. SQL> select * from item_master;
ITEM_ID 1 2 3 hamam colgate powder ITEM_DESC 146 406 215 BAL_STOCK

2. Create a table item_buyed containing item id, item description, quantity. SQL> create table item_buyed (item_id varchar2(20), item_desc varchar2(20), quantity number(20)); Table created. SQL> select * from item_buyed;
ITEM_ID 1 2 hamam colgate ITEM_DESC 23 78 QUANTITY

3 4

powder lizol

45 12

3. Write a PL/SQL block with CURSORS that would update balance stock in the item_master table each time an item bought. The change in the item_master depends on the item_id: i) If the item_id is already present in the item_master table then perform an update operation to increase the bal_stock by the quantity in the item_buyed table. ii) Incase of item_id is not present in the item_master table then it is added as a new item record in the item_master table. declare itid item.item_id%type; iteid itembuy.item_id%type; balst item.bal_stock%type; quant itembuy.bal_stock%type; itemdesc itembuy.item_desc%type; itemdeesc item.item_desc%type; cursor c is select item_id,item_desc,bal_stock from item; cursor d is select item_id,item_desc,bal_stock from itembuy; begin open d; open c; loop fetch d into iteid,itemdesc,quant; loop fetch c into itid,itemdeesc,balst; if(itid=iteid) then update item set bal_stock=balst+quant where item_id=iteid; exit; else insert into item values(iteid,itemdesc,quant); exit; end if; exit when(c%notfound);

end loop; exit when(d%notfound); end loop; close c; close d; end; 1 row(s) updated.

SQL> select * from item_master;

ITEM_ID 1 2 3 4 hamam

ITEM_DESC 169 484 260 12 colgate powder lizol

BAL_STOCK

RESULT:
Thus the basic cursor commands are executed and output is verified.

Exp no: 04 Date: 24/11/08

TRIGGERS

AIM:
To start certain tasks automatically when certain conditions are met using trigger in oracle.

DEFINITION:
A trigger is a statement that the system executes automatically as a side effect of a modification to the database.

PROCEDURE:
1.Create a table item_master with the fields item_id, item_desc and bal_stock. 2. Create a trigger named as trig1 to perform its action whenever a value is inserted into the table item_master. 3. Use the dbms_output.put_line statement to display the trigger. 4. End the trig1. 5. Now the trig1 is created. 6. Create trigger named as trig2 to perform its action whenever the values are inserted in to the table item_master by giving a particular condition. 7. Use the if statement to check the values in the table item_master. 8. Use the error statement to display the error message. 9. End the trigger trig2. 10. Check the working of triggers trig1 and trig2 by inserting the values into the table item_master. 11. Create a trigger named as trig3 to perform its action whenevrer changes are made to the table item_master. 12. If the bal_stock value is less than 10 then the error message is

displayed using the error statement. 13. Create a trigger named as trig5 to perform its action whenever a value is deleted from the table item_master. 14. If the value of old_item is i005 then show the error message. 15. Check the working of trigger trig5 by deleting the value from the table item_master. 16. Stop the program.

OUTPUT:
1. Create a trigger that will display user has created a row after every insert on item_master table. SQL> desc item_master

SQL> create or replace trigger tri1 after insert on item for each row declare begin dbms_output.put_line('***USER HAS INSERTD A ROW***'); end; Trigger created. SQL> set serveroutput on; SQL> insert into item_master values('05','pencil',10); ***USER HAS INSERTD A ROW*** 1 row(s) inserted. 2. Create a trigger that will not insert an item into the item_master. If the item_id is i001 or the item_desc is laptop. SQL> create or replace trigger tri1 after insert on item for each row declare begin

if(:new.item_id='i001' or :new.item_desc='laptop')then raise_application_error('-20001','YOU CANT INSERT THIS VALUE'); end if; end; Trigger created. SQL> insert into item_master values('i001','laptop',50000);

ORA-20001: ***YOU CANT INSERT THIS VALUE*** ORA-06512: at "trig.TRIG2", line 4 ORA-04088: error during execution of trigger 'trig.TRIG2'
SQL> insert into item_master values(i006,cinthol,222) ***USER HAS CREATED A ROW*** 1 row created 3. Create a trigger that will not the item_master if the bal_stock is <10. SQL> ed Wrote file afiedt.buf SQL> create or replace trigger tri3 before update on item for each row declare begin if(:new.bal_stock<10) then raise_application_error('-20002','YOU CANT update THIS VALUE'); end if; end; Trigger created. SQL> update item_master set bal_stock = 5 where item_desc=hamam SQL> update item_master set bal_stock-5 where item_desc=hamam

ORA-20002: YOU CANT UPDATE THIS VALUE ORA-06512: at "trigger.TRI3", line 4 ORA-04088: error during execution of trigger 'tirgger.TRI3'
SQL> update item_master set bal_stock=11 where item_desc=hamam

1 row updated 4. Create a trigger that will not delete an item if item_id is 1005. SQL> ed Wrote file afiedt.buf create or replace trigger tri4 before delete on item for each row when(old.item_id='01') declare begin raise_application_error('-20003','YOU CANT DELETE THIS VALUE'); end; Trigger created. SQL> delete from item_ where item_id='01'; SQL> delete from item_master where item_id=i006

ORA-20003: YOU CANT DELETE THIS VALUE ORA-06512: at " trigger.TRI4", line 3 ORA-04088: error during execution of trigger 'trigger.TRI4'
SQL> delete from item_master where item_id=i006 1 row deleted DROPING A TRIGGER: SQL> drop trigger trig4 Trigger dropped SQL> select * from item_master
ITEM_ID
1 2 3 4 4

ITEM_DESC
hamam colgate powder lizol lizol 169 484 260 12 12

BAL_STOCK

RESULT:
Thus, the program for trigger using oracle is executed and output is verified.

Exp no: 05 Date: 04/12/08

PROCEDURES AND FUNCTIONS

AIM:
To study the concepts of PL/SQL procedure and functions and to implement string manipulations and execute SQL queries on SQL functions and set operations.

ALGORITHM:
A)

FUNCTION:
1.Start the function. 2.Create a function iii with parameter item_sid to return a integer value. 3. Create a cursor to select item_id from the table item_master. 4. Create an alias name for item_id in item_master. 5. Compare the values of item_id and item_sid. 6. If values are same return 0 other wise return 1. 7. Now the function is created. 8. Create alias names for all the fields in the tables item_master and item_buyed. 9.Create cursor c to select the fields from the table item_master. 10.Create cursor d to select the fields from the table item_buyed. 11. Open the cursors c and d. 12. Fetch the values from the two tables item_master and item_buyed. 13. Return the value itemeid for the created function iii.. 14. If the return value is zero then update the values of bal_stock field in the item_master table using the condition bal_stock=balst+quant .

15. If the return value is one then the values are inserted into the item_master table. 16. End all the if loops and close the cursors. 17. Stop the program.
B)

PROCEDURE:
1. Start the procedure. 2. Create a procedure calculate with the parameters h_no, p_rding, and c_rding. 3.Calculate the unit by subtracting the values of c_rding and p_rding. 4. If the calculated unit is greater than 150 then the amount is updated as (100 + unit*1.5). 5. Else if the unit is greater than 50 and less than 100 then the amount is updated as(50 + unit*0.5). 6. Otherwise the given amount is calculated as ( unitt *0.5). 7. End all the if loops. 8. Update the values for the table bill_calc. 9. Now the procedure is created. 10. Create the cursor c1 by selecting the fields house_no, prev_rding and curr_rding from the table bill_calc. 11. Create the alias name for the cursor and call the function calculate to pass the parameter values. 12. End the loop . 13. Stop the program.

OUTPUT:
SQL> Create table bill_cal(house_no number,name varchar(20),prev_reading number,curr_reading number,unit number,amount number) SQL> insert into bill_cal values(25,'karthi',10,100,0,0) SQL> insert into bill_cal values(35,'arul',30,80,0,0) SQL> insert into bill_cal values(45,'jai',12,110,0,0) SQL> select * from bill_cal;

HOUSE_NO
25 35 45

NAME
karthi arul jai

PREV_READING
10 30 12

CURR_READING
100 80 110 0 0 0

UNIT
0 0 0

AMOUNT

SQL>create or replace procedure calculate(h_no number,p_rding number,c_rding number) is unitt number; amt number(8,2); begin unitt:=c_rding-p_rding; if(unitt>150)then mt:=100+unitt*1.5; else if(unitt>50 and unitt<100)then amt:=50+unitt*0.5; else amt:=unitt*0.5; end if; end if; update bill_cal set amount=amt where house_no=h_no; update bill_cal set unit=unitt where house_no=h_no; end;
Procedure created.

SQL> declare cursor c1 is select house_no,prev_reading,curr_reading from bill_cal; d c1%rowtype; begin

for d in c1 loop calculate(d.house_no,d.prev_reading,d.curr_reading); end loop; end;

HOUSE_NO
25 35 45 55

NAME
karthi arul jai mani

PREV_READING
10 30 12 15

CURR_READING
100 80 110 175

UNIT
90 50 98 160

AMOUNT
555 111 555 999

SQL> create or replace function iii(itemsid number)return number is cursor c1 is select item_id from item_master; d c1%rowtype; begin for d in c1 loop if(d.item_id=itemsid)then return 0; end if; end loop; return 1; end; Function created. SQL> declare i1 item_master.item_id%type; i2 item_buyed.item_id%type; b1 item_master.bal_stock%type; q item_buyed.quantity%type; d1 item_master.item_desc%type; d2 item_master.item_desc%type; cursor c is select item_id,item_desc,bal_stock from item_master; cursor d is select item_id,item_desc,quantity from item_buyed; retval number; begin

retval:=0; open d; open c; fetch c into i1,d1,b1; loop fetch d into i2,d2,q; retval:=iii(i2); if(retval=0)then update item_master set bal_stock=b1+q where item_id=i2; else if(retval=1)then insert into item_master values(i1,d1,b1); end if; end if; exit when(d%notfound); end loop; close d; close c; end;
Statement processed.

SQL> select * from item_master;


ITEM_ID
102 101 102 102 102 102

ITEM_DESC
clogate hamam clogate clogate clogate clogate

BAL_STOCK
613 613 359 613 613 359

RESULT:
Thus the program for procedure and functions is executed and the output is verified successfully

Exp no: 06 Date: 5/12/08 EMBEDDED SQL

AIM:
To implement an inventory management system using Embedded SQL.

ALGORITHM:
1. Type the coding in visual basic editor and connect the program to the MSAccess. 2. Test the connection made with MS-Access data base and connect to the proper server. 3. Run the program in VB 6.0 & Click according to the application for a new data base. 4. Enter the valid administrator / user login id and password and do the banking as per the login . 5. The entered datas is stored in the MS-Access. 6. Thus a VB 6.0 coding is connected using MS-Access and application is verified.

PROGRAM CODE:
LOGIN FORM Private Sub Login_Click() If Me.Text1.Text = "Admin" And Me.Text2.Text = "Admin" Then Me.Hide Form2.Show End If End Sub MAIN FORM Private Sub Exit_Click() End End Sub Private Sub Stck_Details_Click() Form4.Show Form3.Hide End Sub Private Sub Stck_Entry_Click() Form3.Show End Sub STOCK ENTRY FORM Dim con As New ADODB.Connection Dim rs As New ADODB.Recordset Dim sql As String Private Sub Form_Load() Set con = New ADODB.Connection con.Provider = "Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\886c\Desktop\DMBS_Record_Final\Inventory\I nventory.mdb;Persist Security Info=False" con.Open Set rs = New ADODB.Recordset rs.Open "select * from inventory", con, adOpenDynamic, adLockOptimistic End Sub

Private Sub Clear_Click() Me.Text1.Text = " " Me.Text2.Text = " " Me.Text3.Text = " " Me.Text4.Text = " " Me.Text5.Text = " " Me.Text6.Text = " " Me.Text7.Text = " " End Sub STOCK DETAILS FORM Stock Form Dim con As New ADODB.Connection Dim rs As New ADODB.Recordset Dim sql As String Private Sub Form_Load() Set con = New ADODB.Connection con.Provider = "Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\886c\Desktop\DMBS_Record_Final\Inventory\I nventory.mdb;Persist Security Info=False" con.Open Set rs = New ADODB.Recordset rs.Open "select * from inventory", con, adOpenDynamic, adLockOptimistic Call Disp End Sub Private Sub Update_Click() rs.Fields(0) = Me.Text1.Text rs.Fields(1) = Me.Text2.Text rs.Fields(2) = Me.Text3.Text rs.Fields(3) = Me.Text4.Text rs.Fields(4) = Me.Text5.Text rs.Fields(5) = Me.Text6.Text rs.Fields(7) = Me.Text7.Text rs.Fields(6) = Me.DTPicker1.Value rs.Update MsgBox "Record Updates..!", vbInformation Call Disp End Sub

Private Sub Delete_Click() rs.Delete rs.MoveNext MsgBox "Record Deleted..!", vbInformation Call Disp End Sub Private Sub First_Click() rs.MoveFirst If rs.BOF Then MsgBox "First Record..!", vbInformation Else Call Disp End If End Sub Private Sub Next_Click() On Error Resume Next rs.MoveNext If rs.EOF Then MsgBox "Last Record..!", vbInformation Else Call Disp End If End Sub Private Sub Command3_Click() rs.MovePrevious If rs.BOF Then MsgBox "First Record..!", vbInformation Else Call Disp End If End Sub Private Sub Last_Click() rs.MoveLast If rs.EOF Then MsgBox "Last Record..!", vbInformation Else Call Disp End If End Sub

LOGIN FORM

MAIN FORM

STOCK ENTRY:

STOCK DETAILS:

RESULT:
Thus the program for Embedded SQL is executed and the output is verified successfully.

Exp no: 07 Date: 09/12/08 DATABASE DESIGN

a) DATABASE DESIGN USING ER-MODEL AIM:


To design a database using ER-model for maintaining details in university register office.

QUERIES:
1. A university register office maintains data about following entities. I) Courses including number, title, credits, syllabus and prerequisites. II) Courses offerings including course number, year, semester section number, instruction, timing and class room. III) Student including student id, name and program. IV) Instructions including identification no. , name, department and title. Further, the enrollment of student in courses and grades awarded to students in each course they are enrolled for must be appropriately modeled. Construct an ER-diagram for the register office. Document all assumption that you make about the mapping constrains. 2. Consider a DB used to record the mark that the students get in different course offerings.

I) Construct an ER-diagram that model exams are entities and use a ternary relationship for above database. II) Construct an alternative ER-diagram that uses only binary relationship between students and course offerings. Make sure that only one relationship exist between particular student and course offering pair gets you can represent the marks i.e., students get in different exams of a course offering

EXPLANATION:
In the above ER-diagram the university has entities like instructor, student, course and course offerings. The instructor entity has attributes are ID NUMBER, which is the primary key, NAME, DEPARTMENT and TITLE. The student entity has attributes such as ID, NAME, and PROGRAMME. The course offering entity has attribute such as course number, year, semester, section number, timing, and classroom. Here TSA represents the specification which denotes the super class and sub class. Here the super class is university and instructor, student, course and course offering are subclass.

REQUIREMENTS:
i) Here the course offerings has entities such as model exams, exam and unit test which as ternary relationship. ii).Here the course offering has entity student and it has entity marks. Each of

which has the binary relationship.

IDNO. ID NAME NAMNA ME TITLE

Teach es

ID

INSTRUCTOR

STUDENT

NAME

IS A

Programme

DEPART MENT

Works for

Belongs to

University

SYLLABU S

COURSE NO.

Course TITLE

CREDIT S
PREREQUIST IES

IS A

Provid e

Offers

COURSE NO. YEAR

SEMESTER
Course offerings

SECTION NO.

INSTRUCTO R

TIMING
CLASS ROOM

Course offerings

Model exam

Condu ct

Exam

Unit test

Students

Prefe rs

Course offerings

Obtai n

Marks

b) DATABASE DESIGN USING NORMALIZATION AIM:


To design a normalization for the maintaining the details in university database.

QUERIES:
For the university database have the following requirements. a) The university keep track of each students name(SNAME), student number (SNUM), social security number (SSN), current address (SC ADDR) and permanent class (CLASS) (Graduate, fresh man) major department (MAJOR CODE), minor department (MINOR CODE), (if any), degree programme (PROG) (BA, B.Sc, PhD); both SSN and Student numbers have unique values for student. b) Each department is described by a name (DNAME), department

code (DCODE), office Phone (OPHONE) and college (DCOLLEGE). Both name and code have unique values for a department. c) Each course has a course name (CNMAE), description (CDESE),

course number (CNUM), no. of semester, hours (READY), Level (LEVEL), offerings department (CDEPT). The course number is unique for each course. d) Each section has instruction (NAME, SEMESTER), year(YEAR),course (SEC COURSE) Section number distinguishes different section of the same course that are transfer during the same semester of year. e) A grade records refer to a student of SSN, particular section and grade (GRADE). Design a database schema for this database application and

show al the functional dependency that should design the normalization for this relational schema.

FIRST NORMAL FORM:


o values. o First normal form disallows multi value & relation within relation. For department relation with the help of DCODE we can alter all the other fields. In this values are single values not multi valued. o For instructor relation with the help of section name (SEC. NAME) we can refer all the other field. This form concentrates on attributes that at holds atomic

SECOND NORMAL FORM:


This form deals with fully functional dependency and partial functional dependency. FUNCTIONAL DEPENDENCY With the help of SSN value we can refer al the other fields in a relation. PARTIAL FUNCTIONAL DEPENDENCY A value of one field refers some of the fields in a relation. Ex: with the help of SNUM we can refer BDATE & DEPT.

THIRD NORMAL FORM:


It depends on transitive dependency {X-Z{X-Y}}, {X-> Z}}

In course relation with the help of CNAME, CDESS and with the help of CNAME, we refer all the remaining fields LEVEL & CDEPT.

UNVERSITY SNAME SNUM SSN SCADDR SCPHONE SPADDR BDATE SEX CLASS MAJORCODE MINORCODE PROG

GRADE REC SSN SECTION GRADE

SECTION INAME SEMESTER YEAR SECCOURSE SECNUM

DEPARTMENT DNAME DCODE DOFFICE DPHONE DCOLLEGE

COURSE CNAME CDESC CNUM CREDIT LEVEL CDEPT

FIRST NORMAL FORM:

DNAME

DCODE

DOFFICE

DPHONE

DCOLLEGE

FDI

INAME

SEMESTER

YEAR

SECCOURSE

SECNUM

FDI

SSN

SECTION

GRADE

SECOND NORMAL FORM:

SSN

SNUM

BDATE

DEPT

GRADE

COURSE

SSUM

BDATE

DEPT

THIRD NORMAL FORM:


CNAME CDESC CNUM LEVEL CDEPT

CNAME

CDESC

CNUM

FDI

CNAME

LEVEL

CDEPT

FDI

UNIVERSITY:
SNAME SNUM SADDR SCADDR SCPHONE SPADDR BDATE SEX CLAS S MAJR CODE MINOR CODE PROG

TINA

105

01

DPI

26463620

DPI

18.10.88

AAA

BBN

B.Tec h

JAYA

106

02

CBE

2345672

HOPES

25.4.89

II

BBB

AAM

B.E

DEPARTMENT:
DNAME CSE IT DCODE O3 05 DOFFICE CBE CBE DPHONE 1111111 2222222 DCOLLEGE TCE TCE

COURSE:
CNAME B.Tech B.E CDESC BACH OF TECH BACH. OF ENG CNUM 05 06 CREDIT 11 10 LEVEL A A CDEPT IT CSE

SECTION:
INAME TINA JAYA SEMESTER VI VI YEAR 2008-2009 2008-2009 SECOURSE B.Tech B.E SECNUM 06 O6

GRADE RECORDS:
SSN 02 01 SECTION B.Tech B.E GRADE A A

RESULT:
Thus the normalization form for maintaining the details in university database has been obtained.

Exp no: 08 Date: 11/12/08 PAYROLL PROCESSING SYSTEM

AIM:
To implement a PAYROLL PROCESSING SYSTEM using Visual Basic 6.0 as front-end tool and Ms Access as backend tool.

ALGORITHM:
1. Type the coding in visual basic 6.0 editor and connect the program to the Ms Access. 2. Test the connection made with Ms Access database and

connects to the proper server. 3. Run the program in VB 6.0 & Click according to the application for a new database. 4. Enter the valid administrator / user login id and password and do the Payroll as per the login. 5. The entered datas is stored in the Ms Access server. 6. Thus a VB 6.0 coding is connected using Ms Access and application is verified.

PROGRAM CODE:
LOGIN FORM: Private Sub Command1_Click () If Me.Text1.Text = "admin" And Me.Text2.Text = "admin" Then Form2.Show Me.Hide Else MsgBox ("Invalid Username/Password") End If End Sub MAIN FORM: Private Sub payroll_Click () Form3.Show End Sub Private Sub exit_Click () End End Sub PAY FORM: Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset Dim a, b, c, d, e As Integer Public Sub Disp() Me.Text1.Text = rs.Fields (0) Me.Text2.Text = rs.Fields (1) Me.Text3.Text = rs.Fields (2) Me.Text4.Text = rs.Fields (3) Me.Text5.Text = rs.Fields (4) Me.Text7.Text = rs.Fields (5) Me.Text6.Text = rs.Fields (6) End Sub Private Sub calculate_Click () a = Val (Me.Text3.Text) b = Val (Me.Text4.Text) c = Val (Me.Text5.Text) d = Val (Me.Text7.Text) e = c - (a + b) Me.Text6.Text = e * d

End Sub

Private Sub clear_Click () Me.Text1.Text = "" Me.Text2.Text = "" Me.Text3.Text = "" Me.Text4.Text = "" Me.Text5.Text = "" Me.Text7.Text = "" Me.Text6.Text = "" End Sub Private Sub Form_Load () Set cn = New ADODB.Connection Set rs = New ADODB.Recordset cn.Open ("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=F:\DMBS_Record_Final\PAY\lokesh.mdb ;") rs.CursorType = adOpenDynamic rs.LockType = adLockOptimistic rs.Open "lokesh", cn a = MsgBox ("Connection OK", vbOKOnly) End Sub Private Sub next_Click () rs.MoveNext If rs.EOF Then rs.MoveLast MsgBox "Last Record" Else Call Disp End If End Sub Private Sub previous_Click () rs.MovePrevious If rs.BOF Then rs.MoveFirst MsgBox "First Record" Else Call Disp End If End Sub Private Sub save_Click () rs.Fields (0) = Me.Text1.Text rs.Fields (1) = Me.Text2.Text rs.Fields (2) = Me.Text3.Text rs.Fields (3) = Me.Text4.Text rs.Fields (4) = Me.Text5.Text

rs.Fields (5) = Me.Text7.Text rs.Fields (6) = Me.Text6.Text rs.Update End Sub

OUTPUT FORM: LOGIN FORM:

MAIN FORM:

PAYROLL FORM:

RESULT:

Thus the program for PAYROLL PROCESSING SYSTEM was executed and the output is verified successfully.

Exp no: 09 Date: 11/12/08 BANKING SYSTEM

AIM:
To implement a BANKING MANAGEMENT SYSTEM using Visual Basic 6.0 as front-end tool and Ms Access as backend tool.

ALGORITHM:
1. Type the coding in visual basic 6.0 editor and connect the program to the Ms Access. 2. Test the connection made with Ms Access database and connects to the proper server. 3. Run the program in VB 6.0 & Click according to the application for a new database. 4. Enter the valid administrator / user login id and password and do the banking as per the login. 5. The entered datas is stored in the Ms Access server. 6. Thus a VB 6.0 coding is connected using Ms Access and application is verified.

PROGRAM CODE:
LOGIN FORM: Private Sub login_Click () If Me.Text1.Text = "admin" And Me.Text2.Text = "admin" Then Me.Hide Form2.Show Else MsgBox ("Invalid User/Password..") End If End sub MAIN FORM: Private Sub Deposit_Click () Form3.Show End Sub Private Sub Exit_Click () End End Sub Private Sub withdraw_Click () Form3.Hide Form4.Show End Sub DEPOSIT FORM: Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset Dim dep, bal, db As Integer Public Sub Disp () Me.Text1.Text = rs.Fields (0) Me.Text5.Text = rs.Fields (1) Me.Text2.Text = rs.Fields (2) Me.DTPicker1.Value = rs.Fields (3) Me.Text3.Text = rs.Fields (4) End Sub Private Sub Clear_Click () Me.Text1.Text = "" Me.Text2.Text = "" Me.Text3.Text = "" Me.Text4.Text = "" Me.Text5.Text = ""

Me.DTPicker1 = "" End Sub Private Sub Deposit_Click () dep = Val (Me.Text4.Text) bal = Val (Me.Text3.Text) db = bal + dep Text3.Text = db rs.Fields (0) = Text1.Text rs.Fields (1) = Text5.Text rs.Fields (2) = Text2.Text rs.Fields (3) = DTPicker1.Value rs.Fields (4) = Text3.Text rs.Update End Sub Private Sub Form_Load () Set cn = New ADODB.Connection Set rs = New ADODB.Recordset cn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;DataSource= C:\Users\886c\Documents\bank.mdb ;") rs.CursorType = adOpenDynamic rs.LockType = adLockOptimistic rs.Open "deposit", cn a=MsgBox ("ConnectionOK", vbOKOnly) End Sub Private Sub Next_Click () rs.MoveNext If rs.EOF Then rs.MoveLast MsgBox "Last Record" Else Call Disp End If End Sub Private Sub Previous_Click () rs.MovePrevious If rs.BOF Then rs.MoveFirst MsgBox "First Record" Else Call Disp End If End Sub

WITHDRAW FORM: Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset Dim dep, bal, db As Integer Public Sub Disp () Me.Text1.Text = rs.Fields (0) Me.Text5.Text = rs.Fields (1) Me.Text2.Text = rs.Fields (2) Me.DTPicker1.Value = rs.Fields (3) Me.Text3.Text = rs.Fields (4) End Sub Private Sub Clear_Click () Me.Text1.Text = "" Me.Text2.Text = "" Me.Text3.Text = "" Me.Text4.Text = "" Me.Text5.Text = "" Me.DTPicker1 = "" End Sub Private Sub Form_Load () Set cn = New ADODB.Connection Set rs = New ADODB.Recordset cn.Open("Provider=Microsoft.Jet.OLEDB.4.0; DataSource=C:\Users\886c\Documents\bank.mdb;") rs.CursorType = adOpenDynamic rs.LockType = adLockOptimistic rs.Open "deposit", cn a = MsgBox ("Connection OK", vbOKOnly) End Sub Private Sub Next_Click () rs.MoveNext If rs.EOF Then rs.MoveLast MsgBox "Last Record" Else Call Disp End If End Sub Private Sub view_Click () Call Disp End Sub

Private Sub withdraw_Click () dep = Val (Me.Text4.Text) bal = Val (Me.Text3.Text) db = bal - dep Text3.Text = db rs.Fields (0) = Text1.Text Fields (1) = Text5.Text rs.Fields (2) = Text2.Text rs.Fields (3) = DTPicker1.Value rs.Fields (4) = Text3.Text rs.Update End Sub

OUTPUT FORM:
LOGIN FORM:

DEPOSIT FORM:

WITHDRAW FORM:

RESULT:
Thus the program for BANKING SYSTEM is executed and the output is verified successfully

Exp no: 10 Date: 14/12/08 LIBRARY MANAGEMENT SYSTEM

AIM:
To implement a LIBRARY MANAGEMENT SYSTEM using Visual Basic 6.0 as front-end tool and Ms Access as backend tool.

ALGORITHM:
1. Type the coding in visual basic 6.0 editor and connect the

program to the Ms Access. 2. Test the connection made with Ms Access database and connects to the proper server. 3. Run the program in VB 6.0 & Click according to the application for a new database. 4. Enter the valid administrator / user login id and password and do the login. 5. The entered datas is stored in the Ms Access server. 6. Thus a VB 6.0 coding is connected using Ms Access and application is verified.

PROGRAM CODE:
LOGIN FORM: Private Sub Command1_Click () If Me.Text1.Text = "admin" And Me.Text2.Text = "admin" Then Form2.Show Me.Hide Else MsgBox ("Invalid Username/Password") End If End Sub MAIN FORM: Private Sub bookissue_Click (Index As Integer) Form3.Show End Sub Private Sub bookreturn_Click (Index As Integer) Form3.Hide Form4.Show End Sub Private Sub exit_Click () End End Sub BOOK ISSUE FORM: Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset Public Sub Disp () Me.Text1.Text = rs.Fields (0) Me.Text2.Text = rs.Fields (1) Me.Text3.Text = rs.Fields (2) Me.Text4.Text = rs.Fields (3) Me.DTPicker1.Value = rs.Fields (4) Me.DTPicker2.Value = rs.Fields (5) End Sub Private Sub clear_Click () Me.Text1.Text = "" Me.Text2.Text = "" Me.Text3.Text = "" Me.Text4.Text = "" Me.DTPicker1 = "" Me.DTPicker2 = ""

End Sub Private Sub Form_Load () Set cn = New ADODB.Connection Set rs = New ADODB.Recordset cn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\DMBS_Record_Final\library\lib1.mdb;") rs.CursorType = adOpenDynamic rs.LockType = adLockOptimistic rs.Open "arul", cn a = MsgBox ("Connection OK", vbOKOnly) End Sub Private Sub next_Click () rs.MoveNext If rs.EOF Then rs.MoveLast MsgBox "Last Record" Else Call Disp End If End Sub Private Sub save_Click () rs.Fields (0) = Me.Text1.Text rs.Fields (1) = Me.Text2.Text rs.Fields (2) = Me.Text3.Text rs.Fields (3) = Me.Text4.Text rs.Fields (4) = Me.DTPicker1.Value rs.Fields (5) = Me.DTPicker2.Value rs.AddNew MsgBox ("Book Issued to: " & Me.Text1.Text & " Book ID: " & Me.Text3.Text & " Return Date: " & Me.DTPicker2.Value), vbInformation End Sub Private Sub view_Click () Call Disp End Sub BOOK RETURN FORM: Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset Public Sub Disp () Me.Text1.Text = rs.Fields (0) Me.Text2.Text = rs.Fields (1) Me.Text3.Text = rs.Fields (2) Me.Text4.Text = rs.Fields (3) Me.DTPicker1.Value = rs.Fields (5) Me.Text5.Text = rs.Fields (6)

End Sub Private Sub clear_Click (Index As Integer) Me.Text1.Text = "" Me.Text2.Text = "" Me.Text3.Text = "" Me.Text4.Text = "" Me.DTPicker1 = "" Me.Text5.Text = " " End Sub Private Sub Form_Load() Set cn = New ADODB.Connection Set rs = New ADODB.Recordset cn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\DMBS_Record_Final\library\lib1.mdb;") rs.CursorType = adOpenDynamic rs.LockType = adLockOptimistic rs.Open "arul", cn a = MsgBox ("Connection OK", vbOKOnly) End Sub Private Sub next_Click (Index As Integer) rs.MoveNext If rs.EOF Then rs.MoveLast MsgBox "Last Record" Else Call Disp End If End Sub Private Sub save_Click (Index As Integer) rs.Fields (0) = Me.Text1.Text rs.Fields (1) = Me.Text2.Text rs.Fields (2) = Me.Text3.Text rs.Fields (3) = Me.Text4.Text rs.Fields (4) = Me.DTPicker1.Value rs.Fields (5) = Me.DTPicker2.Value rs.Update MsgBox ("Book returned from: " & Me.Text1.Text & Book ID: " & Me.Text3.Text & Return Date: " & Me.DTPicker1.Value & " Fine Amount: " & Me.Text5.Text), vbInformation End Sub Private Sub view_Click (Index As Integer) Call Disp End Sub

OUTPUT

FORM:

LOGIN FORM:

MAIN FORM:

BOOK ISSUE FORM:

BOOK RETURN FORM:

RESULT:
Thus the program for LIBRARY MANAGEMENT SYSTEM is executed and the output is verified successfully.

Вам также может понравиться