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

SUSCET/ 5th

RDBMS FILE

INTRODUCTION TO DBMS
Data is one of the most important assets of a company. It is very important to make sure data is stored and maintained accurately and quickly. DBMS (Database Management System) is a system that is used to store and manage data. A DBMS is a set of programs that is used to store and manipulation data. Manipulation of data include the following: Adding new data, for example adding details of new student. Deleting unwanted data, for example deleting the details of students who have completed course. Changing existing data, for example modifying the fee paid by the student.

A DBMS provides various functions like data security, data integrity, data sharing, data concurrence, data independence, data recovery etc. However, all database management systems that are now available in the market like Sybase, Oracle, and MS-Access do not provide the same set of functions, though all are meant for data management. Database managements systems like Oracle, DB2 are more powerful and meant for bigger companies. Whereas, database management systems like MS-Access are meant for small companies. So one has to choose the DBMS depending upon the requirement.

DBMS:
A general purpose software system enabling:1) Creation of large disk-resident databases. 2)Posing of data retrieval queries in a standard manner. 3)Retrieval of query results efficiently. 4)Concurrent use of the system by a large number of users in a consistent manner. 5)Guaranteed availability of data irrespective of system failures. DBMS stands for "Database Management System." In short, a DBMS is a database program. The DBMS manages incoming data, organizes it, and provides ways for the data to be modified or extracted by users or other programs. Some DBMS examples include MySQL, PostgreSQL, Microsoft Access, SQL Server, FileMaker, Oracle, RDBMS, dBASE, Clipper, and FoxPro. Since there are so many database management systems available, it is important for there to be a way for them to communicate with each other. For this reason, most database software comes with an Open Database Connectivity (ODBC) driver that allows the database to integrate with other databases. For example, common SQL statements such as SELECT and INSERT are translated from a program's proprietary syntax into a syntax other databases can understand.

Divya Bajaj

1154440

SUSCET/ 5th

RDBMS FILE

DIFFERENCE BETWEEN DBMS AND RDBMS :


DBMS RDBMS

In DBMS relation between two tables or files area maintained programmatically DBMS does not support client/server Architecture DBMS does not support Distributed databases In DBMS there is no security of data

In RDBMS relationship between two table or files can be specified at the time of table creation Most of the RDBMS supports client/server Architecture Most of the RDBMS supports Distributed databases In RDBMS there are multiple level of security 1. Logging in at O/S level 2. Command level(i.e. at RDBMS level) 3. Object level Each table is given an extension in Many tables are grouped in one database DBMS in RDBMS DBMS may satisfy less than 7 to 8 rules RDBMS usually satisfy more than 7 to 8 of Dr. E. F. Codd rules of Dr. E.F. Codd Naming Convention Field Column, Attributes Record Row, Tuple, Entity File Table, Relation, Entity class INTRODUCTION TO ORACLE
An Oracle database is a collection of data treated as a unit. The purpose of a database is to store and retrieve related information. A database server is the key to solving the problems of information management. In general, a server reliably manages a large amount of data in a multiuser environment so that many users can concurrently access the same data. All this is accomplished while delivering high performance. A database server also prevents unauthorized access and provides efficient solutions for failure recovery. Oracle Database is the first database designed for enterprise grid computing, the most flexible and cost effective way to manage information and applications. Enterprise grid computing creates large pools of industry-standard, modular storage and servers. With this architecture, each new system can be rapidly provisioned from the pool of components. There is no need for peak workloads, because capacity can be easily added or reallocated from the resource pools as needed. The database has logical structures and physical structures. Because the physical and logical structures are separate, the physical storage of data can be managed without affecting the access to logical storage structures.
Divya Bajaj 2 1154440

SUSCET/ 5th

RDBMS FILE

