Dbms Lab File
Dbms Lab File
(BCS-551)
Student Name
Roll No.
Section-Batch
1. Students are advised to come to the laboratory at least 5 minutes before (to the starting
time), those who come after 5 minutes will not be allowed into the lab.
2. Plan your task properly much before to the commencement, come prepared to the lab with
the synopsis /program/experiment details.
Laboratory observation notes with all the details (Problem statement, Aim, Algorithm,
Procedure, Program, Expected Output, etc.,) filled in for the lab session.
Laboratory Record updated up to the last session experiments and other utensils (if
any) needed in the lab.
4. Sign in the laboratory login register, write the TIME-IN, and occupy the computer system
allotted to you by the faculty.
5. Execute your task in the laboratory, and record the results / output in the lab observation
note book, and get certified by the concerned faculty.
6. All the students should be polite and cooperative with the laboratory staff, must maintain
the discipline the laboratory.
7. Computer labs are established with sophisticated and high end branded systems, which
should be utilized properly.
8. Students / Faculty must keep their mobile phones in SWITCHED OFF mode during the lab
sessions. Misuse of the equipment, misbehaviors with the staff and systems etc., will attract
severe punishment.
9. Students must take the permission of the faculty in case of any urgency to go out; if any
body found loitering outside the lab / class without permission during working hours will be
treated seriously and punished appropriately.
10. Students should LOG OFF/ SHUT DOWN the computer system before he/she leaves the
lab after completing the task (experiment) in all aspects. He/she must ensure the system / seat
is kept properly.
4
DETAILS OF THE EXPERIMENTS CONDUCTED
(TO BE USED BY THE STUDENTS IN THEIR RECORDS)
INDEX
5 Creating cursor
5
PRACTICAL -1
To install the Oracle software, you must use the Oracle Universal installer.
1. For this installation, you need either the DVDs or a downloaded version of the DVDs. In this tutorial, you
install from the downloaded version. From the directory where the DVD files were unzipped, open
Windows Explorer and double-click on setup.exe from the \db\Disk1 directory.
2. The product you want to install is Oracle Database 11g. Make sure the product is selected and
click Next.
3. You will perform a basic installation with a starter database. Enter orcl for the Global Database Name
and oracle for Database Password and Confirm Password. Then, click Next
4. Oracle Configuration Manager allows you to associate your configuration information with your Metalink
account. You can choose to enable it on this window. Then, click Next.
6
5. Review the Summary window to verify what is to be installed. Then, click Install.
7
9. When the database has been created, you can unlock the users you want to use. Click OK.
To test that your installation completed successfully, perform the following steps:
https://<hostname>:1158/em
8
where <hostname> should be changed to your machine name, IP address, or localhost.
Because Enterprise Manager Database Control is a secure site, you need a certificate. Select the Accept
this certificate permanently option, and then click OK.
2. Enter system as the User Name and oracle as the Password, and then click Login
3. The Database Control Home Page appears. Your installation was successful.
9
5. Login again and then create a new database user by filling the below entries and click on creating
workspace
6. Login by using your created username and password and start using ORACLE
10
PRACTICAL -2
2.1 Objective 2.2 Theory (Installation&Dia Guide) 2.3 Assignment 2.4 Solution to Assignment
a. Installation Guide
11
4. In the “License Agreement” window click “Next” to continue installation.
12
6. Choose the installation location on your computer and click “Install”.
13
b. Dia User Guide
Create an ER Diagram
In this section, basic guidelines are given on how to create ER database diagrams. An ER diagram consists of
entity sets, attributes, and the relationship sets between entity sets. Let us create an ER diagram for a
database called “Courses and Students”. The database will have two main entity sets, i.e., “Course” and
“Student”. The relation between them defines which students belong to which course.
2. On the left side of the menu click on the dropdown menu, select “Other sheets” and click on “ER”.
14
3. Now the menu consists only of shapes that are relevant to an ER diagram.
4. Let us create an entity called “Course”. Choose the “E” icon with a single frame in the shapes menu and
click on the drawing space at the center. A rectangle with the name “Entity” will appear.
15
5. Double-click on the new entity set and the properties window will show up (or right-click and choose
“Properties”). Change the name of the entity set to “Course” and click “OK”. The entity sets name will be
changed.
6. The “Course” entity set has several attributes: “courseId” (primary key), “title”, “ECTS”, “level”,
“language”. In the shape menu select the “A” icon with an oval around it and click near the created
“Course” entity set. An oval with the name “Attribute” will appear.
16
7. Double-click on the attribute and in the properties window change the name to “courseId”. Since this
attribute is also a primary key, select “Key” value “Yes”. Click “OK”.
8. In the shape menu click on the “Participation” icon and connect the entity set with the attribute.
17
9. It is also possible to connect an entity set with an attribute using different connectors. Choose the
appropriate style at the end of a new connector by clicking on “arrow style at the end of the line new
lines”. Select “line (L)” connector.
10. Proceed with the rest of the attributes of the entity set “Course”.
18
11. Attributes of the “Student” entity set are: “studentId”, “firstName”, “lastName”, “startDate”.
12. Create the relationship set between “Course” and “Student” with the name “Belongs” that also
has an attribute “signUpDate”. In the shape menu select “R” with a diamond around it and click
between the two entity sets in the drawing area.
4
13. Change the name to “Belongs” and assign attribute “signUpDate” to it.
The ER diagram for database “Courses and Students” was created successfully!
Note: saveyour diagram several times through all the creation process!
5
2.3 Assignment:
A university wants to set up a database to record details about its staff, and the departments they
belong to. They intend to record the following information.
• For each member of staff, their staff identity number, name, job title, and salary.
• For each department, its name and address.
• For each member of staff, all departments that they belong to. It is required that every member of
staff belongs to at least one department.
• For each department, the head of department. It is required that each department has exactly one
head of department.
Draw an ER diagram that expresses the requirements for the database. Make sure that you capture
all the constraints on the data mentioned above.
6
PRACTICAL -3
TITLE : CREATING TABLES, INSERT INTO TABLES & SELECT FROM TABLES
View definition-
The SQL DDL includes commands for defining views.
Transaction Control- SQL includes for specifying the beginning and ending of transactions.
Integrity-
The SQL DDL includes commands for specifying integrity constraints that the data stored in the
database must specify. Updates that violate integrity constraints are allowed.
Authorization-
The SQL DDL includes commands for specifying access rights to relations and views.
The SQL DDL allows specification of not only a set of relations but also information about each
relation, including-
Schema for each relation
The domain of values associated with each attribute.
The integrity constraints.
The set of indices to be maintained for each relation.
The security and authorization information for each relation.
The physical storage structure of each relation on disk.
7
Domain types in SQL-
Syntax-
Create table tablename
(column name datatype(size), column name datatype(size));
Syntax-
CREATE TABLE TABLENAME
[(columnname, columnname, ………)]
AS SELECT columnname, columnname……..FROM tablename;
Syntax-
INSERT INTO tablename
[(columnname, columnname, ………)]
Values(expression, expression);
Syntax-
INSERT INTO tablename
SELECT columnname, columnname, …….
FROM tablename;
Syntax-
INSERT INTO tablename
SELECT columnname, columnname……..
FROM tablename
WHERE columnname= expression;
8
Retrieving of data from the tables-
Syntax-
SELECT * FROM tablename;
Syntax-
SELECT columnname, columnname, ….
FROM tablename;
Syntax-
SELECT DISTINCT columnname, columnname
FROM tablename;
Syntax-
SELECT columnname, columnname
FROM tablename
WHERE searchcondition;
3.3 ASSIGNMENT
ii) Product_master
Columnname datatype size
Product_no varchar2 6
Description varchar2 20
Profit_percent number 10,2
Unit_measure varchar2 10
Qty_on_hand number 10
Reoder_lvl number 10
Sell_price number 10
Cost_price number 10
9
Q2- Insert the following data into their respective tables:
Q3:- On the basis of above two tables answer the following queries:
i) Find out the names of all the clients.
ii) Retrieve the list of names and cities of all the clients.
iii) List the various products available from the product_master table.
iv) List all the clients who are located in Bombay.
v) Display the information for client no 0001 and 0002.
vi) Find the products with description as ‘1.44 drive’ and ‘1.22 Drive’.
vii) Find all the products whose sell price is greater then 5000.
viii) Find the list of all clients who stay in in city ‘Bombay’ or city ‘Delhi’ or ‘Madras’.
ix) Find the product whose selling price is greater than 2000 and less than or equal to 5000.
x) List the name, city and state of clients not in the state of ‘Maharashtra’.
10
3.4. SOLUTION TO ASSIGNMENT
Q.3. Solutions
i. select name from client_master;
ii. select name, city from client_master;
iii. select description from product_master;
iv. select * from client_master where city = ‘bombay’;
v. select * from client_master where client_no = ‘0001’ orclient_no = ‘ ‘0002’;
vi. select * from product_master where description=’1.44 drive’ or ‘1.22 drive’;
vii. select * from product_master where sell_price> 5000;
viii. select * from client_master where city = ‘bombay’ or city = ‘madras’;
ix. select * from product_master where sell_price> 2000 and sell_price<= 5000;
x. select name, city , state from client_master where state not in (‘maharastra’);
11
TITLE :DATA MANIPULATION LANGUAGE
3.1 Objective 3.2 Theory and concepts 3.3 Assignment 3.4. Solution to Assignment
Deletion Operation:-
A delete request is expressed in much the same way as query. We can delete whole tuple ( rows) we
can delete values on only particulars attributes.
Syntax:
Delete from tablename :
+ Addition - Subtraction
* multiplication ** exponentiation
/ Division () Enclosed operation
Renaming columns used with Expression Lists: - The default output column names can be renamed
by the user if required
12
Syntax:
Logical Operators:
The logical operators that can be used in SQL sentenced are
Pattern Searching:
The most commonly used operation on string is pattern matching using the operation ‘like’ we
describe patterns by using two special characters.
Percent (%) ; the % character matches any substring we consider the following examples.
‘Perry %’ matches any string beginning with perry
‘% idge % matches any string containing’ idge as substring.
‘ - - - ‘ matches any string exactly three characters.
‘ - - - % matches any string of at least of three characters.
Oracle functions:
Functions are used to manipulate data items and return result. Function follow the format of
function _name (argument1, argument2 ..) .An arrangement is user defined variable or constant.
The structure of function is such that it accepts zero or more arguments.
Examples:
Avg return average value of n
Syntax:
Avg ([distinct/all]n)
Min return minimum value of expr.
Syntax:
MIN((distict/all )expr)
Count Returns the no of rows where expr is not null
Syntax:
Count ([distinct/all)expr]
Count (*) Returns the no rows in the table, including duplicates and those with nulls.
Max Return max value of expr
Syntax:
Max ([distinct/all]expr)
13
Sum Returns sum of values of n
Syntax:
Sum ([distinct/all]n)
3.3 ASSIGNMENT
Que.1 Using the table client master and product master answer the following queries.
14
TITLE:TO IMPLEMENT CONSTRAINTS ON TABLES.
3.1 Objective 3.2 Theory and concepts 3.3 Assignment 3.4. Solution to Assignment
i. Column Level Constraints: If the constraints are defined along with the column definition, it
is called a column level constraint.
ii. Table Level Constraints: If the data constraint attached to a specify cell in a table reference
the contents of another cell in the table then the user will have to use table level
constraints.
Null Value Concepts:-while creating tables if a row locks a data value for particular column that
value is said to be null . Column of any data types may contain null values unless the column was
defined as not null when the table was created
Syntax:
Primary Key: primary key is one or more columns is a table used to uniquickly identity each row in
the table. Primary key values must not be null and must be unique across the column. A multicolumn
primary key is called composite primary key.
Unique key concept:-A unique is similar to a primary key except that the purpose of a unique key is
to ensure that information in the column for each record is unique as with telephone or devices
license numbers. A table may have many unique keys.
15
Default value concept: At the line of cell creation a default value can be assigned to it. When the
user is loading a record with values and leaves this cell empty, the DBA wil automatically load this
cell with the default value specified. The data type of the default value should match the data type
of the column
Syntax:
Foreign Key Concept :Foreign key represents relationship between tables. A foreign key is column
whose values are derived from the primary key of the same of some other table .the existence of
foreign key implies that the table with foreign key is related to the primary key table from which the
foreign key is derived .A foreign key must have corresponding primary key value in the primary key
table to have meaning.
Foreign key as a column constraint
Syntax :
Create table table name
(columnnamedatatype (size) references another table name);
Syntax :
Create table name
(columnnamedatatype (size)….
primary key (columnname);
foreign key (columnname)references table name);
Check Integrity Constraints: Use the check constraints when you need to enforce intergrity rules
that can be evaluated based on a logical expression following are a few examples of appropriate
check constraints.
A check constraints name column of the coient_master so that the name is entered
in upper case.
A check constraint on the client_no column of the client _master so that no
client_no value starts with ‘c’
Syntax:
Create table tablename
(columnnamedatatype (size) CONSTRAINT constraintname)
Check (expression));
3.3 ASSIGNMENTS:
Que.1 Create the following tables:
i. Sales_master
Columnname Datatype Size Attributes
Salesman_no varchar2 6 Primary key/first letter
must start with ‘S’
Sal_name varchar2 20 Not null
Address varchar2 Not null
16
City varchar2 20
State varchar2 20
Pincode Number 6
Sal_amt Number 8,2 Not null, cannot be 0
Tgt_to_get Number 6,2 Not null, cannot be 0
Ytd_sales Number 6,2 Not null, cannot be 0
Remarks Varchar2 30
ii. Sales_order
Columnname Datatype Size Attributes
S_order_no varchar2 6 Primary/first letter must be 0
S_order_date Date 6 Primary key reference clientno of
client_master table
Client_no Varchar2 25
Dely_add Varchar2 6
Salesman_no Varchar2 6 Foreign key references
salesman_no of salesman_master
table
Dely_type Char 1 Delivery part(p)/full(f),default f
Billed_yn Char 1
Dely_date Date Can not be lessthans_order_date
Order_status Varchar2 10 Values (‘in process’;’fulfilled’;back
order’;’canceled
I. Sales_order_details
Column Datatype Size Attributes
Insert the following data into their respective tables using insert statement:
Data for sales_man master table
Salesman_n Salesma Address City Pin code State Salamt Tgt_to_ Ytd Remark
o n name get Sales
S00001 Kiran A/14 Bom 400002 Mah 3000 100 50 Good
worli bay
17
S00002 Manish 65,narim Bom 400001 Mah 3000 200 100 Good
an bay
S00003 Ravi P-7 Bom 400032 Mah 3000 200 100 Good
Bandra bay
S00004 Ashish A/5 Juhu Bom 400044 Mah 3500 200 150 Good
bay
(ii)
Data for salesorder table:
S_orderno S_orderdate Client no Dely Bill Salesman no Delay Orderstatus
type yn date
019001 12-jan-96 0001 F N 50001 20-jan- Ip
96
019002 25-jan-96 0002 P N 50002 27-jan- C
96
016865 18-feb-96 0003 F Y 500003 20-feb- F
96
019003 03-apr-96 0001 F Y 500001 07-apr- F
96
046866 20-may-96 0004 P N 500002 22-may- C
96
010008 24-may-96 0005 F N 500004 26-may- Ip
96
(iii)
Data for sales_order_details table:
18
3.4 SOLUTION TO ASSIGNMENT:
Q.2. Insert the following data into their respective tables using insert statement:
(i) Insert into sales_master
Values(‘S0001’,’kiran’,’a/14 worli’,’bombay ’,’400002 ’,’mah ’,’3000 ’,’100 ’,’50 ’,’good’);
19
TITLE : MODIFYING THE STRUCTURES OF THE TABLE.
3.1 Objective 3.2 Theory and concepts 3.3 Assignment 3.4. Solution to Assignment
3.2 THEORY AND CONCEPTS: Modifying the Structure of Tables- Alter table command is used to
changing the structure of a table. Using the alter table clause you cannot perform the following
tasks:
The following tasks you can perform through alter table command.
NOTE: Oracle not allow constraints defined using the alter table, if the data in the table, violates
such constraints.
Syntax:
DROP TABLE tabename:
You can also define integrity constraints using the constraint clause in the ALTER TABLE command.
The following examples show the definitions of several integrity constraints.
20
You can drop an integrity constraint if the rule that if enforces is no longer true or if the constraint is
no longer needed. Drop the constraint using the ALTER TABLE command with the DROP clause. The
following examples illustrate the droping of integrity constraints.
3.3 ASSIGNMENT:
Q2. Insert the following values into the challan header and challan_details tables:
21
CH3965 P00001 5
CH3965 P07975 2
Q.2. Insert the following values into the challan header and challan_details tables:
Insert into challan_header
Values(‘ch9001’,’019001’,’12-dec-95’,’Y’);
22
PRACTICAL - 4
TITLE : Normalization
4.2 THEORY AND CONCEPTS: Normalization is the process of organizing data in a database. This
includes creating tables and establishing relationships between those tables according to rules
designed both to protect the data and to make the database more flexible by eliminating
redundancy and inconsistent dependency.
Redundant data wastes disk space and creates maintenance problems. If data that exists in more
than one place must be changed, the data must be changed in exactly the same way in all locations.
A customer address change is much easier to implement if that data is stored only in the Customers
table and nowhere else in the database.
What is an "inconsistent dependency"? While it is intuitive for a user to look in the Customers table
for the address of a particular customer, it may not make sense to look there for the salary of the
employee who calls on that customer. The employee's salary is related to, or dependent on, the
employee and thus should be moved to the Employees table. Inconsistent dependencies can make
data difficult to access because the path to find the data may be missing or broken.
There are a few rules for database normalization. Each rule is called a "normal form." If the first rule
is observed, the database is said to be in "first normal form." If the first three rules are observed, the
database is considered to be in "third normal form." Although other levels of normalization are
possible, third normal form is considered the highest level necessary for most applications.
As with many formal rules and specifications, real world scenarios do not always allow for perfect
compliance. In general, normalization requires additional tables and some customers find this
cumbersome. If you decide to violate one of the first three rules of normalization, make sure that
your application anticipates any problems that could occur, such as redundant data and inconsistent
dependencies.
Do not use multiple fields in a single table to store similar data. For example, to track an inventory
item that may come from two possible sources, an inventory record may contain fields for Vendor
Code 1 and Vendor Code 2.
23
What happens when you add a third vendor? Adding a field is not the answer; it requires program
and table modifications and does not smoothly accommodate a dynamic number of vendors.
Instead, place all vendor information in a separate table called Vendors, then link inventory to
vendors with an item number key, or vendors to inventory with a vendor code key.
Create separate tables for sets of values that apply to multiple records.
Relate these tables with a foreign key.
Records should not depend on anything other than a table's primary key (a compound key, if
necessary). For example, consider a customer's address in an accounting system. The address is
needed by the Customers table, but also by the Orders, Shipping, Invoices, Accounts Receivable, and
Collections tables. Instead of storing the customer's address as a separate entry in each of these
tables, store it in one place, either in the Customers table or in a separate Addresses table.
Values in a record that are not part of that record's key do not belong in the table. In general,
anytime the contents of a group of fields may apply to more than a single record in the table,
consider placing those fields in a separate table.
For example, in an Employee Recruitment table, a candidate's university name and address may be
included. But you need a complete list of universities for group mailings. If university information is
stored in the Candidates table, there is no way to list universities with no current candidates. Create
a separate Universities table and link it to the Candidates table with a university code key.
EXCEPTION: Adhering to the third normal form, while theoretically desirable, is not always practical.
If you have a Customers table and you want to eliminate all possible interfield dependencies, you
must create separate tables for cities, ZIP codes, sales representatives, customer classes, and any
other factor that may be duplicated in multiple records. In theory, normalization is worth pursing.
However, many small tables may degrade performance or exceed open file and memory capacities.
It may be more feasible to apply third normal form only to data that changes frequently. If some
dependent fields remain, design your application to require the user to verify all related fields when
any one is changed.
Fourth normal form, also called Boyce Codd Normal Form (BCNF), and fifth normal form do exist, but
are rarely considered in practical design. Disregarding these rules may result in less than perfect
database design, but should not affect functionality.
1. Unnormalized table:
24
Student# Advisor Adv-Room Class1 Class2 Class3
1022 Jones 412 101-07 143-01 159-02
4123 Smith 216 101-07 143-01 179-04
Tables should have only two dimensions. Since one student has several classes, these classes
should be listed in a separate table. Fields Class1, Class2, and Class3 in the above records are
indications of design trouble.
Spreadsheets often use the third dimension, but tables should not. Another way to look at this
problem is with a one-to-many relationship, do not put the one side and the many side in the
same table. Instead, create another table in first normal form by eliminating the repeating
group (Class#), as shown below:
Note the multiple Class# values for each Student# value in the above table. Class# is not
functionally dependent on Student# (primary key), so this relationship is not in second normal
form.
Students:
Registration:
Student# Class#
1022 101-07
1022 143-01
1022 159-02
4123 101-07
4123 143-01
4123 179-04
25
In the last example, Adv-Room (the advisor's office number) is functionally dependent on the
Advisor attribute. The solution is to move that attribute from the Students table to the Faculty
table, as shown below:
Students:
Student# Advisor
1022 Jones
4123 Smith
Faculty:
26
PRACTICAL – 5
5.1 Objective 5.2 Theory and concepts 5.3 Example for practice 5.4 viva Question
SELECT-INTO offers the fastest and simplest way to fetch a single row from a SELECT
statement. The syntax of this statement is
SELECT select_list INTO variable_list FROM remainder_of_query;
EXAMPLE:
Get the last name for a specific employee ID (the primary key in the employees table):
DECLARE
l_last_nameemployees.last_name%TYPE;
BEGIN
SELECT last_name
INTO l_last_name
FROM employees
WHERE employee_id = 138;
DBMS_OUTPUT.put_line (
l_last_name);
END;
Fetch an entire row from the employees table for a specific employee ID:
DECLARE
l_employeeemployees%ROWTYPE;
BEGIN
SELECT *
INTO l_employee
FROM employees
WHERE employee_id = 138;
DBMS_OUTPUT.put_line (
l_employee.last_name);
END;
27
high values specified in the range. With a cursor FOR loop, the body of the loop is executed for each
row returned by the query.
The following block uses a cursor FOR loop to display the last names of all employees in
department 10:
BEGIN
FOR employee_rec IN (
SELECT *
FROM employees
WHERE department_id = 10)
LOOP
DBMS_OUTPUT.put_line (
employee_rec.last_name);
END LOOP;
END;
BEGIN
updateabcd set no=22 where name='ramDA';
if SQL%FOUND then
dbms_output.put_line('success');
else
dbms_output.put_line('failed');
end if;
end;
DECLARE
ROWS_AFFECTED CHAR(4);
BEGIN
updateabcd set no=23 where name='ram';
ROWS_AFFECTED :=TO_CHAR(SQL%ROWCOUNT);
if SQL%ROWCOUNT>0 then
dbms_output.put_line(ROWS_AFFECTED ||'success');
else
dbms_output.put_line('failed');
end if;
end;
28
PRACTICAL – 6
6.1 Objective 6.2 Theory and concepts 6.3 Example for practice 6.4 Viva Question
A procedure is a block that can take parameters (sometimes referred to as arguments) and be invoked.
Procedures promote reusability and maintainability. Once validated, they can be used in number of
applications. If the definition changes, only the procedure are affected, this greatly simplifies
maintenance. Modularized program development:
Group logically related statements within blocks.
Nest sub-blocks inside larger blocks to build powerful programs.
Break down a complex problem into a set of manageable well defined logical modules
and implement the modules with blocks.
Example:
Create [or Replace] PROCEDURE leave_emp
(v_id IN emp.empno%TYPE)
IS
BEGIN
DELETE FROM emp
WHERE empno=v_id;
END leave_emp;
Example:
29
Create [or Replace] PROCEDURE leave_emp
(v_id IN emp.empno%TYPE)
IS
BEGIN
DELETE FROM emp
WHERE empno=v_id;
END leave_emp;
30
IMPLEMENTATION OF FACTORIAL USING FUNCTION
SQL>create function fnfact(n number)
return number is
b number;
begin
b:=1;
for i in 1..n
loop
b:=b*i;
end loop;
return b;
end;
/
SQL>Declare
n number:=&n;
y number;
begin
y:=fnfact(n);
dbms_output.put_line(y);
end;
/
Function created.
Create a procedure which generate all the prime numbers below the given
number and count the no.of prime numbers.
31
if(mod(I,j)=0) then
c:=c+1;
end if;
j:=j+1;
end loop;
if(c=2) then
dbms_output.put_line(i);
tot:=tot+1;
end if;
i:=i+1;
end loop;
end;
/
Sql>procedure created.
declare
t number;
begin
prime_proc(10,t);
dbms_output.put_line(‘the total prime no .are’||t);
end;
OUTPUT
sql>/
2
3
5
7
The total prime no.are 4
32
PRACTICAL – 7
7.1 Objective 7.2 Theory and concepts 7.3 Example for practice7.4 Viva Question
7.2 THEORY AND CONCEPTS: Packages are PL/SQL constructs that enable the grouping of
related PL/SQL objects, such as procedures, variables, cursors, functions, constants, and type
declarations. Informix Dynamic Server does not support the package construct.
A package can have two parts: a specification and a body. The specification defines a list of all
objects that are publicly available to the users of the package. The body defines the code that is used
to implement these objects, such as, the code behind the procedures and functions used within the
package.
The package body is optional. If the package contains only variable, cursor and type definitions then
the package body is not required.
As the package specification is accessible to users of the package, it can be used to define global
variable definitions within PL/SQL.
The Migration Workbench automatically creates packages during the conversion process for the
following reasons:
33
The Utilities package, which is used to emulate built-in Informix Dynamic Server functions,
is not available in Oracle.
A trigger is a named PL/SQL block stored in the Oracle Database and executed automatically when a
triggering event takes place. The event can be any of the following:
A data manipulation language (DML) statement executed against a table e.g., INSERT, UPDATE, or
DELETE. For example, if you define a trigger that fires before an INSERT statement on the
customers table, the trigger will fire once before a new row is inserted into the customers table.
A data definition language (DDL) statement executes e.g., CREATE or ALTER statement. These
triggers are often used for auditing purposes to record changes of the schema.
A system event such as startup or shutdown of the Oracle Database.
A user event such as login or logout.
The act of executing a trigger is also known as firing a trigger. We say that the trigger is fired.
Enforcing complex business rules that cannot be established using integrity constraint such as
UNIQUE, NOT NULL, and CHECK.
Preventing invalid transactions.
Gathering statistical information on table accesses.
Generating value automatically for derived columns.
Auditing sensitive data.
34
Step2: Creating package definition or body
CREATE or replace PACKAGE body emppackage AS
procedure emp_proc2
is
begin
updateemp
setsal=sal+sal*0.10
wherecomm<>sal*0.09;
DBMS_OUTPUT.PUT_LINE ('I am a procedure ');
end emp_proc2;
function fname2(a in number,b in out number)
return number is
begin
b:=a;
return b;
end fname2;
END;
Step3: Calling function / procedure of a package in a program
declare
a number:=10;
b number:=10;
begin
a:=emppackage.fname2(20,b);
dbms_output.put_line(a || b);
emppackage.emp_proc2;
end;
/
Output
2020
I am a procedure
PL/SQL procedure successfully completed.
Example:
Write PL/SQL queries to create Triggers.
SQL>create or replace trigger t11
before update on emp
for each row
begin
if :new.sal<1000
then
dbms_output.put_line('trigger fired');
end if;
end;
Trigger created.
Trigger gets fired when update is performed on EMP table
SQL> update emp
setsal=500
whereempno=69000;
Output
trigger fired
1 row updated.
35
Query: Write a transparent audit system from a table cust_master. The system must keep track of
records that are being deleted or updated.
TABLE:
SQL>select * from cust_mast;
CUST CUST_NAME DOB
-------- ----------------- --------
c1Meenakshi 26-SEP-91
c2Shivani 27-DEC-92
c3Shantanu 30-SEP-72
PL/SQL code block
SQL>set serveroutput on
SQL> create trigger audit_sys before delete or update on cust_mast
for each row
begin
insert into audit_sys values(:old.cust_no,:old.cust_name,:old.dob);
end;
/
Output
Trigger created.
SQL>delete from cust_mast where cust_no=’c3’;
1 row deleted.
SQL>select * from audit_sys;
CUST CUST_NAME DOB
-------- ----------------- --------
c3Shantanu 30-SEP-72
SQL>update cust_mast set dob=’25-nov-1990’ where cust_no=’c2’;
1 row updated.
SQL>select * from audit_sys;
36
PRACTICAL – 8
Payroll Processing refers to the complete set of steps involved in calculating the total remuneration
of each employee. The process typically involves three to four stages and tasks such as defining
salary structures, gathering employee data, components, deductions, allowances, and setting up the
necessary policies with respect to taxes and other adjustments, and then calculating the total salary
after adjusting all the company policies. After the salaries are disbursed, filing, reporting and providing
payslips to employees also comes under the entire payroll processing cycle.
In simplest words, if payroll is the amount paid by the employer to employee, payroll processing is the
whole methodology to accurately calculate the net pay of the employees as per statutory compliances
and company policies.
-- Database
-- Table structure for table loginn
CREATE TABLE loginn (
iddint(10) NOT NULL PRIMARY KEY AUTO_INCREMENT,
e_mailtinytext NOT NULL,
passlongtext NOT NULL
);
-- Dumping data for table loginn
INSERT INTO loginn (idd, e_mail, pass) VALUES
(1, 'dev', 'dev');
-- Table structure for table empp
CREATE TABLE empp (
iddint(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
first_namevarchar(100) NOT NULL,
last_namevarchar(100) NOT NULL,
e_mailvarchar(100) NOT NULL UNIQUE KEY,
pass text NOT NULL,
d_o_b date NOT NULL,
gndrvarchar(10) NOT NULL,
contctvarchar(20) NOT NULL,
nidint(20) NOT NULL,
addrvarchar(100) DEFAULT NULL,
deprtmntvarchar(100) NOT NULL,
degvarchar(100) NOT NULL,
imgg text NOT NULL
);
-- Dumping data for table empp
INSERT INTO empp (idd, first_name, last_name, e_mail, pass, d_o_b, gndr, contct, nid, addr, deprtmnt, deg,
imgg) VALUES
(121, 'Mohit', 'Kumar', '[email protected]', '1234', '1994-04-04', 'Male', '01919', 12221, 'Razarbagh', 'IT', 'Head',
'images/no.jpg'),
(122, 'Mohan', 'Kumar', '[email protected]', '1234', '2018-01-01', 'Male', '0202', 323, 'Ad_______', 'CS', 'CS',
'images/no.jpg'),
(123, 'Ram', 'Singh', '[email protected]', '1234', '1990-02-02', 'Male', '5252', 6222, 'Thames, UK', 'Creative', 'MSc',
'images/sw-google.png'),
37
(124, 'Govind', 'Iyer', '[email protected]', '1234', '1971-12-01', 'Male', '9595', 5929, 'Chemsford, USA',
'Creative', 'MSc', 'images/test.jpg'),
(125, 'Shyam', 'Manja', '[email protected]', '1234', '1971-06-28', 'Male', '8585', 5258, 'LA, USA', 'SpaceTech',
'BSc', 'images/330px-Elon_Musk_Royal_Society.jpg'),
-- Table structure for table emp_leave
CREATE TABLE emp_leave (
iddint(11) DEFAULT NULL,
tokenint(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
start date DEFAULT NULL,
end date DEFAULT NULL,
reason char(100) DEFAULT NULL,
statuss char(50) DEFAULT NULL,
FOREIGN KEY (idd) REFERENCES empp (idd) ON DELETE CASCADE ON UPDATE CASCADE
);
-- Dumping data for table emp_leave
INSERT INTO emp_leave (idd, token, start, end, reason, statuss) VALUES
(101, 301, '2019-04-07', '2019-04-08', 'Sick Leave', 'Approved'),
(102, 302, '2019-04-07', '2019-04-08', 'Urgent Family Cause', 'Approved'),
(103, 303, '2019-04-08', '2019-04-08', 'Concert Tour', 'Approved'),
(105, 304, '2019-04-26', '2019-04-30', 'Launching Tesla Model Y', 'Pending'),
(104, 305, '2019-04-08', '2019-04-09', 'Emergency Leave', 'Pending');
-- Table structure for table projectt
CREATE TABLE projectt (
piddint(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
eiddint(11) DEFAULT NULL,
p_namevarchar(100) DEFAULT NULL,
due_date date DEFAULT NULL,
sub_date date DEFAULT '0000-00-00',
markkint(11) NOT NULL,
statussvarchar(50) DEFAULT NULL,
FOREIGN KEY (eidd) REFERENCES empp (idd) ON DELETE CASCADE ON UPDATE CASCADE
);
-- Dumping data for table projectt
INSERT INTO projectt (pidd, eidd, p_name, due_date, sub_date, markk, statuss) VALUES
(213, 101, 'Database', '2019-04-07', '2019-04-04', 10, 'Submitted'),
(214, 102, 'Test', '2019-04-10', '0000-00-00', 0, 'Due'),
(215, 105, 'Maruti Model Y', '2019-04-19', '2019-04-06', 10, 'Submitted'),
(216, 105, 'Maruti Model X', '2019-04-03', '2019-04-03', 10, 'Submitted'),
(217, 103, 'Statistical', '2019-04-19', '2019-04-04', 6, 'Submitted'),
-- Table structure for table rank
CREATE TABLE rankk (
eiddint(11) NOT NULL PRIMARY KEY,
pointsint(11) DEFAULT 0,
FOREIGN KEY (eidd) REFERENCES empp (idd) ON DELETE CASCADE ON UPDATE CASCADE
);
-- Dumping data for table rank
INSERT INTO rankk (eidd, points) VALUES
(101, 10),(102, 0),(103, 6),(104, 0),(105, 20);
-- Table structure for table salaryy
CREATE TABLE salaryy (
iddint(11) NOT NULL PRIMARY KEY,
baseeint(11) NOT NULL,
bonussint(11) DEFAULT NULL,
totint(11) DEFAULT NULL,
FOREIGN KEY (idd) REFERENCES empp (idd) ON DELETE CASCADE ON UPDATE CASCADE
);
-- Dumping data for table salaryy
INSERT INTO salaryy (idd, basee, bonuss, tot) VALUES
(101, 55000, 10, 60500), (102, 16500, 0, 16500), (103, 65000, 6, 68900), (104, 78000, 0, 78000), (105, 105000,
20, 126000);
38
COMMIT;
Questions:-
Q1. Print list of all the employees.
Ans1. SQL>SELECT * FROM empp;
39
PRACTICAL – 9
A Library Management System is a software built to handle the primary housekeeping functions of a library.
Libraries rely on library management systems to manage asset collections as well as relationships with their
members. Library management systems help libraries keep track of the books and their checkouts, as well as
members’ subscriptions and profiles.
Library management systems also involve maintaining the database for entering new books and recording books
that have been borrowed with their respective due dates.
40
last_name VARCHAR(300),
joined_date DATE,
actv_status_id INT,
CONSTRAINT membr PRIMARY KEY (idd),
CONSTRAINT membr_status FOREIGN KEY (actv_status_id) REFERENCES membr_status(idd)
);
CREATE TABLE resrvtn (
idd INT,
bokk_id INT,
membr_id INT,
resrvtn_date DATE,
resrvtn_status_id INT,
CONSTRAINT resrvtn PRIMARY KEY (idd),
CONSTRAINT res_bokk FOREIGN KEY (bokk_id) REFERENCES bokk(idd),
CONSTRAINT res_membr FOREIGN KEY (membr_id) REFERENCES membr(idd)
);
CREATE TABLE finee_paymtn (
idd INT,
membr_id INT,
paymtn_date DATE,
paymtn_amount INT,
CONSTRAINT finee_paymtn PRIMARY KEY (idd),
CONSTRAINT fineepay_membr FOREIGN KEY (membr_id) REFERENCES membr(idd)
);
CREATE TABLE loann (
idd INT,
bokk_id INT,
membr_id INT,
loann_date DATE,
retrned_date DATE,
CONSTRAINT loann PRIMARY KEY (idd),
CONSTRAINT loann_bokk FOREIGN KEY (bokk_id) REFERENCES bokk(idd),
CONSTRAINT loann_membr FOREIGN KEY (membr_id) REFERENCES membr(idd)
);
CREATE TABLE finee (
idd INT,
bokk_id INT,
loann_id INT,
finee_date DATE,
finee_amount INT,
CONSTRAINT finee PRIMARY KEY (idd),
CONSTRAINT finee_bokk FOREIGN KEY (bokk_id) REFERENCES bokk(idd),
CONSTRAINT finee_loann FOREIGN KEY (loann_id) REFERENCES loann(idd)
);
COMMIT;
Questions:-
Q1. Print all types of books available in Library.
Ans1. SQL>SELECT catgry_name from catgry;
Q2. Print the fullname of all the authors.
Ans2. SQL>SELECT CONCAT(first_name, ' ', last_name) as FullName FROM authr;
41
PRACTICAL – 10
Code:-
-- Database
-- Table structure for table dev
CREATE TABLE dev (
iddint(10) NOT NULL PRIMARY KEY AUTO_INCREMENT,
namevarchar(40) NOT NULL,
e_mailvarchar(40) NOT NULL,
passvarchar(40) NOT NULL
);
-- Dumping data for table dev
INSERT INTO dev (idd, name, e_mail, pass) VALUES
(1, 'Mohan Kumar', '[email protected]', 'kumar'), (2, 'Rohan Singh', '[email protected]', 'kumar');
-- Table structure for table coursee
CREATE TABLE coursee (
coursee_idint(10) NOT NULL PRIMARY KEY AUTO_INCREMENT,
coursee_short_namevarchar(250) NOT NULL,
coursee_full_namevarchar(250) NOT NULL,
coursee_datevarchar(50) NOT NULL
);
INSERT INTO coursee (coursee_id, coursee_short_name, coursee_full_name, coursee_date) VALUES
(44, 'M.C.A', 'MASTER OF COMPUTER APPLICATION', '25-04-2019'), (45, 'M.S.C', 'MASTER OF
SCIENCE', '25-04-2019'), (46, 'B.COM', 'BACHELOR OF COMMERCE', '25-04-2019'), (48, 'M.B.A ',
'MASTER OF BUSINESS ADMINISTRATION', '25-04-2019');
-- Table structure for table folow
CREATE TABLE folow (
iddint(10) NOT NULL PRIMARY KEY AUTO_INCREMENT,
to_user_idint(20) NOT NULL,
from_user_idint(20) NOT NULL
);
-- Dumping data for table folow
INSERT INTO folow (idd, to_user_id, from_user_id) VALUES
(29, 23, 20), (33, 20, 32), (37, 0, 21), (38, 21, 21), (40, 21, 20), (45, 30, 20), (46, 40, 20), (47, 20, 20);
-- Table structure for table folowing
CREATE TABLE folowing (
iddint(10) NOT NULL PRIMARY KEY AUTO_INCREMENT,
from_user_idvarchar(20) NOT NULL,
to_user_idvarchar(20) NOT NULL
);
-- Table structure for table folows
CREATE TABLE folows (
iddint(10) NOT NULL PRIMARY KEY AUTO_INCREMENT,
42
to_user_idint(20) NOT NULL,
from_user_idint(20) NOT NULL
);
-- Table structure for table postss
CREATE TABLE postss (
post_idint(10) NOT NULL PRIMARY KEY AUTO_INCREMENT,
from_user_idvarchar(3) NOT NULL,content longtext NOT NULL,
imagevarchar(255) NOT NULL,
timestamptimestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
);
-- Dumping data for table postss
INSERT INTO postss (post_id, from_user_id, content, image, timestamp) VALUES
(10, '1', 'Priyankachopra', 'priyanka chopra.jpg', '2019-05-08 15:37:52'),
(70, '1', 'This website is developed by Social Codia.', 'socialcodia.png', '2020-04-27 21:15:56'),
(15, '1', 'The results of the best video ever try to get the way this can be its own incomplete website and I will be
its own incomplete website and I will be its own incomplete website and I will be its own incomplete website
and I will be its own incomplete websit', 'Screenshot_2019-05-05-20-08-26-
893_com.mxtech.videoplayer.ad.png', '2019-05-08 17:12:44'),
(17, '8', 'True Love ♥ï¸ ', '918369709214_status_eace0e54cee646309b0da5f908d6731f.jpg', '2019-05-08
19:14:13'),
(21, '8', 'Wow , Looking great Mohan... 😘😘😘', 'IMG_20190513_223507454.jpg', '2019-05-13
22:22:56'),
(22, '8', 'Ramzan Mubarak Mohan... 😘😘😘', 'B612_20190509_075024_942.jpg', '2019-05-13 22:24:01'),
(25, '20', 'Mohan Kumar The Boss', '6.jpg', '2019-05-19 05:55:07'),
(35, '20', 'Your genes decide whether you will own a dog or not, pawsible? Although dogs and other pets are
common household membrs across the globe, little is known how they impact our daily life and health.',
'dogsgenes.jpeg', '2019-05-20 00:28:40'),
(47, '21', 'demo post from student_id = 21', 'mohit.png', '2019-10-10 17:07:40'),
(48, '21', 'stack image', 'stock-vector-editable-square-frame-banner-template-for-social-media-post-red-black-
and-white-geometric-shape-1415216360.jpg', '2019-10-10 17:06:33'),
(59, '21', 'Rohan Singh', 'rohan - Copy.jpg', '2019-10-21 05:19:12');
-- Table structure for table stdnts
CREATE TABLE stdnts (
iddint(10) NOT NULL PRIMARY KEY AUTO_INCREMENT,
rollnovarchar(255) NOT NULL,
standerdvarchar(255) NOT NULL,
user_namevarchar(40) NOT NULL,
namevarchar(255) NOT NULL,
gndrvarchar(255) NOT NULL,
contctvarchar(255) NOT NULL,
e_mailvarchar(255) NOT NULL,
passvarchar(255) NOT NULL,
cityyvarchar(255) NOT NULL,
imagevarchar(255) NOT NULL
);
-- Dumping data for table stdnts
INSERT INTO stdnts (idd, rollno, standerd, user_name, name, gndr, contct, e_mail, pass, cityy, image)
VALUES
(20, '1', 'BCA', 'mohit', 'Mohan Kumar', 'male', '9867503256', '[email protected]', 'kumar', 'Thane',
'mohit.png'), (21, '2', 'Botanology', 'rohan', 'Rohan Singh', 'female', '9867503256', '[email protected]',
'kumar', 'Sipah', 'rohan.jpg'), (22, '6', '3', 'sohan', 'Sohan Kumar', 'male', '82684000646',
'[email protected]', 'kumar', 'Thane', '6.jpg'), (27, '10', '1', 'ibbu', 'Ram Kumar', 'male', '9920322293',
'[email protected]', 'kumar', 'Mumbra, Thane', '');
-- Table structure for table teacher
CREATE TABLE teacher (
iddint(10) NOT NULL PRIMARY KEY AUTO_INCREMENT,
namevarchar(40) NOT NULL,
e_mailvarchar(30) NOT NULL,
contctvarchar(13) NOT NULL,
gndrvarchar(7) NOT NULL,
43
positionvarchar(50) NOT NULL,
passvarchar(20) NOT NULL,
addrvarchar(255) NOT NULL,
imagevarchar(60) NOT NULL
);
-- Dumping data for table teacher
INSERT INTO teacher (idd, name, e_mail, contct, gndr, position, pass, addr, image) VALUES
(1, 'Mohan Kumar', '[email protected]', '9555555256', 'male', 'Manager', 'kumar', 'kausa, mumbra, thane',
'mohan.png'),
(8, 'Rohan Kumar', '[email protected]', '7156478954', 'female', 'Head Teacher', 'kumara', 'Sipah', 'rohan.jpg');
COMMIT;
Questions:-
Q1. Print all the information regarding courses.
Ans1. SQL>SELECT * FROM coursee;
Q2. Print all information of teachers.
Ans2. SQL>SELECT * FROM teacher;
44
PRACTICAL – 11
11.2 THEORY AND CONCEPTS: Data is the heart of the enterprise, it's crucial to protect it and to
protect organization's data, one need to implement a data backup and recovery plan. Backing up file
scan protect against accidental loss of user data, database corruption, hardware failures, and even
natural disasters. It's our job as an administrator to make sure that backups are performed and that
backup tapes are stored in a secure location.
Data backup is an insurance plan. Important files are accidentally deleted all the time. Mission-critical
data can become corrupt. Natural disasters can leave office in ruin. With a solid backup and recovery
plan, one can recover from any of these.
It takes time to create and implement a backup and recovery plan. We'll need to figure out what data
needs to be backed up, how often the data should be backed up, and more. To help we create a plan,
consider the following:
• How important is the data on systems? The importance of data can go a long way in helping to
determine if one need to back it up—as well as when and how it should be backed up. For critical
data, such as a database, one'll want to have redundant backup sets that extend back for several
backup periods. For less important data, such as daily user files, we won't need such an elaborate
backup plan, but 'll need to back up the data regularly and ensure that the data can be recovered
easily.
• What type of information does the data contain? Data that doesn't seem important to we may be
very important to someone else. Thus, the type of information the data contains can help we
determine if we need to back up the data—as well as when and how the data should be backed up.
• How often does the data change? The frequency of change can affect our decision on how often
the data should be backed up. For example, data that changes daily should be backed up daily.
• How quickly do we need to recover the data? Time is an important factor in creating a backup
plan. For critical systems, we may need to get back online swiftly. To do this, we may need to
alter our backup plan.
• Do we have the equipment to perform backups? We must have backup hardware to perform
backups. To perform timely backups, we may need several backup devices and several sets of
backup media. Backup hardware includes tape drives, optical drives, and removable disk drives.
Generally, tape drives are less expensive but slower than other types of drives.
• Who will be responsible for the backup and recovery plan? Ideally, someone should be a
primary contact for the organization's backup and recovery plan. This person may also be
responsible for performing the actual backup and recovery of data.
45
• What is the best time to schedule backups? Scheduling backups when system use is a slow as
possible will speed the backup process. However, we can't always schedule backups for off-peak
hours. So we'll need to carefully plan when key system data is backed up.
• Do we need to store backups off-site? Storing copies of backup tapes off-site is essential
to recovering our systems in the case of a natural disaster. In our off-site storage location, we
should also include copies of the software we may need to install tore-establish operational
systems.
If we view the properties of a file or directory in Windows Explorer, we'll note an attribute called
Archive. This attribute often is used to determine whether a file or directory should be backed up. If
the attribute is on, the file or directory may need to be backed up. The basic types of backups we can
perform include
• Normal/full backups All files that have been selected are backed up, regardless of the setting of
the archive attribute. When a file is backed up, the archive attribute is cleared. If the file is later
modified, this attribute is set, which indicates that the file needs to be backed up.
• Copy backups All files that have been selected are backed up, regardless of the setting of the
archive attribute. Unlike a normal backup, the archive attribute on files isn't modified. This allows
us to perform other types of backups on the files at a later date.
• Differential backups Designed to create backup copies of files that have changed since the last
normal backup. The presence of the archive attribute indicates that the file has been modified and
only files with this attribute are backed up. However, the archive attribute on files isn't modified.
This allows to perform other types of backups on the files at a later date.
• Incremental backups Designed to create backups of files that have changed since the most recent
normal or incremental backup. The presence of the archive attribute indicates that the file has
been modified and only files with this attribute are backed up. When a file is backed up, the
archive attribute is cleared. If the file is later modified, this attribute is set, which indicates that the
file needs to be backed up.
• Daily backups Designed to back up files using the modification date on the file itself. If a file
has been modified on the same day as the backup, the file will be backed up. This technique
doesn't change the archive attributes of files. In we backup plan we'll probably want to perform
full backups on a weekly basis and supplement this with daily, differential, or incremental
backups. We may also want to create an extended backup set for monthly and quarterly backups
that includes additional files that aren't being backed up regularly.
Tip We'll often find that weeks or months can go by before anyone notices that a file or data source is
missing. This doesn't mean the file isn't important. Although some types of data aren't used often,
they're still needed. So don't forget that we may also want to create extra sets of backups for monthly
or quarterly periods, or both, to ensure that we can recover historical data over time.
The difference between differential and incremental backups is extremely important. To understand
the distinction between them. As it shows, with differential backups we back up all the files that have
changed since the last full backup (which means that the size of the differential backup grows over
time). With incremental backups, we only back up files that have changed since the most recent full or
46
incremental backup (which means the size of the incremental backup is usually much smaller than a
full backup).
Once we determine what data we're going to back up and how often, we can select backup devices
and media that support these choices.
• Capacity: The amount of data that we need to back up on a routine basis. Can the backup
hardware support the required load given our time and resource constraints?
• Reliability: The reliability of the backup hardware and media. Can we afford to sacrifice
reliability to meet budget or time needs?
• Extensibility: The extensibility of the backup solution. Will this solution meet our needs as the
organization grows?
• Speed: The speed with which data can be backed up and recovered. Can we afford to sacrifice
speed to reduce costs?
• Cost: The cost of the backup solution. Does it fit into our budget?
Capacity, reliability, extensibility, speed, and cost are the issues driving our backup plan. If we
understand how these issues affect our organization, we'll be on track to select an appropriate backup
solution. Some of the most commonly used backup solutions include
• Tape drives Tape drives are the most common backup devices. Tape drives use magnetic tape
cartridges to store data. Magnetic tapes are relatively inexpensive but aren't highly reliable. Tapes
can break or stretch. They can also lose information overtime. The average capacity of tape
cartridges ranges from 100 MB to 2 GB. Compared with other backup solutions, tape drives are
fairly slow. Still, the selling point is the low cost.
• Digital audio tape (DAT) drives DAT drives are quickly replacing standard tape drives as the
preferred backup devices. DAT drives use 4 mm and 8 mm tapes to store data.DAT drives and
tapes are more expensive than standard tape drives and tapes, but they offer more speed and
capacity. DAT drives that use 4 mm tapes can typically record over 30 MB per minute and have
capacities of up to 16 GB. DAT drives that use 8 mm tapes can typically record more than 10 MB
per minute and have capacities of up to 36GB (with compression).
• Auto-loader tape systems Auto-loader tape systems use a magazine of tapes to create extended
backup volumes capable of meeting the high-capacity needs of the enterprise. With an auto-loader
system, tapes within the magazine are automatically changed as needed during the backup or
recovery process. Most auto-loader tape systems use DAT tapes. The typical system uses
magazines with between 4 and 12 tapes. The main drawback to these systems is the high cost.
• Magnetic optical drives Magnetic optical drives combine magnetic tape technology with optical
lasers to create a more reliable backup solution than DAT. Magnetic optical drives use 3.5-inch
and 5.25-inch disks that look similar to floppies but are much thicker. Typically, magnetic optical
disks have capacities of between 1 GB and 4 GB.
• Tape jukeboxes Tape jukeboxes are similar to auto-loader tape systems. Jukeboxes use magnetic
optical disks rather than DAT tapes to offer high-capacity solutions. These systems load and
47
unload disks stored internally for backup and recovery operations.Their key drawback is the high
cost.
• Removable disks Removable disks, such as Iomega Jaz, are increasingly being used as backup
devices. Removable disks offer good speed and ease of use for a single drive or single system
backup. However, the disk drives and the removable disks tend to be more expensive than
standard tape or DAT drive solutions.
• Disk drives Disk drives provide the fastest way to back up and restore files. With disk drives,
you can often accomplish in minutes what takes a tape drive hours. So when business needs
mandate a speedy recovery, nothing beats a disk drive. The drawbacks to disk drives, however,
are relatively high costs and less extensibility.
Before we can use a backup device, we must install it. When we install backup devices other than
standard tape and DAT drives, we need to tell the operating system about the controller card and
drivers that the backup device uses. For detailed information on installing devices and drivers, see the
section of Chapter 2 entitled "Managing Hardware Devices and Drivers."
Selecting a backup device is an important step toward implementing a backup and recovery plan. But
we also need to purchase the tapes or disks, or both, that will allow we to implement our plan. The
number of tapes we need depends on how much data we'll be backing up, how often we'll be backing
up the data, and how long we'll need to keep additional data sets.
The typical way to use backup tapes is to set up a rotation schedule whereby we rotate through two or
more sets of tapes. The idea is that we can increase tape longevity by reducing tape usage and at the
same time reduce the number of tapes we need to ensure that we have historic data on hand when
necessary.
One of the most common tape rotation schedules is the 10-tape rotation. With this rotation schedule,
we use 10 tapes divided into two sets of 5 (one for each weekday). The first set of tapes is used one
week and the second set of tapes is used the next week. On Fridays, full backups are scheduled. On
Mondays through Thursdays, incremental backups are scheduled. If we add a third set of tapes, we
can rotate one of the tape sets to an off-site storage location on a weekly basis.
Tip: The 10-tape rotation schedule is designed for the 9 to 5 workers of the world. If we're in a24 x 7
environment, we'll definitely want extra tapes for Saturday and Sunday. In this case, use a 14-tape
rotation with two sets of 7 tapes. On Sundays, schedule full backups. On Mondays through Saturdays,
schedule incremental backups.
48
PRACTICAL – 12
12.1 OBJECTIVE: Objective of inventory control system project is to design a database to record
proper variety of required items in inventory, maintain optimized inventory, safety stock levels and
obtain low raw material prices, storage cost, insurance cost, taxes
o Develop ER Diagrams
View details of inventory items and all associated costs to aid in decision
making on placing orders with suppliers
49
Technology to be used – MySql
Timeline of Mini Project (in terms of no. of lab classes required for project completion)– 6 hrs
Project deliverables
ER Diagrams,
50
12.1 Objective 12.2 Theory and concepts
Scope of Mini Project (project description listing out functionalities / features to be developed)
o Develop ER Diagrams
o Using the bill of materials required for production, MRP then disassembles demand
into the individual components and raw materials needed to complete the build while
accounting for any required sub-assemblies.
o Scheduling production
Using the master production schedule, the system determines how much time and
labor are required to complete each step of each build and when they need to happen
so that the production can occur without delay.
o The production schedule also identifies what machinery and workstations are needed
for each step and generates the appropriate work orders, purchase orders and transfer
orders. If the build requires subassemblies, the system takes into account how much
time each subassembly takes and schedules them accordingly.
51
o Identifying issues and making recommendations
Finally, because the MRP links raw materials to work orders and customer orders, it
can automatically alert your team when items are delayed and make
recommendations for existing orders: automatica
automatically
lly moving production in or out,
performing what-ifif analyses, and generating exception plans to complete the required
builds.
Timeline of Mini Project (in terms of no. of lab classes required for project completion)
completion)– 6 hrs
Project deliverables
ER Diagrams,
52
12.1 Objective 12.2 Theory and concepts
12.1 OBJECTIVE: Objective of Hospital management system project is to design database for recording
and managing hospital information to reduce the burden of handling manually the activities of all
sections of hospital like reception, lab, inpatient/outpatient management and patient billing etc., which
improve the processing efficiency.
Scope of Mini Project - Project description listing out functionalities / features to be developed–
o Develop ER Diagrams
53
Technology to be used – MySql
Timeline of Mini Project (in terms of no. of lab classes required for project completion) – 6 hrs
Project deliverables
ER Diagrams,
Converting ER Diagrams into Tables
Making SQL Queries
54
12.1 Objective 12.2 Theory and concepts
12.1 OBJECTIVE: Objective of Railway reservation system project is to design a database to efficiently
manage Railway Reservation SYSTEM for a city tour.
Scope of Mini Project (project description listing out functionalities / features to be developed)
o Develop ER Diagrams
Enter, modify and delete Train details (Train No, Category, Vendor etc.)
55
Technology to be used – MySql
Timeline of Mini Project (in terms of no. of lab classes required for project completion)– 6 hrs
Project deliverables
ER Diagrams,
Converting ER Diagrams into Tables
Making SQL Queries
56
12.1 Objective 12.2 Theory and concepts
o Develop ER Diagrams
o Database: PIS core offering consists of a database for storing employee information.
HR professionals can store all personnel data into the system that can be accessed
from any time, from anywhere.
o Time and Labor Management: Functions like time and labor management requires a
lot of time. PIS packages allow employees to input their hours worked and help
managers to instantly verify vacation requests, and the information is fed to the
payroll directly.
o Benefits: Some PIS packages allow employers to develop and maintain medical,
retirement, and other benefits through their software.
o Employee Interface: Most PIS packages allow limited user access for an employee.
o Hiring and Retention: Hiring and retention are the most crucial components of PIS.
57
Technology to be used – MySql
Timeline of Mini Project (in terms of no. of lab classes required for project completion)– 6 hrs
Project deliverables
58
12.1 Objective 12.2 Theory and concepts
12.1OBJECTIVE: The process of identifying users depends on the type of device they are using (e.g.
a smart phone or laptop) and whether they are using a web browser or mobile app. For example, a
user visiting web pages in a web browser, either on a mobile device or computer, would be identified
by browser-based identification methods. A user playing a mobile-app game on a smart phone or
tablet would be identified by a mobile identifier.
Scope of Mini Project (project description listing out functionalities / features to be developed)
o Develop ER Diagrams
o Regardless of the type of user and their rights, each user has a unique identification
that distinguishes it from other users. System administrators use these IDs to assign
privileges, track user activity and manage overall operations on a particular system,
network or application.
o Many analytics technologies can’t identify unique users if they use multiple devices
across multiple sessions, as each time a user does this, a new user is counted. By
having a unique user ID, this eliminates this issue, allowing for all activity being
attributed to one user in an analytics report
59
Technology to be used – MySql
Timeline of Mini Project (in terms of no. of lab classes required for project completion)– 6 hrs
Project deliverables
ER Diagrams,
60
12.1 Objective 12.2 Theory and concepts
12.1OBJECTIVE:Timetable management software helps design timetables and mark attendance for
teachers and students.It helps to regulate proper schedules and allocate faculty according to their
availability by outlining the classes, sections, and other details fed into the system.Adopting a digital
system for timetable management enhances the authenticity of data as it would be sensitive towards
manipulations and boosts efficiency due to workflow automation
Scope of Mini Project (project description listing out functionalities / features to be developed)
o Develop ER Diagrams
o unplanned systems can be taxing: A well-timed routine can help by keeping students
and teachers involved and disciplined. It will also save time by lowering the amount
of time spent in chaos and confusion.
o Event and holiday calendar planner: Holidays and events could be added in the
backend which can further be viewed by the user in the form of a fully furnished
yearly calendar.
61
Technology to be used – MySql
Timeline of Mini Project (in terms of no. of lab classes required for project completion)– 6 hrs
Project deliverables
ER Diagrams,
62
12.1 Objective 12.2 Theory and concepts
12.1OBJECTIVE:Objective of this project is to design database for recording and managing day to
day activity of a hotel to reduce the burden of handling manually the activities of all sections of hotel
like reception, employee, booking status, Visitors check in, check out status, and billing etc., which
improve the processing efficiency.
Scope of Mini Project (project description listing out functionalities / features to be developed)
o Develop ER Diagrams
Enter, modify, and delete Room details (Room No, Category etc.)
63
Technology to be used – MySql
Timeline of Mini Project (in terms of no. of lab classes required for project completion)– 6 hrs
Project deliverables
ER Diagrams,
Converting ER Diagrams into Tables
Making SQL Queries
64
Filename: DBMS LAB FILE
Directory: C:\Users\ASUS\OneDrive\Documents
Template: C:\Users\ASUS\AppData\Roaming\Microsoft\Templates\Normal.dotm
Title:
Subject:
Author: Windows User
Keywords:
Comments:
Creation Date: 8/10/2023 11:52:00 AM
Change Number: 39
Last Saved On: 12/9/2024 1:11:00 PM
Last Saved By: ASUS
Total Editing Time: 914 Minutes
Last Printed On: 12/9/2024 1:12:00 PM
As of Last Complete Printing
Number of Pages: 77
Number of Words: 14,308 (approx.)
Number of Characters: 81,561 (approx.)