0% found this document useful (0 votes)
27 views25 pages

ABHAY

Uploaded by

omstationary0578
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views25 pages

ABHAY

Uploaded by

omstationary0578
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 25

Lab Manual report

On

DATABASE MANAGEMENT SYSTEM (BCS-551)

Department of AI & DS

Submitted by: Submitted to:

ABHAY NIRANJAN NAWNEET KUMAR

Roll no - 2201321630001

B.Tech - 3rd Year

Semester - 5th

Index
S.n Pag
e
o NAME OF PRATICAL No.
1. Installing oracle/ MYSQL
2. Creating Entity-Relationship Diagram using case tools.
Writing SQL statements Using ORACLE /MYSQL:
a). Writing basic SQL SELECT statements.
b). Restricting and sorting data.
c). Displaying data from multiple tables.
3. d). Aggregating data using group function.
e). Manipulating data.
f). Creating and managing tables.

4. Normalization

5. Creating cursor

6. Creating procedure and functions

7. Creating packages and triggers

8. Design and implementation of payroll processing system

9. Design and implementation of Library Information System

10.. Design and implementation of Student Information System

11.Automatic Backup of Files and Recovery of Files


Mini project (Design & Development of Data and Application) for following:
a) Inventory Control System.
b) Material Requirement Processing.
c) Hospital Management System.
d) Railway Reservation System.
12. e) Personal Information System.
f) Web Based User Identification System.
g) Timetable Management System.
h) Hotel Management System
Experiment – 1

To install Oracle Database on windows 10 first download Oracle 11g 64 bit from
Oracle. Please follow the link given below to download Oracle Database 11g

http://www.oracle.com/technetwork/database/enterpriseedition/
downloads/index.html

After Oracle Database 11g download complete extract zip files then run setup.exe
from installation folder.

Select Create and configure database


Select Desktop Class then click on next for next step

Choose installation path where you want to install Oracle Database 11g after
that enter database name and admin password for your database.

Click finish to start Oracle Database installation


Oracle Database installation is started

Click in Allow access when prompted


Installing Oracle Database 11g on windows 10 is almost completed you can see
information about Oracle Database name, system identifier(SID) and the URL to
open or access Oracle Database on this page click OK to continue

Click finishes here Oracle Database 11g is installed on windows 10.


Experiment – 2

Objective: Creating Entity-Relationship Diagram using case tools.

Draw an ER Diagram for Deposit Relationship where Deposit is an association


between Customer and Account Entities.
Customer has following attributes: cust_id, cust_name, cust_age and cust_city.
Account has following attributes: acc_no, amount
Experiment – 3

Objective: Writing SQL statements Using ORACLE

SQL COMMANDS

CREATE TABLE: It defines each column of table uniquely. Each column has
minimum of three attributes name data type and size.

Syntax

CREATE TABLE table name (column_name1 datatype (size), column_name2


datatype(size) …);

Create table deposit (acno varchar2(5), cname varchar2(18), bname varchar2(18),


amount number(8,2), adate date);

SELECT: The select command of sql lets you make queries on the database.
It can be used to retrieve a subset of rows or columns from one or more tables.

Syntax
SELECT <column_name1>,<column_name2> FROM <table _name>;
DESCRIBE : To find information about columns like column name, their
data types and other attributes of a table we can use DESCRIBE command.

Syntax

DESCRIBE table name;


ALTER TABLE : After creating a table one may have need to change the
table either by add new columns or by modify existing columns. One can do so by
using alter table command.

Syntax to add a column

ALTER TABLE tablename ADD(col1 datatype,col2 datatype);

Syntax to modify a column

ALTER TABLE tablename MODIFY(col1 datatype,col2 datatype);

DELETE : One can delete data from table by using delete from statement.

Syntax of delete rows from table


DELETE FROM table name WHERE <condition>;
INSERT: To add new rows in an existing oracle table the insert command is used.

Syntax
INSERT INTO table name(col1,col2,col3,..)VALUES(value1,value2,value3);

Example

INSERT INTO employee(emp_id,ename,desg,basic_pay)VALUES(100001,’MOHIT’,’MANAGER’,55000);

Insert into deposit values (‘100’,’anil’,’vrce’,1000.00,’1-mar-95’);

UPDATE: The update command enables user to change the values of existing rows.

Syntax
UPDATE table name SET col1=value1,col2=value2;
Example
UPDATE emp_info SET salary =salary +100;
DROP TABLE: To remove the definition of oracle table, the drop table statement
is used.
Syntax

DROP TABLE table name;

RENAME: One can change the name of a table by rename command

Syntax
RENAME old name to new name
Experiment – 4
(SQL FUNCTIONS)

SUM (): The SUM() function returns the sum of all the values of the selected
Column.

Syntax:
SELECT SUM(column_name) FROM table_name;

MAX(): The MAX() function returns the maximum value of the selected
column.

Syntax:
SELECT MAX(column name) FROM table_name;

MIN(): The MIN() function returns the minimum value of the selected colume
AVG(): It returns average value after calculating from values in a numeric column.

