Introduction to DBMS Database management has evolved from a specialized computer application to a control component of a modern computing environment. As such, knowledge about database system has become an essential part in computer science. Because in any organization, it requires accurate and reliable data for effective decision-making. In addition the Database Management exerts centralized control of the database, prevents fraudulent or unauthorized users from accessing the data, and ensures the privacy of the data. Data: Data is defined as the collection of meaningful facts which can be stored and processed by the computer. In other words, data is the material on which computer programs work upon. Data is raw facts or figures which can be processed. Data can be a number, letter of alphabets, words, special symbols and etc. but this information is unorganized. Information: Information is defined as the processed data that will help to make the further decision. Information will be generated after arranging the data into a suitable and meaningful form. The processed version of data is called information. ~ 1 ~ Data Process Information
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Introduction to DBMS
Database management has evolved from a specialized computer application to a control component of
a modern computing environment. As such, knowledge about database system has become an essential
part in computer science. Because in any organization, it requires accurate and reliable data for
effective decision-making. In addition the Database Management exerts centralized control of the
database, prevents fraudulent or unauthorized users from accessing the data, and ensures the privacy
of the data.
Data: Data is defined as the collection of meaningful facts which can be stored and processed by the
computer. In other words, data is the material on which computer programs work upon. Data is raw
facts or figures which can be processed. Data can be a number, letter of alphabets, words, special
symbols and etc. but this information is unorganized.
Information: Information is defined as the processed data that will help to make the further
decision. Information will be generated after arranging the data into a suitable and meaningful form.
The processed version of data is called information.
File processing system: File based system is the manual database to keep the records in which
human being manages the database without the support of computer. This is the traditional approach to
store the data. This system stores permanent records in the various files. In the file processing system
whole data scattered into various paper and notebook. When we want to find some data, we have to
search through the system from starting to end. The file based system was developed in response to the
need of industry for more efficient data access and data storage. In the early system the records was
stored in the file which is called file system.
File:A file is a collection of letters, numbers and special characters which contain record.
~ 1 ~
Data Process Information
HIERARCHY OF DATABASE
Bit 0.1
Byte 10101011(8-bits)
Field (Attribute name like name, Age, Address)
Record(One or more rows in a table)
File (Table or collection of all records)
Database (Collection of files or tables)
E.g.
Student (Database name)
Filed name or attribute name
Personal table name Academic (Table name)
~ 2 ~
Record
Disadvantages of file processing system:
Duplicacy of data: In manual system repetion of data create duplication. Duplication is wasteful as it
requires additional storage space. Data duplication creates the problem of data inconsistency. There is
possibility of information getting duplicated, this redundancy is storing same data multiple times leads
to higher costs and wastage of space.
Integrity Problem: The problem of integrity is the problem of ensuring that the data in the database is
accurate. Several types of constants must be imposed in order to enter the right type of data in the
database. But in file system it is not possible to apply the constraints.
Security Problem: Data stored in the file system must be safe from outsider. Any unauthorized user
can destroy the data and it leads to data inconsistency. In file processing system security constraints
are not easy to enforce.
Data dependence: In files data is stored separately in each file. File system leads data dependence as
when the data changed in one file, the corresponding data in other have also to be changed.
Difficult to share data: File system gives the sharing problem because data is stored in different files
uses different format. Which are not compatible with each other. Multiple users cannot share a single
file.
~ 3 ~
Name Father Name Age
John Albert 24
Ramesh Suresh 18
Difficult to get quick response: In file system, user can’t get quickly the required output. To find the
data user have to search the whole file.
Disadvantages of file processing system:
Concurrent problem: When more than one user need to access the same file at a simultaneously, is
known as concurrent problem. When more than one user at the same time read and update andf modify
the files it will create the problem as it may have inaccurate data.
Enable to represent data modeling of real world: The file system approach has the inability to
design a database which shows the basic entities, relationships and models.
What is the database?
A database is a collection of related information stored so that it is available to many users for
different purposes. The content of a database is obtained by combining data from all the different
sources in data in an organization. So that date are available to all users and redundant data can be
eliminated or at least minimized. A computer database gives us some electronic filing system,
which has a large number of ways of cross-referencing, and this allows the user many different ways
to reorganize and retrieve data. A sales base can handle business inventory, accounting and filing &
use the information in its files to prepare summaries.
Characterstics of data in the database:
Data in the database are shared by different users and application.
Data in the database are permanent.
Data should be secured and protected from unauthorized users.
Whenever more than one data elements in a database represent related data the data values
should be consisted.
Data should not be duplicated in the database.
~ 4 ~
Data should be independent in the database.
Data should be well organized.
It should be flexible to change.
Data should be correct.
Data should be available when needed
Significance of database:
Database plays an important role in the real world as we were used database in the manual system of
keeping the records where large number of files was used to store the data in the database. To solve
the problems found in following examples we need database.
Consider the example of majority of people whose phone number changed from five digits to six
digits then it would be difficult to change all the phone numbers from the telephone directory as we
need to change all the phone number. To overcome this situation we can create a new directory. With
this option the job will become more complex.
It is quite clear from the examples that traditional approach works at great accuracy if there
is less number of data to be processed. The manual approach does not work well if we have to process
larger amount of data. To overcome the problem of the manual system the database approach is used.
Why a database?
Handling of a small shop’s database can be done manually but if you have a large data base and
multiple users than in that case you have to maintain computerized database. The advantages of a
database system over traditional, paper-based methods of record keeping will perhaps make it
more apparent. Here are some of them.
1. Compactness: No need for possibly voluminous paper files.
2. Speed: The machine can retrieve and change data faster than a human being.
3. Less drudgery: Much of the sheer tedium of maintaining files by hand is eliminated.
Mechanical tasks are always better done by machines.
~ 5 ~
4. Accuracy: Accurate, up-to-date information is available on demand at any time.
Database Management System
There can be a database, which store newspaper articles, magazines, books and comics. There is
already a well-defined market for specific information for highly selected group of users on
almost all subjects. MEDLINE is a well-known database service providing medical information
for doctors and similarly WESTLAW is computer based information service catering to the
requirements of lawyers. The key for making all this possible is the manner in which the
information in the database is managed. The management of data in database system is done by
means of a generally purpose software package called a database system is done by means of a
general purpose software package called a Database Management system. The Database
Management system is the major software component of a database system. Some commercially
available DBMS are Ingress, ORACLE, and Sybase. A Database Management system, therefore,
is a combination of hardware and software that can be used to set up and monitor a database, and
can manage the updation and retrieval of database that has been stored in it.
Advantages of using DBMS
The DBMS has a number of advantages as compared to traditional file system. The DBA must
keep in mind these benefits or capabilities during designing databases, coordinating and
monitoring the DBMS. Following are the advantages of using DBMS:-
Controlling redundancy: Centralized control of data by the DBA avoids unnecessary
duplication of data and reduces the storage space. In traditional file processing, every user
maintain its own files. Each user independently creates their own data so therefore most of the
data is stored twice or more.
Minimizing data inconsistency: Data inconsistency exists when different copies of the same
data exist in different places. By controlling the data redundancy, the data consistency is obtained.
~ 6 ~
Restricting unauthorized access: Each DBMS provide security and authorization. Database
system requires you to login and then process the data. Each user can process the data according
the rights given by the DBA.
Advantages of using DBMS
Improved data access: The DBMS provide quick answer to queries of the user. The DBMS
quickly sends back the answer of the query.
Providing compatibility with programming languages: DBMS provide the compatibility with
the programming languages like C, C++, JAVA etc.
Data administrator: Data administrator means managing and organizing data from a central
point by the DBA. Administration provides a user to easily access the data according to its
requirement.
Enforcing integrity constraints: DBMS enforce integrity constraints on the data. For example,
before inserting salary information for an employee, the DBMS can check that the data
department budget is not exceeded.
Providing backup and recovery: Each DBMS provide the facilities for recovering from
hardware or software failure, such as disk crash, power failure, software errors.
Disadvantages of using DBMS
Although there are many advantages of DBMS, the DBMS may also have some minor
disadvantages. These are:
Cost of hardware and software: A processor with high speed of data processing and memory of
large size is required to run the DBMS software. The cost of these hardware and software are very
high.
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 file. It is very difficult and costly
~ 7 ~
method to convert data of data files into database. You have to hire database and system
designers. So a lot of money has to be paid for data conversion.
Cost of staff training: Most DBMS are often complex systems so the training for users to use the
DBMS is required. The organization has to be paid a lot of amount for the training of staff to run
the DBMS.
Appointing technical staff: The trained technical persons such as database administrator
application programmers, data entry operators etc. are required to handle the DBMS. Companies
have to pay high salaries to these persons.
Database damage: In most of the organization, all data is integrated into a single database. If
database is damaged due to electric failure or database is corrupted on the storage madia, then you
valuable data may be lost forever.
Privacy and security is reduced: When information is centrally stored and is made available to
remote users, the possibilities of destruction of data is often more than traditional system.
Database administrator
A database administrator(DBA) is a person who is responsible for the management of a database.
DBA is a person or group of persons who implements the policies of an organization. He is
responsible for authorizing access, monitoring database use, providing satisfactory response time,
backup and recovery from the system failure. DBA has all the powers of the database.
Duties of the DBA
The main duties of the DBA are as under:
Installation of new software: It is basic the job of the DBA to install new version of DBMS
software, application software, and other software related to DBMS administration.
~ 8 ~
Data dictionary management: Management & control of data dictionary is an important role of
the DBA.DBA creates the data definition, data validation rules, documentation of data dictionary
and etc.
Duties of the DBA
Scheme defination: The creation of the original database scheme. This involves data storage and
definition language technique.
Storage structure and access method definition: Writing a set of definition used by the data
storage and language compiler.
Define integrity rules: DBA is responsible for defining integrity rules for the database. These
rules help to maintain database security.
Configuration of hardware and software with the system administrator: DBA works with the
system administrator to take decision about hardware and software settings.
Security administration: DBA has to monitor and check DBMS security. This involves adding
and removing users and provide permission to them.
Data analysis:DBA has to analyze the data stored in the database and he has to give
recommendation relating to performance and efficiency of that data storage.
Database design: A DBA has to design database on each level. DBA creates the policy about
internal, conceptual, and external level.
Components of the DBMS
A database system is composed of four components;
Data
Hardware
Software
~ 9 ~
Users
Which coordinate with each other to form an effective database system.
Data: It is a very important component of the database system. Most of the organization generate,
store and process large amount of data. The data acts a bridge between the machine and the user.
User can directly access the data from the machine. Data may be of different types:
User Data : The user data is stored in rows and column in the form of tables.
Metadata: A description about the structure of the database is known as Metadata. It means “data
about data”. It stores in data dictionary.
Hardware: The hardware consists of any kind of physical storage device like secondary storage
devices like disks(hard disk, zip disk, floppy disk), optical disks(CD-ROM), magnetic tapes etc. on
which data is stored together with the Input/Output devices (mouse, keyboard, printers),
processors, main memory etc. which are used for storing and retrieving the data in a fast and
efficient manner.
~ 10 ~
users
Application program
Application program
Data and program
Application program
Application program
database
DBMS
users
Components of the DBMS
Software: The software acts as a bridge between the users and the database. Software interacts
with the users, application programs, and database and file system. Software helps to insert, delete,
update, and retrieve data.
Users: Users are those persons who need the information from the database. On the basis of the
job and requirement made by them they are provided access to the database totally or partially.
The various types of users which are access the database are:
Database administrator (DBA)
Database designer
End users
Application programmer
Database administrator: Administrator (DBA) is a person who is responsible to manage
implements the policies of an organization. He is responsible for authorizing access, monitoring
database use, providing satisfactory response time, back up and recovery from the system failure.
DBA has all the powers of the database.
Database designer: Database designer performs the duty to identify the data to be stored and also
choose the database structure.
End users: End users are those users who interact with the database and they use the information
stored in the database.
~ 11 ~
Application programmer: These are the professional users, who are responsible for writing the
application program. The application program could be written in a general purposes language
such as C, COBOL, and embedded in the program.
Structure of DBMS:
DBMS (Database Management System) acts as an interface between the user and the database.
The user requests the DBMS to perform various operation (insert, delete, update and retrieval) on
the database. The components of DBMS perform these requested operations on the database and
provide necessary data to the users. The various components of DBMS are shown below:
~ 12 ~
File manager
Data manager
Database
User User User
Query processor
DDL/DMLCompiler
Data dictionary
Query optimizer
DDL Comiler:
Data Description Language compiler processes schema definition specified in the DDL. It uses the
information such as name of the file, data items, storage details of each file etc. it works in
CREATE and ALTER query.
DML Compiler and Query optimizer:
The DML commands such as insert, delete, update can be processed through DML compiler. It
compiles your query and convert into the object code. The object code is the best way to execute a
query by the query optimizer and then send to the data manager.
Data Manager:
The Data Manager is the central software component of the DBMS also known as Database
Control System.
The main features of Data Manager are:-
o Convert operation in user’s queries.
o Control information access.
o It also control buffer in main memory.
o It also implements constraint.
o It also control the back up and recovery operations.
Data Dictionary:
Data Dictionary stores the description of data in the database. It contains information about
Data – names of the tables, names of the attributes of each table, length of attributes, and
numbers of rows in each table.
~ 13 ~
It stores various relation and links between different tables.
Constraints on data i.e. range of value permitted.
Detailed information on physical database design such as storage structure, access paths,
files and record sizes.
It stores access permission or rights on table.
Importance of data Dictionary:
Data dictionary is necessary in the data base due to following reason:
It improves the control of DBA over the information system.
It helps in documentation the database design process.
It helps in searching the view on the database.
It promotes data Independence.
Data Files:
It contain the data portion of the database.
Compiled DML:
The DML complier converts the high level query into low level commands known as complied
DML.
End User:
End user are those user who interact with the database & they use information store in the
database.
Architecture of the DBMS:
~ 14 ~
The three level architecture is also known as three Schema Architecture. The purpose of the three
level architecture is to separate the user application and the physical database. The three level
architecture is a convenient tool by which user can visualize data according to their level.
Schema: The view at each level is described by scheme. A scheme is an outline or plan that
describes the record and relationships existing in the view. Schema is basically used to define the
structure of the database.
The Three-Schema Architecture:
Objectives:
~ 15 ~
End users
External view viview
External view
External/conceptual mapping
Conceptual Schema
Conceptual/Internal mapping
Internal Schema
Stored database
1. It allows independent customized user views. Each user should be able to access the same
data in different views. These views should be independent.
2. It hides the physical storage details from the users.
3. The database administrator should be able to change the database storage structure without
affecting the user’s views.
Database Schemas:
There are three different types of schema corresponding to the three levels in the ANSI-SPARC
architecture.
The external schemas describes the different external views of the data.
The conceptual schema describes all the data items and relationships between them.
The internal schema defines the storage structure of data on physical device.
Levels
The three level architecture is divided into three view levels;
External view level
Conceptual view level
Internal view level
External data level
The external view is at the Highest Level of database Abstraction. The external view is closest to
the users. It describes how data can be viewed by individual users. The external view are defined
by the help of external schemas.
Conceptual view:
At this level of database abstraction all the entities and the relationship among them are included.
One conceptual view represent the entire database. This conceptual view is defined by the
~ 16 ~
conceptual schema. This view is also known as logical view. Logical view is basically concerned
with the DBA, who decide what information to be kept in the database.
Internal view:
The internal view is also referred to as physical view level. It describes the physical storage
structure of database. The internal view describes how the data is stored in the database. It works
with the operating system and DBMS for storing and retrieving data to and from the storage
devices.
Mapping
The process to convert the request(from external level) and the result between levels is called
mapping. The mapping defines the correspondence between three levels. The mapping description
is also stored in the data dictionary. The DBMS is responsible for mapping between these three
This section describes many of the reason for SQL’s widespread acceptance by relational
database vendors as well as end users. The strength of SQL benefit all ranges of users including
application programmers, database administrators, and management a few and end users.
Non –Procedural Language
~ 59 ~
SQL is a non –procedural language because it:
Processes sets of records rather than just one in a time;
Provides automatic navigation to the data
System administrator
Database administrators
Security administrators
Application programmers
Decision support system perdsonnel
Many other types of end users
SQL provides easy-to-learn commands that are both consistent and applicable to all users. The
basic SQL command can be learned in a few hours and even the most advanced commands can be
mastered in a few days.
Unified languages:
SQL provides commands for a variety of task including:
Querying data;
Inserting, updating and deleting rows in a table;
Creating, replacing, altering and dropping objects;
Controlling access to the database and its object;
Guaranteeing database consistency and language.
SQL unifies all the above tasks in one consistent language.
~ 60 ~
Common Language for all Relational Databases
Because all major relational database management system support SQL, you can transfer all skill
you have gained with SQL from one database to another. In addition, since all programs written
in SQL are portable, they can often be moved from one database to another with very little
modification.
Embedded SQL
Embedded SQL refers to the use of standard SQL commands embedded within a procedure
programming language. Embedded SQL is a collection of these commands.
All SQL commands, such as SELECT and INSERT, available with SQL with interactive tools;
Flow control commands, such as PREPARE and OPEN, which integer the standard SQL
commands with a procedural programming language.
The Oracle precompilers support embedded SQL. The Oracle precompilers interpret embedded
SQL statements and translate them in to statements that can be understood by procedural language
compiler. Each of these Oracle precompilers translate embedded SQL programs in to a different
procedural language:
The Pro*Ada precompiler
The Pro*C/C++ precompiler
The Pro*COBOL precompiler
The Pro*FORTAN precompiler
The Pro*Pascal precompiler
The Pro*PL/1 precompiler
Database Objects
~ 61 ~
Oracle supports two types of data objects.
Schema objects: A schema is a collection of logical structure of data, of schema objects. A
schema is owned by a database user and has the same name as that user. Each user owns a single
schema. Schema objects can be created and manipulated with SQL and include the following
types of object
Non-schema Objects: Other types of objects are also stored in the database and can be created and manipulated with SQL, but are not contained in a schema.
Object Naming Conventions
The following rules apply when naming objects:
Names must be from 1 to 30 characters long with the following exceptions:
Names of databases are limited to 8 characters. Names of database links can be as long as 128 characters.
Names cannot contain quotation marks.
Names are not case-sensitive.
A name must begin with an alphabetic character from your database character set unless surrounded by double quotation marks.
~ 62 ~
Cluster database links database triggers
Indexes packaged sequences
Snapshots snapshot logs stored functions
Stored procedures synonyms tables
Views
Profiles Rates
Tallback segments table spaces
Users
Names can only contain alphanumeric character form your database character set and the character_,$ and#. You are strongly discouraged from using $ and#.
Names of the databases links can also contain periods(.) and ampersand(&).
Object Naming Guidelines
There are several helpful guidelines for naming objects and their parts:
Use full, description, pronounceable names (or well-known abbreviation).
Use consistent naming rules.
Use the same name to describe the same entity or attributes across tables.
When naming objects, balance the objective of keeping names short and easy to use with the objectives of making names as long and descriptive as possible. When in doubt, choose the more descriptive name because many people may use the objects in the database over a period of time. Your counterpart ten years from now may have difficulty in understanding a database with names like PMDD instead of PAYMENT_DUE_DATE.
Using consistent naming rules helps users to understand the part that each table plays in your application. One such rule might be to begin the names of all tables belonging to the FINANCE application with FIN_.
Use the same names to describes the same things across tables. For example, the department number columns of the EMP and DEPT tables should both be named DEPTNO.
internal datatype Description VARCHAR2 Variable length character string having maximum length size bytes. Maximum
size is 2000 and min. is 1. You must specify size for a VARCHAR2. Number (p,s) Number having precision p and scale s.The precision p can range 1 to 38. The
scale s can range form-84 to 127.LONG Character data of variable length upto 2 gigabites, or 231-1 bytes.DATE Valid data range from January 1,4712 BC to December 31,4712 AD.RAW(size) Raw binary data of length size bytes. Maximum size is 255 bytes. You must
specify size of a RAW value. LONG RAW Raw binary data of variable length up to 2 gigabytes.CHAR(size) Fixed length character data of length size byte. Maximum size is 255. Default
and minimum size is 1 byte.
~ 63 ~
Character data types:
Character data types are used to manipulate words and free-form text. These data types are used to store character (alphanumeric) data in the database character set.
CHAR Data Type
The CHAR data type specifies a fixed length character string. When you create a table with in CHAR column, you can supply the column
Introduction to Query by Example
~ 64 ~
QBE is a simple point and click way for non-technical users to build queries, and is built in to Access. This unit will introduce you to the various queries like SELECT query, Make-Table query, DELETE query, UPDATE query, APPEND query.
SELECT Queries
It is used to retrieve data from one or more tables and display the results in a datasheet, which you can save or modify. You can also use Select queries to group records and calculate sums, averages and so on. Any time you create a new query it is a select query until you tell Access to make it something else. When you run a select select query, Access display the dynaset, which you can then view and make changes to record by record.
How to create a select query by using the wizard
The following steps show you how to create a query to retrieve information about customers and orders from the Northwind sample database that is included with Microsoft Access.
1. Start Microsoft Access , and then open the sample database Northwind.mdb.
2. On the View menu, point to Database Objects, and then click Queries.
3. On the Insert menu, click Query.
4. In the New Query dialog box, click Simple Query Wizard, and then click OK.
5. In the Simple Query Wizard dialog box, click the Customers table in the Tables/Queries list. Double –click each of the following fields to add them to the Selected Fields box: CustomerID, CompanyName, ContactName, ContactTitle.
6. On the same page of the Simple Query Wizard, click the Orders table in the Tables/Queries list. Click >> to add all the fields from the Orders table to the Selected Fields box.
7. Click Finish. The Simple Query Wizard constructs the query, and displays the results in Datasheet view.
How to Create a Select Query in Design View
1. Start Microsoft Access.
~ 65 ~
2. Open the Northwind.mdb sample database.
3. On the View menu, point to Database Objects, and then click Queries.
4. In the Database Window, double-click Create Query in Design View.
5. In the Show Table dialog box, click Customers, and then click Add.
6. Repeat step 5 for the Orders Table
7. Click Close to close the Show Table dialog box
8. In the Customer table field list in the top half of the query design window, double-click to add the following fields: CustomerID, CompanyName, ContactName, ContactTitle .
9. In the Order table field list in the top half of the query design window, double-click the *. Adding the * is the equivalent of selecting all the fields from a particular table.
10. On the File menu, click Save. Type qryCustomerOrders for the name of the query.
11. On the Query menu, click Run to view the results of the query.
Action Queries
While finding and organizing the information stored in your database is an immensely useful task, queries are capable of doing much more. They can actually perform specified tasks for you and make managing your data a great deal easier. Queries that perform jobs for you are known as action queries because they do things with or to the information stored in your tables. A query can look for and modify records that have an unmatched field between two related tables, update records stored in your tables, delete specified records from one or more tables, create a new table for you , or even add records to an existing table. All of these jobs would take a good while to do manually, but a carefully designed query can accomplish them in a matter of seconds.
Access provides four types of action queries:
A Make-Table query creates a new table from all or part of another table or tables.
A Delete query deletes records from a table or tables.
An Append query adds a group of records to an existing tables or tables.
An Update query changes the data in a group of records.
~ 66 ~
The Make-Table Query
A Make-table query creates a new table by retrieving the records you asked for and using them to make a new table. You can choose the fields from one or more existing tables to include in the new tables and can also specify the criteria that must be met from each fields.
Delete Query
To remove a number of records that meet the same criteria, it is much faster to use a Delete query than to delete each record separately.
Append Query
An Append question query is an action query that adds from one or more Access tables to another existing tables. As with make-table queries, you can append records to a table in the current database or in another database.
Update Query
With an update query, you can change data in existing tables. Update queries allow you to update large quantities of information in a single action.