[Link] | [Link] | [Link].
in
Database Management System [Link](Computer Science)-II Year(IV Semester)
DATABASE MANAGEMENT SYSTEM
Syllabus
Unit-I
Introduction to Databases: Introduction, Traditional File-Based Systems, Database Approach,
Roles in the Database Environment, Advantages and Disadvantages of DBMSs, The Three-
Level ANSI-SPARC Architecture, Database Languages, Data Models, Functions of a DBMS,
Components of a DBMS Relational Model: Introduction, Terminology, Integrity constraints,
Views. The Relational Algebra: Unary Operations, Set Operations, Join Operations, Division
Operation, Aggregation and Grouping Operations.
Unit-II
Entity-Relationship Modeling: Entity Types, Relationship Types, Attributes, Keys, Strong and
Weak Entity Types, Attributes on Relationships, Structural Constraints, Problems with ER
Models-Fan Traps, Chasm Traps. Enhanced Entity-Relationship Modeling:
Specialization/Generalization, Aggregation, Composition. Functional Dependency: Multi
Valued Dependency, Join Dependency. Normalization: The Purpose of Normalization, How
Normalization supports Database Design, Data Redundancy and Update Anomalies, Functional
Dependencies in brief, The Process of Normalization, INF, 2NF, 3NF, BCNF. The Database
Design Methodology for Relational Database (Appendix-D).
Unit-III
SQL: Introduction, Data Manipulation-Simple Queries, Sorting Results, Using the SQL
Aggregate Functions, Grouping Results, Sub- queries, ANY and ALL, Multi table Queries,
EXISTS and NOT EXIST, Combining Result Tables, Database Updates SQL: The ISO SQL
Data Types, Integrity Enhancement Feature-Domain Constraints, Entity Integrity, Referential
Integrity, General Constraints, Data definition-Creating a Database, Creating a Table, Changing
a Table Definition, Removing a Table, Creating an Index, Removing an Index, Views- Creating
a View, Removing a View, View Resolution, Restrictions on Views, View Updatability, WITH
CHECK OPTION, Advantages and Disadvantages of Views, View Materialization,
Transactions, Discretionary Access Control- Granting Privileges to other Users, Revoking
Privileges from Users Advanced SQL: The SQL Programming Language- Declarations,
Assignments, Control Statements, Exceptions, Cursors, Subprograms, Stored Procedures,
Functions, and Packages, Triggers, Recursion.
Unit-IV
Transaction Management: Transaction Support-Properties of Transaction, Database
Architecture, Concurrency Control- the Need for Concurrency Control, Serializability and
Recoverability, Locking Methods, Deadlock, Time Stamping Methods, Multi-version
Timestamp Ordering, Optimistic Techniques, Granularity of Data Items, Database Recovery-
The Need for Recovery, Transaction and Recovery, Recovery Facilities, Recovery Techniques,
Nested Transaction Model. Security: Database Security-Threats, Computer-Based Controls-
Authorization, Access Controls, Views, Backup and Recovery, Integrity, Encryption, RAID.
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 1
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
Text Book:
1. Thomas M. Connolly, Carolyn E. Begg, Database Systems- A Practical Approach to
Design, Implementation, and Management (6e).
References
1. Sharon Allen, Evan Terry, Beginning Relational Data Modeling
2. Jeffrey A. Hoffer V. Ramesh, Heikki Topi, Modern Database Management
3. Raghu Ramakrishnaan, Johannes Gehrke, Database Management Systems
4. Ramez Elmasri, Shamkant B Navathe, Fundaments of Database Systems
5. Abraham Silberschatz, Henry F. Korth, S. Sudarshan, Database System
6. Concepts C Coronel, S Morris, Peter Rob, Database Systems: Design, Implementation,
and Management
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 2
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
UNIT- I
Data: Data is a raw collection of facts about people, places, objects and events, which include
text, graphics, images, sound etc that have meaning in the user’s environment.
Data is given by the user to the computer.
It is not understandable (meaningless).
It requires processing.
Example: 1Data Sri 35 45 55 Data (Here, it is not clear whether 35
2 Ram 75 80 98
is rno (or) marks)
Information: Information is meaningful data in an organized form. Information is processed
data that increases the knowledge of a person who uses the data.
Information is given by the computer to the user.
It is understandable (meaningful).
It is processed data.
Example: Sno Name M1 M2 M3
(Number) (Varchar) (Number) (Number) (Number)
1 Sri 35 45 55 Information
2 Ram 75 80 98
Data Process
Information
Meta data: Meta data is data about data. It describes the properties/characteristics of other data.
It includes field names, data types and their size.
It is used for processing
It gives meaning to the data.
Sno Name M1 M2 M3 Meta data
(Number) (Varchar) (Number) (Number) (Number)
Data base: A data base is a collection of logically related data stored in a standardized format
and is sharable by multiple users. (OR)
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 3
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
A mass storage of data that is generated over a period of time in a business environment
is called “data base”.
Symbol of data base is:
Example:
1. University database: In this we can store data about students, faculty, courses, results, etc.
2. Bank database: In this we can store data about Account holders.
Database Management System (DBMS): It is a set of databases and a set of application
programs that allows us to organize, manipulate and retrieve information. (OR) The collection
of interrelated data and a set of programs to access data conveniently, easily and efficiently is
called as DBMS.
DBMS = Database + Software
DBMS S/W
User Database
DBMS software is an interface between user and Database.
DBMS provides services like storing, updating, deleting and selecting data.
Database system: It is a set of Databases, DBMS, Hardware and people who operate on it.
Evolution of database system:
Late 1950’s : Sequential file processing systems were used in late 1950’s. In these systems, all
records in a file must be processed in sequence.
1960’s : Random access file processing systems were greatly in use in this period. It
supported direct access to a specific record. In this, it was difficult to access
multiple records though they were related to a single file.
1970’s : During this decade the hierarchical and net work database management systems
were developed and were treated as first generation DBMS.
Late 1970’s: E. F. Codd and others developed the relational data model during this 1970’s. This
model is considered second generation DBMS. All data is represented in the form
of tables. SQL is used for data retrieval.
1980’s : Object Oriented model was introduced in 1980’s. In this model, both data and
their relationships (operations) are contained in a single structure known as object.
1990’s : Client/ Server computing were introduced, then data ware housing, internet
applications.
2000 : Object oriented database systems were introduced.
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 4
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
**Traditional File Processing System**
File is a place where a group of related data is stored. (OR) Collection of records is called
“file”. At the time of 1950’s sequential file processing systems were used to maintain the data.
Later, in 1960’s Random Access file processing systems were introduced.
File management system was the first method used to store the data in a
computerized database. The traditional filing system (TFS) is a method of storing and
arranging computer files and the information in the file (data). Basically it organizes
these files into a database for the storage, organization, manipulation, and retrieval by the
computer's operating system.
Characteristics (OR) Advantages of File Processing System:
It is a group of files storing data of an organization.
Each file is independent from one another.
Each file is called a flat file.
Each file contained and processed information for one specific function, such as accounting
or inventory.
Files are designed by using programs written in programming languages such as COBOL, C,
and C++.
The physical implementation and access procedures are written into database application;
therefore, physical changes resulted in intensive rework on the part of the programmer.
As systems became more complex, file processing systems offered little flexibility,
presented many limitations, and were difficult to maintain.
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 5
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
Disadvantages of file processing system:
1. Program data independence: File descriptions are stored within each application program
that accesses a given file. Any changes made to a file structure require changes to the file
descriptions for all programs that access the file. So errors are often introduced when making
changes.
2. Duplication of data: Applications are often developed independently in the file processing
systems, surely there will be duplication of data files. This duplication is wasteful, since it
requires additional storage space.
3. Limited data sharing: With the traditional file processing approach, each application has its
own private files and users have little opportunity to share data outside their own
applications.
4. Lengthy development times: In traditional file processing systems, there is little
opportunity to support previous development efforts each new application must be started
from scratch by designing new file formats and descriptions and process becomes very
lengthy and time consuming.
5. Excessive program maintenance: The above factors all combine to create heavy program
maintenance load in organizations that rely on traditional file processing systems.
6. Data Security: The security of data is low in file based system because, the data is
maintained in the flat file(s) is easily accessible.
**Database Approach**
In order to remove all limitations of the File Based Approach, a new approach was
required that must be more effective known as Database approach.
The Database is a shared collection of logically related data, designed to meet the
information needs of an organization. A database is a computer based record keeping system
whose over all purpose is to record and maintains information. The database is a single, large
repository of data, which can be used simultaneously by many departments and users. Instead of
disconnected files with redundant data, all data items are integrated with a minimum amount of
duplication.
The database is no longer owned by one department but is a shared corporate resource.
The database holds not only the organization's operational data but also a description of this
data.
For this reason, a database is also defined as a self-describing collection of integrated
records. The description of the data is known as the Data Dictionary or Meta Data (the 'data
about data'). It is the self-describing nature of a database that provides program-data
independence.
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 6
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
Building blocks of a Database:
The following three components form the building blocks of a database. They store the
data that we want to save in our database.
Columns: Columns are similar to fields, that is, individual items of data that we wish to store.
A Student' Roll Number, Name, Address etc. are all examples of columns.
Rows: Rows are similar to records as they contain data of multiple. A row can be made up of as
many or as few columns as you want.
Tables: A table is a logical group of columns. For example, you may have a table that stores
details of customers' names and addresses. Another table would be used to store details of parts
and yet another would be used .for supplier's names and addresses.
It is the tables that make up the entire database and it is important that we do not
duplicate data at all.
**Roles in Database Environment**
There are 4 distinct types of people involved in Database environment:
1. Data & Database Administrators
2. Database Designers
3. Application Programmers
4. End-Users
Data & Database Administrators:
DA (data administrator) is responsible for the management of the data resource:
Database planning
Development & maintenance of standards
Policies and procedures
Conceptual/logical database design
DBA (Database Administrator) is responsible for the physical realization of the database:
Physical database design & implementation
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 7
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
Security & integrity control
Maintenance of operational system
Ensuring satisfactory performance of the applications for users
Database designers: They are concerned with:
Identifying the data
Identifying relationship between entities and attributes
Identify the relationships between the data
Understand the constraints on the data (business rules)
a. Logical database designer: Identify data (entities & attributes), relationships b/w data,
and constraints on the data.
b. Physical database designer: Map the logical data models into a set of tables &
integrity constraints, Selecting specific storage structures and access methods for the data,
designing security measures.
Application programmers: Uses a 3rd or 4th generation programming language. They worked
from the specification produced by systems analysts. Each program may contain statements that
request the DBMS to perform some operation:
Retrieving data
Insert data
Delete data
Updating data
End Users: They are the clients of the database. They can be classified as:
Naive users: Typically unaware of the DBMS
Sophisticated users: Familiar with the structure of the DBMS. May use a high-level
query language to perform required operation.
** Advantages of DBMS **
Database Management System (DBMS): It is a set of databases and a set of application
programs that allows us to organize, manipulate and retrieve information. (OR) The collection
of interrelated data and a set of programs to access data conveniently, easily and efficiently is
called as DBMS. Advantages are:
1. Program data independence: the separation of data descriptions (metadata) from the
application programs that use the data is called data independence. With this database
approach, data descriptions are stored in a central location called repository. This allows data
to change without changing the application programs.
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 8
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
2. Minimal data redundancy: Unnecessary data can be reduced. There will not be any
duplicate. Each primary fact is recorded in only one place in the database, so that we can
avoid the wasted storage space.
3. Improve data consistency. By eliminating data redundancy, we can improve data
consistency. For example, if a customer address is stored only once, updating that becomes
simple.
4. Improved data sharing: A database is designed as a shared resource. Authorized users are
granted permission to use the database and each user is provided one or more user views to
facilitate this use.
5. Improved data accessibility: without any programming experience, one can retrieve and
display data very easily. The language used to write queries is called structured query
language ( SQL).
6. Enforcement of standards: these standards will include naming conventions, data quality
standards and procedures for accessing, updating and protecting data.
7. Focus on data: DBMS focuses on data. It first defines the data and then all queries, reports
and programs to access the data through the DBMS.
8. Reduced program maintenance: In a database environment the data are more independent
of application programs. As a result, program maintenance can be significantly reduced in a
database environment.
** Disadvantage of DBMS **
1. Cost: DBMS requires high initial investment for hardware, software and trained staff. A
significant investment based upon size and functionality of organization if required.
2. Complexity: A DBMS fulfill lots of requirement and it solves many problems related to
database. But all these functionality has made DBMS extremely complex software.
Developer, designer, DBA and End user of database must have complete skills if they want
to user it properly. If they don’t understand this complex system then it may cause loss of
data or database failure.
3. Technical staff requirement: Any organization has many employees working for it and
they can perform many others tasks too that are not in their domain but it is not easy for
them to work on DBMS. A team of technical staff is required who understand DBMS and
company have to pay handsome salary to them too.
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 9
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
4. Database Failure: As we know that in DBMS, all the files are stored in single database so
chances of database failure become more. Any accidental failure of component may cause
loss of valuable data. This is really a big question mark for big firms.
5. Size: As DBMS becomes big software due to its functionalities so it requires lots of space
and memory to run its application efficiently. It gains bigger size as data is fed in it.
6. Performance: Traditional files system was very good for small organizations as they give
splendid performance. But DBMS gives poor performance for small scale firms as its speed
is slow.
** Three-level ANSI SPARC Database Architecture **
The Architecture of most of commercial dbms are available today is mostly based on this
ANSI-SPARC database architecture. ANSI SPARC THREE-TIER architecture has main three
levels:
1. Internal Level (or) Physical level
2. Conceptual Level (or) Logical level
3. External Level
These three levels provide data abstraction; means hide the low level complexities from end
users. A database system should be efficient in performance and convenient in use.
Using these three levels, it is possible to use complex structures at internal level for efficient
operations and to provide simpler convenient interface at external level.
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 10
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
1. Internal level:
This is the lowest level of data abstraction.
It describes how the data are actually stored on storage devices.
It is also known as physical level.
It provides internal view of physical storage of data.
It deals with complex low level data structures, file structures and access methods in
detail.
It also deals with Data Compression and Encryption techniques, if used.
2. Conceptual level:
This is the next higher level than internal level of data abstraction.
It describes what data are stored in the database and what relationships exist among those
data.
It is also known as logical level.
It hides low level complexities of physical storage.
Database administrator and designers work at this level to determine what data to keep in
database.
Application developers also work on this level.
3. External Level:
This is the highest level of data abstraction.
It describes only part of the entire database that a end user concern.
It is also known as an view level.
End users need to access only part of the database rather than entire database.
Different user needs different views of database. And so, there can be many view level
abstractions of the same database.
** Database languages **
Database languages are used for read, update and store data in the database. There are
several such languages that can be used for this purpose, one of them is SQL (Structured Query
Language).
Types of DBMS languages:
Data Definition Language: DDL commands are used to define the “structure of a database”.
DDL deals with metadata. The commands are:
1. Create: Is used to create a new database object such as tables, views, etc.
2. Alter: Is used to change the structure of a database object.
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 11
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
3. Truncate: Is used to delete total rows permanently, without deleting structure.
4. Drop: Is used to delete/erase database object permanently.
5. Rename: Is used to rename the database object.
Data Manipulation Language: DML commands are used to manipulate (or) access a database,
including updating, modifying and querying data. It deals with data. The commands are:
1. Insert: Is used to store a new record into a database table.
2. Update: Is used to edit/change the values of attributes in a table.
3. Delete: Is used to remove (delete) one or more rows from a table.
4. Select: Is used to retrieve data from a table.
Data control Language: DCL commands are used to have a control over the database, when it
is shared among multiple users. The commands are:
1. Grant: Is used to give privileges (permissions) on database object to other users.
2. Revoke: Is used to take the given privileges back (cancel) from the users.
Transaction Control Language: TCL commands are used to control the transaction. The
commands are:
1. Commit: Is used to make changes permanent on the storage when a transaction is
successfully completed.
2. Rollback: Is used to cancel (Undo) the changes.
3. Save point: Is used to make Limit (margin) for commit or rollback.
** Data models **
A data model is a simple graphical representation of real-world entities (objects).
According to Hoberman (2009), “A data model is a way of finding the tools for both business
and IT professionals, which uses a set of symbols and text to precisely explain a subset of real
information to improve communication within the organization and thereby lead to a more
flexible and stable application environment”.
A data model represents the structure of data in a database.
A data model is a communication tool (conceptual tool) for describing data, relationship
and constraints.
Data modeling is the first step in designing a database.
A data model can provide interaction among the designer, application programmer and
end user.
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 12
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
A good database is designed only when we develop good data model.
A data model can be of two types.
1. Record Based data models
2. Object Based data models.
Record-based data models: In this model, data is represented in the form of fixed format
records. The Record-based data models are:
1. Hierarchical model
2. Network model
3. Relation model.
Hierarchical model: A Hierarchical data model is a data model, in which the data organized
into a “tree” like structure. This structure represents the information using “parent/ child”
relationship.
Each parent can have many children but each child has only one parent.
The hierarchical structure contains levels or segments.
The root segment is the parent of the level1 segment, which in turn is the parent of level2
segment, etc.
In short, it represents one-to-many (1: M) relationship between parent and children
segments.
The hierarchical model was developed in 1970’s.
The following diagram is an example for hierarchical model.
Manager Root
Level1 Segment
Asst_Manager1 Asst_Manager2
(Root Children)
Level2 Segment
Clerk1 Clerk2 Clerk1 Clerk2 (Level1 Children)
Advantages:
It provides data sharing.
It provides data security.
It provides data integrity, conceptual simplicity.
Efficient with 1: M relationship.
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 13
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
Disadvantages:
Does not support many-to-many (M: N) relationship.
No support to DDL& DML.
Difficult to manage.
Structural dependency.
Network model: In the network model, a parent can have several children and a child can also
have many parent records. Records are physically linked through pointers. A pointer can store
address.
The network model was created to represent complex relationships.
This model was developed in 1970’s.
The network database is a collection of records in 1: M relationship.
In network database terminology, a relationship is called a set. Each set is composed of at
least two record types; a parent record & a child record.
A set represents 1: M relationship between the parent and child.
Nodes
Suppliers
S1 S2 S3
Links
Customers
C1 C2 C3
Advantages:
It supports DDL& DML.
Handles more relationships types such as M: N.
It supports data integrity.
Conceptual simplicity.
Disadvantages:
Complex implementation
Structural dependency.
Relational model: Relational model was introduced in late 1970’s by [Link]. In this model,
the data is maintained in the form of tables consisting of rows and columns.
Data in two tables is related through common columns.
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 14
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
Unlike hierarchical and network models, there are no physical links in relational model.
Example: The following set of tables-is an example for relational model.
Table: EMPLOYEE Table: DEPARTMENT
empno ename job salary deptno deptno deptname
(Foreign key) (Primary key)
1003 Ravi Manager 12000 10 10 Finance
1004 Rajesh Clerk 5000 20 20 Accounts
1005 Kiran Clerk 5000 30 30 Marketing
Advantages:
Structural independence.
Supports SQL (Structured Query Language).
Easier database design, implementation and use.
Disadvantages:
Requires high configuration (Hardware & Software)
Possibility of poor design & implementation.
Object-based data model: These models Represents the data in the form of objects. The
object-based data models are:
1. Object-oriented data model
2. Entity-relationship model.
Object-oriented data model: This model was introduced in 1990’s. In this model, the data is
represented in the form of objects. In this model we can store not only data but also procedures
(methods). Object-oriented data model is based on following components.
Object: Object is a real time entity that must be existing in the world.
Attribute: It describes the properties/characteristics of an object.
Ex: STUDENT object contains attributes like sno, name, marks, etc.
Method: It is a set of instructions that performs a specific task.
Representation of an object Example
STUDENT Object
Method1 sno
name
Data
Data marks Attributes
Method2 Method3 write( )
read( )
play( ) Methods
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 15
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
Entity-Relationship model: Entity-Relationship model is graphical representation of entities,
attributes and relationship.
This model becomes very popular because it is easier to understand databases graphically
than text.
ER model was introduced by “Peter Chen” in 1976.
ER model is based on the following components.
Entity: An entity is a person, place, object, event or concept in user’s environment, which we
want to store in database. It is represented in the ERD by a “rectangle”.
Attribute: It describes the properties/characteristics of an entity. It is represented by an
“ellipse”.
Relationship: Relationship describes associations among data. It is represented by a
“diamond”.
** Functions of DBMS **
There are several functions that a DBMS performs to ensure data integrity and
consistency of data in the database.
1. Data Dictionary Management: Data Dictionary is where the DBMS stores definitions of
the data elements and their relationships (metadata). The DBMS uses this function to look
up the required data component structures and relationships.
2. Data Storage Management: This particular function is used for the storage of data and any
related data entry forms or screen definitions, report definitions, data validation rules,
procedural code, and structures that can handle video and picture formats. Users do not need
to know how data is stored or manipulated.
3. Data Transformation and Presentation: This function exists to transform any data entered
into required data structures. By using the data transformation and presentation function the
DBMS can determine the difference between logical and physical data formats.
4. Security Management: This is one of the most important functions in the DBMS. Security
management sets rules that determine specific users that are allowed to access the database.
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 16
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
Users are given a username and password or sometimes through biometric authentication
(such as a fingerprint or retina scan) but these types of authentication tend to be more costly.
This function also sets restraints on what specific data any user can see or manage.
5. Multiuser Access Control: Data integrity and data consistency are the basis of this
function. Multiuser access control is a very useful tool in a DBMS, it enables multiple users
to access the database simultaneously without affecting the integrity of the database.
6. Backup and Recovery Management: Backup and recovery is brought to mind whenever
there is potential outside threats to a database. For example if there is a power outage,
recovery management is how long it takes to recover the database after the outage. Backup
management refers to the data safety and integrity; for example backing up all your mp3
files on a disk.
7. Data Integrity Management: The DBMS enforces these rules to reduce things such as data
redundancy, which is when data is stored in more than one place unnecessarily, and
maximizing data consistency, making sure database is returning correct/same answer each
time for same question asked.
8. Database Access Languages and Application Programming Interfaces: A query
language is a nonprocedural language. An example of this is SQL (structured query
language). SQL is the most common query language supported by the majority of DBMS
vendors. The use of this language makes it easy for user to specify what they want done
without the headache of explaining how to specifically do it.
9. Database Communication Interfaces: This refers to how a DBMS can accept different end
user requests through different network environments. An example of this can be easily
related to the internet. A DBMS can provide access to the database using the Internet
through Web Browsers (Mozilla Firefox, Internet Explorer, and Netscape).
10. Transaction Management: This refers to how a DBMS must supply a method that will
guarantee that all the updates in a given transaction are made or not made. All transactions
must follow what is called the ACID properties.
A – Atomicity: states a transaction is an indivisible unit that is either performed as a whole and
not by its parts, or not performed at all.
C – Consistency: A transaction must alter the database from one constant state to another
constant state.
I – Isolation: Transactions must be executed independently of one another. Part of a transaction
in progress should not be able to be seen by another transaction.
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 17
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
D – Durability: A successfully completed transaction is recorded permanently in the database
and must not be lost due to failures.
** Components of DBMS **
Database system refers to the set of components that define and control the collection,
storage, management and use of data. The general database system architecture is shown below.
Database system refers to the set of components that define and control the collection, storage,
management and use of data. The general database system architecture is shown below.
Software
P
E
O
Application DBMS
P
Programs
L
E
Database
(DATA)
Hardware
The 4 components of a database system are:
1. Hardware
2. Software
3. People
4. Data
Hardware: The hardware is set if physical devices on which a database resides. It consists of
one or more computers, disk drives, CRT terminals, printers connecting cables and other
devices. Hard disks are the main storage mechanism for database and are essential since they
allow random access.
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 18
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
Software: To make the database system work properly, two types of software are needed. i)
DBMS software ii) application programs (operating system)
DBMS software: It manages the database within the database system. Some example of DBMS
software includes Oracle, Access, MySQL and etc.
Application programs: These are used to access and manipulate data in the DBMS and to
manage the computer environment. Most of the application programs provide GUI (graphical
user interface).
People: This component includes all users of database system. According to the job nature, two
main types of users identified: they are,
i) Practitioners: system administrators, database administrators, database designers,
system analysts and programmers.
ii) Users: clerks, management, supervisors.
Data: Data refers to the collection of raw facts stored in the database. Because data are the raw
material, from which information is generated. No database system can exist without data.
Relationship between four components: Practitioners consult with the users to identity data
needs and design database structures as per the needs. The database structures are designed
using DBMS. Users enter the data into a system by specified procedures.
The entered data maintained in hardware media such as disks. Application Allow users to
access the database.
** Relational Model **
Relational model stores data in the form of tables. This concept purposed by Dr. E.F.
Codd, a researcher of IBM in the year 1960s. The relational model consists of three major
components:
1. The set of relations and set of domains that defines the way data can be represented (data
structure).
2. Integrity rules that define the procedure to protect the data (data integrity).
3. The operations that can be performed on data (data manipulation).
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 19
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
A rational model database is defined as a database that allows you to group its data items
into one or more independent tables that can be related to one another by using fields common
to each related table.
Characteristics of Relational Database: Relational database systems have the following
characteristics:
The whole data is conceptually represented as an orderly arrangement of data into rows
and columns, called a relation or table.
All values are scalar. That is, at any given row/column position in the relation there is one
and only one value.
All operations are performed on an entire relation and result is an entire relation, a
concept known as closure.
Basic Terminology used in Relational Model:
Table (or) Relation -- In relational data model, relations are saved in the format of Tables. This
format stores the relation among entities. A table has rows and columns, where rows represent
records and columns represent the attributes.
Tuple − Each row of data is a tuple. Actually, each row is an n-tuple, but the "n-" is usually dropped.
Relation instance − A finite set of tuples in the relational database system represents relation
instance. Relation instances do not have duplicate tuples.
Relation schema − A relation schema describes the relation name (table name), attributes, and
their names.
Relation key − each row has one or more attributes, known as relation key, which can identify
the row in the relation (table) uniquely.
Attribute domain − every attribute has some pre-defined value scope, known as attribute
domain.
The figure shows a relation with the formal names of the basic components marked the
entire structure is, as we have said, a relation.
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 20
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
** Database (Integrity) Constraints **
Database constraints are restrictions on the contents of the database or on database
operations.
Need of Constraints: Constraints in the database provide a way to guarantee that:
The values of individual columns are valid.
In a table, rows have valid primary key or unique key values.
In a dependent table, rows have valid foreign key values that reference rows in a parent
table.
Different Types of constraints:
1. Domain Constraints
2. Key Constraints
3. Integrity Rule/ Constraint 1 (Entity Integrity Rule or Constraint)
4. Integrity Rule/ Constraint 2 (Referential Integrity Rule or Constraint)
5. General Constraints
Domain Constraints: Domain Constraints specifies that what set of values an attribute can
take. Value of each attribute X must be an atomic value from the domain of X.
The data type associated with domains includes integer, character, string, date, time, currency
etc. An attribute value must be available in the corresponding domain. Consider the example
below:
Key Constraints: Keys are attributes or sets of attributes that uniquely identify an entity within
its entity set. An Entity set E can have multiple keys out of which one key will be designated as
the primary key. Primary Key must have unique and not null values in the relational table.
Example of Key Constraints in a simple relational table –
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 21
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
Integrity Rule 1 (Entity Integrity Rule or Constraint): The Integrity Rule 1 is also called
Entity Integrity Rule or Constraint. This rule states that no attribute of primary key will contain
a null value. If a relation has a null value in the primary key attribute, then uniqueness property
of the primary key cannot be maintained. Consider the example below:
Integrity Rule 2 (Referential Integrity Rule or Constraint): The integrity Rule 2 is also
called the Referential Integrity Constraints. This rule states that if a foreign key in Table 1 refers
to the Primary Key of Table 2, then every value of the Foreign Key in Table 1 must be null or
be available in Table 2. For example,
Some more Features of Foreign Key: Let the table in which the foreign key is defined is
Foreign Table or details table i.e. Table 1 in above example and the table that defines the
primary key and is referenced by the foreign key is master table or primary table i.e. Table 2 in
above example. Then the following properties must be hold:
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 22
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
Records cannot be inserted into a foreign table if corresponding records in the master
table do not exist.
Records of the master table or Primary Table cannot be deleted or updated if
corresponding records in the detail table actually exist.
General Constraints: General constraints are the arbitrary constraints that should hold in the
database. Domain Constraints, Key Constraints, Integrity Rule 1 (Entity Integrity) and 2
(Referential Integrity Constraints) are considered to be a fundamental part of the relational data
model. However, sometimes it is necessary to specify more general constraints like the CHECK
Constraints or the Range Constraints etc.
Check constraints can ensure that only specific values are allowed in certain column.
For example, if there is a need to allow only three values for the color like ‘Bakers Chocolate’,
‘Glistening Grey’ and ‘Superior White’, then we can apply the check constraint. All other
values like ‘GREEN’ etc would yield an error.
Range Constraints is implemented by BETWEEN and NOT BETWEEN. For example,
if it is a requirement that student ages be within 16 to 35, then we can apply the range
constraints for it.
The below example will explain Check Constraint and Range Constraint –
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 23
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
** Views **
View is a virtual table on one or more tables. The table on which a view is created is
called as a “base table”.
We can provide limitation on updating in base table through a view. If any changes made
to the base table those changes are also reflected in view.
Advantages of views:
We can provide security to the data.
We can provide limitation on data.
We can provide customized view for the data.
View uses little storage area.
It allows different users to view the same data in different ways at the same time.
It does not allow direct access to the tables of the data dictionary.
Disadvantages of views:
It can’t be indexed.
Takes time for creating view each time.
When table is dropped view becomes inactive.
View is a database object, so it occupies the space.
Without table, view will not work.
Updation is possible for simple view but not for complex views, they are read only type
of views.
Syntax: Create view <view-name> as select columns from <table-name> [WHERE condition];
Example: Create view as select * from EMP where job=’clerk’;
Above example creates view “v1”, it contains the records of all clerk only.
** Relational Algebra **
Relational model supports eight relational operators: SELECT, PROJECT, JOIN,
INTERSECT, UNION, DIFFERENCE (MINUS), PRODUCT AND DIVIDE. The use of
relational operators on existing tables produces new relations. In this
Unary operators are: SELECT, PROJECT
Set operators are: UNION, INTERSECT, PRODUCT AND MINUS
Join operators are: EQUI JOIN, NON EQUI JOIN AND OUTER JOIN
Division operator is: DIVIDE
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 24
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
SELECT: SELECT also known as RESTRICT, yields values for all the rows found in a table
that satisfy given condition. In other words, SELECT yields a horizontal subset of a table.
EMP: Result
eno ename job Select *from emp where
eno ename job
123 Ricky Manager
124 Rajesh Clerk Job=’CLERK’; 124 Rajesh Clerk
125 Amar Clerk 125 Amar Clerk
gives
126 Kiran Accountant
PROJECT: Yields all values for selected attributes. In other words, PROJECT yields a vertical
subset of a table.
EMP:
eno ename job Select ename, job from emp;
123 Ricky Manager ename job
124 Rajesh Clerk Ricky Manager
125 Amar Clerk gives
Rajesh Clerk
126 Kiran Accountant Amar Clerk
Kiran Accountant
UNION: combines all rows from two tables, excluding duplicate rows. The tables must have
the same attribute characteristics (data types should match).
T1 T2 Result
sname sname sname
Ramu Kiran gives Ramu
RajuUnion Ramu Raju
Kiran srinu Kiran
Srinu
INTERSECT: Yields only the rows that appear in both tables’ i.e common rows.
T1 T2 Result
sname sname
Ramu Kiran sname
Raju INTERSECT Ramu gives Kiran
Kiran srinu Ramu
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 25
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
DIFFERENCE (MINUS): Yields all rows in one table that are not found in the other table,
that is, it subtracts one table from the other. However a difference B is not same as B
DIFFERENCE A.
T1 T2 Result
sname sname sname
Ramu Kiran gives
MINUS Raju
Raju Ramu
Kiran srinu
PRODUCT: Yields all possible pairs of rows from two tables-also known as the Cartesian
product. Therefore, if one table has 3 rows and the other table has 2 rows, the product Yields a
list composed of 3*2=6 rows.
T1 T2 Result
sname cname sname cname
Ramu C gives
Union Ramu C
Raju C++ Ramu C++
Kiran
Raju C
Raju C++
Kiran C
Kiran C++
JOIN: allows information to be combined from two or more tables. JOIN allows the use of
independent tables linked by common attributes. A natural join links tables by selecting only
the rows with common values in their common attributes.
STD COURSE
rno name cid cid cname
33 Ram 10 10 C
44 Kiran 30 JOIN 30 Oracle
55 Amar 80
QUERY: SELECT RNO, NAME, [Link], CNAME FROM STD,COURSE WHERE
[Link]=[Link];
rno name cid cname
33 Ram 10 C
44 Kiran 30 Oracle
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 26
[Link] | [Link] | [Link]
[Link] | [Link] | [Link]
Database Management System [Link](Computer Science)-II Year(IV Semester)
Types of Joins:
Equi-join links tables based on an equality condition that compares specified columns of
each table. The outcome of the equi-join does not eliminate duplicate columns.
Theta Join is a non-equi-join that compares specified columns of each table using a
comparison operator other than the “equals to” operator.
Outer join: In an outer Join the unmatched pairs would be retained and the values for the
unmatched other tables would be left blank or null.
DIVIDE: uses one single column table say A as the divisor and one 2-column table say B as the
dividend. The tables must have a common column. The output of the divide operation is a
single column with the values of column from the dividend table (B) rows where the value of
the common column in both tables match.
T1 T2 Result
c1 c2 c1 c2
A 5 A gives
DIVIDE 5
A 9 B 9
B 5
B 9
Aggregate (Group) functions (Operations): These functions are used to operate on a group of
values. They aggregate the group to perform calculations such as finding out sum, max, min
values and etc.
SUM: finds sum of the values of a column.
Ex: SELECT SUM(SAL) FROM EMP;
AVG: finds average of the values of a column.
Ex: SELECT AVG (SAL) FROM EMP;
MAX: finds maximum of the values of a column.
Ex: SELECT MAX (SAL) FROM EMP WHERE JOB=’MANAGER’;
MIN: finds minimum of the values of a column.
Ex: SELECT MIN (SAL) FROM EMP;
COUNT: finds number of records.
Ex: SELECT COUNT (*) FROM EMP;
Prepared by G. Veerachary MCA, AP-SET, UGC-NET Page 27
[Link] | [Link] | [Link]