Syntax:
SELECT AVG(column_name) FROM table name;

COUNT(): It is used to count the number of rows returned in a SELECT


statement. Itcan’t be used in MS ACCESS.

Syntax:
SELECT COUNT(column_name) FROM table_name;

FIRST (): The FIRST() function returns the first value of the selected
column.

Syntax:
SELECT FIRST(column_name) FROM table_name;

LAST (): The LAST () function returns the last value of the selected
column. It can beused only in MS ACCESS.

Syntax:
SELECT LAST (column_name) FROM table_name;
String functions are used to perform an operation on input string and return an
output string. Following are the string functions defined in SQL:

ASCII (): This function is used to find the ASCII value of a character.

CHAR_LENGTH (): This function is used to find the length of a word.

CHARACTER_LENGTH (): This function is used to find the length of a line.


CONCAT (): This function is used to add two words or strings.

CONCAT_WS(): This function is used to add two words or strings with a


symbol as concatenating symbol.

FIND_IN_SET(): This function is used to find a symbol from a set of symbols.


Syntax: SELECT FIND_IN_SET('b', 'a, b, c, d, e, f');

FORMAT (): This function is used to display a number in the given format.

INSERT(): This function is used to insert the data into a database.

INSTR(): This function is used to find the occurrence of an alphabet.

LCASE(): This function is used to convert the given string into lower case.

LEFT(): This function is used to SELECT a sub string from the left of given
size or characters.

LENGTH(): This function is used to find the length of a word.

LOCATE(): This function is used to find the nth position of the given word in a
string.

LOWER(): This function is used to convert the upper case string into lower case.

LPAD(): This function is used to make the given string of the given size by adding

LTRIM(): This function is used to cut the given sub string from the original string.

MID(): This function is to find a word from the given position and of the given
size.
POSITION(): This function is used to find position of the first occurrence of the
given alphabet.

REPEAT(): This function is used to write the given string again and again till the
number of times mentioned
.
REPLACE(): This function is used to cut the given string by removing the given
sub string.

REVERSE(): This function is used to reverse a string.

RIGHT(): This function is used to SELECT a sub string from the right end of the
given size.

Syntax: SELECT RIGHT('GNIOT.org', 4);


Experiment No: 5

SQL Constraints

SQL constraints are used to specify rules for the data in a table.
The following constraints are commonly used in SQL:--->

NOT NULL - Ensures that a column cannot have a NULL value


 UNIQUE - Ensures that all values in a column are different
 PRIMARY KEY - A combination of a NOT NULL and

UNIQUE. Uniquely identifies each row in a table


 FOREIGN KEY - Uniquely identifies a row/record in another table
 CHECK - Ensures that all values in a column satisfies a specific condition
 DEFAULT - Sets a default value for a column when no value is specified
 INDEX - Used to create and retrieve data from the database very quickly.
Experiment No: 6

The SQL Joins clause is used to combine records from two or more tables in a
database. A JOIN is a means for combining fields from two tables by using values
common to each.
Consider the following two

Table 1 − CUSTOMERS Table

| ID | NAME | AGE | ADDRESS |SALARY|


| 2 | Khilan | 25 | Delhi | 1500.00 |
| 3 | kaushik | 23 | Kota | 2000.00 |

Table 2 − ORDERS Table

Now, let us join these two tables in our SELECT statement as shown below.
This would produce the following result.

| ID | NAME | AGE | AMOUNT |


| 3 | kaushik | 23 | 3000 |
| 3 | kaushik | 23 | 1500 |
| 2 | Khilan | 25 | 1560 |
| 4 | Chaitali | 25 | 2060 |

Now, let us join these two tables in our SELECT statement as shown below

SQL> SELECT ID, NAME, AGE, AMOUNT FROM CUSTOMERS, ORDERS WHERE CUSTOMERS.ID =
ORDERS.CUSTOMER_ID;

This would produce the following result


ID | NAME | AGE | AMOUNT |
| 3 | kaushik | 23 | 3000 |
| 3 | kaushik | 23 | 1500 |
| 2 | Khilan | 25 | 1560 |
| 4 | Chaitali | 25 | 2060

Here, it is noticeable that the join is performed in the WHERE clause. Several
operators can be used to join tables, such as =, <, >, <>, <=, >=,! =, BETWEEN,
LIKE, and NOT; they can all be used to join tables.
There are different types of joins available in SQL −>

 INNER JOIN − returns rows when there is a match in both tables.

 LEFT JOIN − returns all rows from the left table, even if there are no matches
in the righttable.

RIGHT JOIN − returns all rows from the right table, even if there
are no
matches in the lefttable.

 FULL JOIN − returns rows when there is a match in one of the tables.

 SELF JOIN − is used to join a table to itself as if the table were two
tables, temporarilyrenaming at least one table in the SQL statement.

CARTESIAN JOIN − returns the Cartesian product of the sets of records


from the two or more joined tables.
SQL Queries on LIKE Pattern

