Professional Documents
Culture Documents
DATABASE:
A database is a logically coherent collection of data with some inherent meaning,
representing some aspect of real world and which is designed, built and populated
with data for a specific purpose.
DBMS:
It is a collection of programs that enables user to create and maintain a database.
In other words it is general-purpose software that provides the users with the
processes of defining, constructing and manipulating the database for various
applications.
DATABASE SYSTEM:
The database and DBMS software together is called as Database system.
1
09MBA083
2
09MBA083
COMPONENTS OF DBMS
DBMS Engine accepts logical request from the various other DBMS
subsystems, converts them into physical equivalent, and actually
accesses the database and data dictionary as they exist on a storage
device.
Data Definition Subsystem helps user to create and maintain the data
dictionary and define the structure of the files in a database.
Warehouse of Information
The database management systems are warehouses of information, where
large amount of data can be stored. The common examples in commercial
applications are inventory data, personnel data, etc.
Systematic Storage
The data is stored in the form of tables. The tables consists of rows and
3
09MBA083
No Language Dependence
The database management systems are not language dependent. Therefore,
they can be used with various languages and on various platforms.
Data Security
Data is the most important asset. Therefore, there is a need for data
security. Database management systems help to keep the data secured.
Data Consistency
Data consistency ensures a consistent view of data to every user. It includes
the accuracy, validity and integrity of related data. The data in the database
must satisfy certain consistency constraints, for example, the age of a
candidate appearing for an exam should be of number datatype and in the
range of 20-25. When the database is updated, these constraints are
checked by the database systems.
DISADVANTAGES:
Power dependency.
security issues
4
09MBA083
ORACLE
5
09MBA083
The client-server model has become one of the central ideas of network
computing. Many business applications being written today use the
client-server model. So do the Internet's main application protocols,
such as HTTP, SMTP, Telnet, and DNS. In marketing, the term has
been used to distinguish distributed computing by smaller dispersed
computers from the "monolithic" centralized computing of mainframe
computers. But this distinction has largely disappeared as
mainframes and their applications have also turned to the client-
server model and become part of network computing.
6
09MBA083
7
09MBA083
1. A client, i.e. the computer, which requests the resources, equipped with a user
interface (usually a web browser) for presentation purposes
2. The application server (also called middleware), whose task it is to provide the
requested resources, but by calling on another server
3. The data server, which provides the application server with the data it requires.
8
09MBA083
ADVANTAGES:
All data is stored on the servers, which generally have far greater security
controls than most clients.
Since data storage is centralized, updates to that data are far easier to
administer.
9
09MBA083
DISADVANTAGES:
10
09MBA083
SQL commands can be combined with database commands to define and access
data from a database.
(b) Embedded SQL: This consists of SQL commands put inside of programs
that are written in other language such as FORTRAN, Pascal, COBOL, C
which can make the programs more powerful and efficient.
ADVANTAGES OF SQL:
1. The language while being simple and easy to learn can cope with
complex situations.
2. SQL enables end users and system personnel to deal with a number of
database management systems where it is available.
11
09MBA083
COMPONENTS OF SQL
The Data Definition Language (DDL) is used to create and destroy databases and
database objects. These commands will primarily be used by database
administrators during the setup and removal phases of a database project. DDL
commands are:
CREATE TABLE
CREATE VIEW
ALTER TABLE
DROP TABLE
DML is used to manipulate data such as to insert, modify, delete or query the data
in the database.DML commands are:
INSERT
DELETE
UPDATE
SELECT
DCL is used to grant and revoke authorization for database access, auditing the
database use and dealing with transactions. There are many ways that a database
can become corrupted. DCL commands are:
COMMIT
12
09MBA083
ROLLBACK
GRANT
REVOKE
CHARACTER (n)
Or CHAR (n)
Where n is the number of characters.
13
09MBA083
14
09MBA083
SQL COMMANDS
DDL COMMANDS:
EXAMPLE:
Table created.
This will create the “record” table with five columns, namely, ROLL NO.,
15
09MBA083
Or
Tables may be destroyed with the SQL command DROP TABLE, WHICH IS OF
THE FORM:
EXAMPLE:
DROP TABLE RECORDS
16
09MBA083
DML COMMANDS:
For inserting data into the tables, SQL has the INSERT command which is of
the form
EXAMPLE:
This command will insert the values into the specified columns only.
1 row created.
17
09MBA083
values(2,'atul','delhi','14-october-1990','m');
1 row created.
1 row created.
1 row created.
1 row created
To modify data values within values within one or more columns for one or
more rows of a table.
SQL has a command called update. It is of the form
UPDATE<table name>
SET <column name> = <value expression>
[, <column name> = <value expression>
18
09MBA083
………
]
[WHERE <condition>]
The columns whose value have to be updated and the expressions to derive
these values are included in the SET clause. The rows to be updated are those
that meet the condition (s) in the WHERE clause.
EXAMPLE:
This command will change the address of the student whose roll no. is 01.
This command deletes rows from the table specified. If the WHERE clause is given;
only rows meeting the condition (s) are deleted. Otherwise, all rows are deleted.
EXAMPLE:
This command will delete the student row whose roll no. is 02.
Querying on the database is done using the SQL command SELECT. The
SELECT command has with it several clauses that may be used.
It can be in the form:
19
09MBA083
EXAMPLE:
SELECT ROLL NO., NAME, ADDRESS
FROM RECORDS;
In this example SELECT command will display all the rows from the
RECORDS table.
The selection could be made for specific rows which meet some condition,
having a SELECT of the form
For example:
ADDRESS
------------------------------
Delhi
Delhi
Mumbai
Mumbai
Joshi road
20
09MBA083
OPERATORS IN SQL
ARITHMETIC OPERATORS
+ , -, *, /
RELATIONAL OPERATORS
=, <>, <, <=, >, >=
CONJUNCTION OPERATORS
These are used to combine the conditions.
AND, OR
LOGICAL OPERATORS
OPERATORS MEANING
IS NULL compare a value with a null value
21
09MBA083
FUNCTION MEANING
COUNT ( ) Count rows or values of a column that do
not contain a null value.
COUNT (*) Count all the rows of a table including
duplicates.
SUM ( ) Return a total or sum on the values of a
numeric column for a group of rows.
AVG ( ) Find average for a group of rows.
22
09MBA083
SQL QUERIES
23
09MBA083
20
7839 King President 17-NOV-81 5000
10
7844 Turner Salesman 7698 08-SEP-81 1500
30
7876 Adams Clerk 7788 23-MAY-87 1100
20
7900 James Clerk 7698 03-DEC-81 950
30
7902 Ford Analyst 7566 03-DEC-81 3000
20
7034 Miller Clerk 7782 23-jan-82 1300
10
NAME
--------------------
24
09MBA083
kanika
atul
naina
hiten
sahil
----------
TURNER
ALLEN
25
09MBA083
FORD 10 03-DEC-81
SMITH 20 17-DEC-80
BLAKE 30 01-MAY-81
WARD 30 22-FEB-81
ALLEN 30 20-FEB-81
Table altered.
OUTPUT:
OUTPUT:
SUM (SAL)
---------
29025
26
09MBA083
OUTPUT:
OUTPUT:
ENAME
----------
Jones
Blake
Clark
Turner
10. GET THE JOB & SALARY OF EMPLOYEES ,NAMES BEGIN WITH A
OUTPUT:
27
09MBA083
Job Salary
---------- ----------
Salesman 1600
Clerk 1100
11. GET THE EMPLOYEES WHOSE SALARY GREATER THAN 2500 AND
DEPTT NO. LESS THAN 30
SQL>Select * from EMPLOYEE
Where salary >2500 AND Deptt no. < 30;
OUTPUT:
20
20
10
20
28
09MBA083
OUTPUT:
DEPTNO
---------
20
30
SQL JOIN
SUPPLIERS
SUPP_ID SUPP_NAME
------------- --------------
100 AMIT
101 RAVI
102 JOHN
103 PARK
104 SMITH
ORDERS
29
09MBA083
3WHERE SUPPLIER.SUPP_ID=ORDERS.SUPP_ID;
OUTPUT:
30