VERSIONS OF ORACLE :
Oracle Database 11g: Overcome the problems associated with using bind variables against indexed columns containing skewed data. Reduce the impact of automated maintenance tasks on your system by controlling how and when they run. Oracle 11g takes the next step down the road to making manual memory management a thing of the past. Take advantage of the Automatic SQL Tuning features of Oracle 11g Release 1. Oracle Database 10g Express Edition: Oracle Database 10g Express Edition (Oracle Database XE) is an entry-level, small-footprint database based on the Oracle Database 10g Release 2 code base that's free to develop, deploy, and distribute; fast to download; and simple to administer. Oracle Database XE is a great starter database. Oracle Database 9i: Reduce segment header contention and wasted space within blocks by switching from using Free Lists to Automatic Segment Free Space Management. Replace you existing rollback segments with self-tuning undo segments. Increase the performance and reduce the size of your data warehouse. Oracle Database 8i: Lists the available mechanisms for gathering database statistics that are used by the cost based optimizer. Hide unused columns or completely remove them. Query external data as if it were a relational table. Allow queries to use indexes even when you are performing a function on the indexed column.

DIFFERENCES BETWEEN ORACLE SERVER 9i AND ORACLE SERVER 10g :


10 G supports grid computing, ASM (Automatic storage management) and Memory management. Oracle 10g is higher version of 9i , Oracle 10g has added a following features :

Major changes to SQL optimizer internals Oracle Grid computing AWR and ASH tables incorporated into Oracle Performance Pack and Diagnostic Pack options Automated Session History (ASH) materializes the Oracle Wait Interface over time Data Pump replaces imp utility with impdp Automatic Database Diagnostic Monitor (ADDM) SQLTuning Advisor SQLAccess Advisor Rolling database upgrades (using Oracle10g RAC) dbms_scheduler package replaces dbms_job for scheduling

INTRODUCTION TO STRUCURE QUERY LANGUAGE

Divya Bajaj

1154440

SUSCET/ 5th

RDBMS FILE

Structured Query Language is a database computer language designed for managing data in
relational database management systems (RDBMS), and originally based upon relational algebra. Its scope includes data insert, query, update and delete, schema creation and modification, and data access control. SQL was one of the first languages for Edgar F. Codds relational model in his influential 1970 paper, "A Relational Model of Data for Large Shared Data Banks"] and became the most widely used language for relational databases. The SQL language is sub-divided into several language elements, including:

Clauses, which are in some cases optional, constituent components of statements and queries Expressions,which can produce either scalar values or tables consisting of columns and rows of data.

Various type of SQL Languages :


Data-Definition Language: A database schema is specified by a set of definitions expressed by a special language called a data-definition language (DDL). The result of compilation of DDL statements is a set of tables that is stored in a special file called data dictionary or data directory. A data dictionary is a file that contains metadata-that is, data about data. This file is consulted before actual data read or modified in the database system. The storage structure and access methods used by the database system are specified by a set of definitions in a special type of DDL called a data storage and definition language. The SQL DDL statements are CREATE, ALTER, DROP, RENAME. Data-Manipulation Language: Data manipulation means: The retrieval of information stored in the database The insertion of new information into the database The deletion of information from the database The modification of information of database A data-manipulation languages (DML) is a language that enables users to access or manipulate data as organized by the appropriate data model. There are basically two types: Procedural DMLs are requiring a user to specify what data are needed and how to get those data. Non-procedural DMLs require a user to specify what data are needed without specifying how to get those data.

Data Control Language(DCL):


Divya Bajaj 4 1154440

SUSCET/ 5th

RDBMS FILE