The LIKE operator is used in a WHERE clause to search for a specified pattern in
a column.There are two wildcards often used in conjunction with the LIKE
operator:

 % - The percent sign represents zero, one, or multiple characters


 _ - The underscore represents a single character

The percent sign and the underscore can also be used in combinations! LIKE

Syntax
SELECT column1, column2, FROM table_name WHERE column N LIKE
pattern;
Experiment No: 7

Objective: Creating cursor in oracle

Theory:
There are two types of cursor
Explicit cursor
Implicit cursor

A. Explicit cursor

An explicit cursor is one in which cursor name is explicitly assigned to select


statement. An implicit cursor is used for all other sql statements. Processing of an
explicit cursor involves four steps. Processing of an implicit cursor is taken care by
PL/SQL .the declaration of the cursor is done in the declarative part of the block.

After declaring a cursor, we can use the following commands to control the cursor.
Open
Fetch
Close

declare
c_rollno stud.rollno%type;
cursorst is select rollno from stud where rollno=1; begin
openst; loop
fetchst into c_rollno;
update stud set lastname='barde' where rollno=c_rollno; exit when st %
NOT FOUND;
end loop;
dbms_output.put_line('table updated'); close st;
end;
output:table updated

In the above cursor we are going to update the table. Name of table is stud and its
attributes are rollno which is number, first name which is of data type varchar2,last
name which is of data type varchar2.

In the Declare section we declare variable that match to the attribute in the table
%TYPE matches the datatype of that variable.In the above procedure c_rollno is
the variable that we declare in the procedure to access the column rollno from table
stud because of %type it directly provide matching of data.
In the begin section we open the cursor and fetch the values. Error handles by the
exception section. Close the cursor. And end;

Experiment No:7(A)

PROCEDURE
Objective: Creating Procedure in Oracle

Theory:
PL/SQL supports the two types of programming:
Procedure.
Function.
Procedures are usually used to perform any specific task and functions are used to
compute a value.

PROCEDURE
The basic syntax for the creating procedure is:

CREATE OR REPLACE PRODURE procedure _name (arguments)AS/IS


procedure body;The body of procedure is block of statements with declarative
executable and exception sections.The declarative section is located between the IS
/AS keyword and BEGIN keyword. The executable section is located between
BEGIN and EXCEPTION keywords or between the BEGIN and END keywords if
there is no EXCEPTION handling section. If EXCEPTION handling is present, it
is located between exception and END keywords.

Steps for Creating Procedure:


CREATE OR REPLACE PRODURE procedure _name (parameter list) AS/IS
(Declarative section)
BEGIN
(Executable section)
EXCEPTION
(Error handling or exception section).
End the procedure name
To execute the procedure we have to write a block of statement: Begin
Procedure name (data);
End;
/
create or replace procedure add new stud(
p_rollnostud.rollno%type,
p_firstnamestud.firstname%type,
p_lastnamestud.firstname%type) as begin
insert into
stud(rollno,firstname,lastname)values(p_rollno ,p_firstname,p_lastname);
end addnewstud;/

output:Procedure created.

begin add newstud(2,'rohini','narwade'); end;


/
In the above procedure we are inserting data into the table. Here procedure name is
add new stud and take the variables like p_rollno, p_firstname, p_lastname having
attribute in the table rollno, firstname, last name respectively.in the begin section
begin executable code is written. In the above procedure we are inserting the value
so write the query to insert the data then end procedure by the end procedure then /

Experiment No: 7(C)


FUNCTION
CREATE OR REPLACE FUNCTION function _name (parameter list) AS/IS
Return datatype is/as(local declaration)

BEGIN
(Exception section)
EXCEPTION
(Error handling or exception section).
End Function name;

A function has two parts, namely function specification and function body. The
function specification begins with the keyword function and end with return
clause. The function bodies begins with the keyword is/as and end with keyword
end

create or replace function studentn(p_rollnostud.rollno%type) returnboolean as


v_firstname varchar2(20); v_returnboolean;
begin
selectfirstname into v_firstname from stud where rollno=p_rollno; if
(firstname='seema')then
v_return =true; else
v_return =false; end if;
end studentn;

Experiment No: 8
Objective: Design and implementation of Student Information System

Specification- To create a database with an interface for implementing student


information system for an educational organization.

a.) Hardware & Software Design Requirements


S.No Requirements Configuration
1. System 1
2. Operating System Windows Windows 7 or higher/Linux
3. Front End C++/Java/Php etc.
4. Back End Oracle 9i/MySql

b.) Steps for Achieving Objective

i.Create the database design with required tables (using SQL) as:
Admin(admin_id, admin_name, admin_pass)
Student_Details(roll_no, name, age, address, dob, email_id, phno, course_enrolled,
section, group etc as required)
Department(dept_id, dept_name, head_name etc. as required)
(Apart from these additional tables/fields can be added as required)

ii. Create the system design with features for adding students by admin after login,
students could view and update their details, department could enroll and view
students as per the database design created in step i.

iii. Basic project should contain required design forms with features to support step

You might also like