DCL statements control access to data and the database using statements such as GRANT and REVOKE. A privilege can either be granted to a user with the help of GRANT statement. The privilege assigned can be SELECT,ALTER ,DELETE ,EXECUTE ,INSERT, INDEX etc. in addition to granting of privileges, you can also revoke it by using REVOKE command. The SQL DCL statements are GRANT, REVOKE, COMMENT. Data Query Language(DQL): A query is a statement requesting the retrieval of information. The portion of a DML that involves information retrieval is called query language.The SQL DQL statement is SELECT command that is only to retrieve data from database. Transaction Control Language(TCL): Transaction stands for program in execution. A transaction is a collection of operation that performs a single logical function in a database application.The SQL TCL statements are SET TRANSACTION, COMMIT, ROLL BACK, SAVE POINT, END TRANSACTION. Data administrative statement(DAS): DAS statements allow the user to perform audits and analysis of solutions within the database. These statements are used to analyse the performance of database. The SQL DAS statements are START AUDIT, STOP AUDIT.

Various Data Types of SQL :


Code 1 Datatype VARCHAR2(size [BYTE | CHAR]) Description Variable-length character string having maximum length size bytes or characters. Maximum size is 4000 bytes or characters, and minimum is 1 byte or 1 character. You must specify size for VARCHAR2.
BYTE

indicates that the column will have byte length semantics; CHAR indicates that the column will have character semantics. 2 NUMBER[(precision Number having precision p and scale s. The precision p [, scale]]) can range from 1 to 38. The scale s can range from -84 to 127. LONG RAW(size) Character data of variable length up to 2 gigabytes, or 231 1 bytes. Provided for backward compatibility. Raw binary data of length size bytes. Maximum size is 2000 bytes. You must specify size for a RAW value.

8 23 96

CHAR [(size [BYTE Fixed-length character data of length size bytes. Maximum | CHAR])] size is 2000 bytes or characters. Default and minimum size is 1 1

Divya Bajaj

1154440

SUSCET/ 5th

RDBMS FILE

ADVANTAGES OF DBMS :
The DBMS has a number of advantages as compared to traditional computer file processing approach. The DBA must keep in mind these benefits or capabilities during designing databases, coordinating and monitoring the DBMS. The major advantages of DBMS are described below.

1. Controlling Data Redundancy: In non-database systems (traditional computer file


processing), each application program has its own files. In this case, the duplicated copies of the same data are created at many places. In DBMS, all the data of an organization is integrated into a single database. The data is recorded at only one place in the database and it is not duplicated. For example, the dean's faculty file and the faculty payroll file contain several items that are identical. When they are converted into database, the data is integrated into a single database so that multiple copies of the same data are reduced to-single copy. In DBMS, the data redundancy can be controlled or reduced but is not removed completely. Sometimes, it is necessary to create duplicate copies of the same data items in order to relate tables with each other. By controlling the data redundancy, you can save storage space. Similarly, it is useful for retrieving data from database using queries.

2. Data Consistency:By controlling the data redundancy, the data consistency is


obtained. If a data item appears only once, any update to its value has to be performed only once and the updated value (new value of item) is immediately available to all users. If the DBMS has reduced redundancy to a minimum level, the database system enforces consistency. It means that when a data item appears more than once in the database and is updated, the DBMS automatically updates each occurrence of a data item in the database.

3. Data Sharing:In DBMS, data can be shared by authorized users of the organization.
The DBA manages the data and gives rights to users to access the data. Many users can be authorized to access the same set of information simultaneously. The remote users can also share same data. Similarly, the data of same database can be shared between different application programs.

4. Data Integration:In DBMS, data in database is stored in tables. A single database


contains multiple tables and relationships can be created between tables (or associated data entities). This makes easy to retrieve and update data.

5.User-friendly: Data is easier to access and manipulate with a DBMS than without it. In
most cases, DBMSs also reduce the reliance of individual users on computer specialists to meet their data needs.

6.Improved security:As stated earlier, DBMSs allow multiple users to access the same
data resources. This capability is generally viewed as a benefit, but there are potential risks for the organization. Some sources of information should be protected or secured and only viewed by select individuals. Through the use of passwords, database management systems can be used to restrict data access to only those who should see it.
Divya Bajaj 6 1154440

SUSCET/ 5th

RDBMS FILE

DISADVANTAGES OF DBMS :
Although there are many advantages but the DBMS may also have some minor disadvantages. These are:

1. Cost of Hardware & Software:


A processor with high speed of data processing and memory of large size is required to run the DBMS software. It means that you have to upgrade the hardware used for file-based system. Similarly, DBMS software is also Very costly.

2. Cost of Data Conversion:


When a computer file-based system is replaced with a database system, the data stored into data file must be converted to database files. It is difficult and time consuming method to convert data of data files into database. You have to hire DBA (or database designer) and system designer along with application programmers; Alternatively, you have to take the services of some software houses. So a lot of money has to be paid for developing database and related software.

3. Cost of Staff Training:


Most DBMSs are often complex systems so the training for users to use the DBMS is required. Training is required at all levels, including programming, application development, and database administration. The organization has to pay a lot of amount on the training of staff to run the DBMS.

4. Appointing Technical Staff:


The trained technical persons such as database administrator and application programmers etc are required to handle the DBMS. You have to pay handsome salaries to these persons. Therefore, the system cost increases.

5. Database Failures:
In most of the organizations, all data is integrated into a single database. If database is corrupted due to power failure or it is corrupted on the storage media, then our valuable data may be lost or whole system stops.

Divya Bajaj

1154440

SUSCET/ 5th

RDBMS FILE

Experiment No. 1
AIM : Learning basic SQL commands . HARDWARE REQUIRED:1) Physical memory (RAM) :- Min 512 MB recommended 2) Disk space :-Min 2.04 GB 3)Processor:-Min 800 MHz

SOFTWARE REQUIRED:1) Operating System :- Windows XP Professional 2)SQL:-10.2.0

Commands :1.CREATE Table :It is used to create table .

Syntax :create table tablename(column1 datatype(size1),column2 datatype(size2),column3 datatype(size3),..,columnNdatatype(sizeN));

example :-Create table STUDENT440 (roll_no int, name varchar(20), sem number(2,0),
branch char(5), address varchar(20), email_id varchar(20)) ;

Divya Bajaj

1154440

SUSCET/ 5th

RDBMS FILE

2. DESC Tablename :- It is used display the structure of the table created. Syntax : desctablename ;

example :- desc STUDENT440;

3.INSERT INTO:-It is used to insert values in the table. Syntax:insert into tablename values(value1,value2,value3,.valueN);

example :insert into STUDENT440 values('1154440','Divya Bajaj','5','CSE','Moahli','divyabajaj@gmail.com'); insert into STUDENT440 values('1154477','Manmeet Singh','5','CSE','Mohali','manmeet@gmail.com'); insert into STUDENT440 values('1154461','Jasmeet Singh','5','CSE','Mohali','jasmeet@gmail.com'); insert into STUDENT440 values('1154411','Amanjot Singh','5','CSE','Patiala','amanjot@gmail.com')

Divya Bajaj

1154440

SUSCET/ 5th 4.SELECT:-a) It is used to retrieve all the data inserted in the table

RDBMS FILE

Syntax:Select * from tablename ;

example :select * from STUDENT440;

b)It is used to retrieve data from a particular column.


Syntax:Select column1,column2,columnN from tablename ;

example :select roll_no,name,branch from STUDENT440;

5. WHERE :-It is used with select clause to display data of particular column specified in condition. Syntax : Select * from tablename where <condition>

example :select * from STUDENT440 where roll_no = 1154440;

Divya Bajaj

10

1154440

SUSCET/ 5th

RDBMS FILE

EXPERIMENTNO.2
AIM :Create three tables client_master440,product_master440 and salesman_master440 and practice various commands.
1. Client_master440 table : create table client_master440(clientnovarchar(5),name varchar(20),address varchar(20),city varchar(20),pin number(8,2),state varchar(20),balancedue number(10,2));

insert into client_master440 values('c1','Pradeep Jindal','HNO.68','Ludhiana','123435','Punjab','50000'); insert into client_master440 values('c2','Varinderpal Singh','HNO. 680','Patiala','147001','Punjab','6500'); insert into client_master440 values('c3','Prateek Mehta','HNO. 23','Ambala','167251','Haryana','10000'); insert into client_master440 values('c4','Vinod Gupta','HNO. 109','Mohali','238976','Punjab','20000');

select * from client_master440;

OUTPUT :

2. Product_master440 table : create table product_master440(productno varchar(5),description varchar(10),profit_per number(8,2),qtyonhand int,sell_price number(8,2),cost_price number(8,2));

Divya Bajaj

11

1154440

SUSCET/ 5th

RDBMS FILE

insert into product_master440 values('p1','LG Mobile','5.5','10','18000','20000'); insert into product_master440 values('p2','LG TV','6.5','15','48000','52000'); insert into product_master440 values('p3','HP Laptop','4.5','9','54000','58000'); insert into product_master440 values('p4','Motorbike','2.5','5','43000','47000'); select * from product_master440;

OUTPUT :

3. Salesman440 table : create table salesman_master440(salesmanno varchar(5),name varchar(20),address varchar(20),city varchar(20),state varchar(20),salesamt number(8,2),targettoget number(6,2),sales number(8,2),remarks varchar(10));

Divya Bajaj

12

1154440

SUSCET/ 5th

RDBMS FILE

insert into salesman_master440 values('s1','Pramod Kumar','HNO. 65','Ambala','Haryana','3000','100','50','Good'); insert into salesman_master440 values('s2','Avinash Kapoor','HNO. 75','Patiala','Punjab','4000','200','10','Fair'); insert into salesman_master440 values('s3','Sarabjeet Singh','HNO. 95','Gurdaspur','Punjab','3000','200','50','Good'); insert into salesman_master440 values('s4','Harsh','HNO. 25','Karnal','Haryana','3500','300','150','Fair'); select * from salesman_master440;

OUTPUT :

1. DISTINCT Clause: It is used to delete the duplicate entries in the table.


Syntax : Select distinct from client_master440;

example :

Inserting duplicate entries in client_master440 table

insert into client_master440 values('c3','Arun Kashyap','HNO. 64','Patiala','173524','Punjab','10000'); insert into client_master440 values('c4','Abhilash','HNO. 84','Gurdaspur','173525','Punjab','20000');

OUTPUT :

Divya Bajaj

13

1154440

SUSCET/ 5th

RDBMS FILE

(a)select distinct * from client_master440 ;

OUTPUT :

(b)select distinct name ,city , balancedue from client_master440 ;

OUTPUT :

2. ORDER BY Clause :It is use to specify the order in which rows appear in the result set which can be in ascending or descending order. By default the order is ascending. Syntax:select * from tablname where condition=value order by columnname ;

example:(a) select * from salesman_master440 order by name; OUTPUT :

(b) select * from salesman_master440 where state='Punjab' order by name ;

Divya Bajaj

14

1154440

SUSCET/ 5th

RDBMS FILE

3. Creating table for existing table :- (a)Create table from another table and populate
the table with same value as present in other table

Syntax :
Create table tablename 1 (colm1,colm2..colm n) As select colm1,colm2..colmn from tablename2;

example :create table employe440(empno,name,address,city,pin,state,salary) As select


clientno,name,address,city,pin,state,balancedue from client_master440 ;

OUTPUT :

(b)Create table from another table without populating the values present in other table.

Syntax:Create table tablename(colm1,colm2.colm n) As selectcolm1,colm2..colm n from tablename where 1=2 ;

example :create table

workers440 (id,name,address,city,pin,state,salary) As select clientno,name, address,city,pin,state,balancedue from client_master440 where 1=2; select * from workers440;

OUTPUT :

Divya Bajaj

15

1154440

SUSCET/ 5th

RDBMS FILE

Retrive the names of all the clients from the table client_master:select name from CLIENT_MASTER440;

Divya Bajaj

16

1154440

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