3rd SEM DBMS
3rd SEM DBMS
3
[Q]. Explain the Functions of Database Management System?
FUNCTIONS (OR) OBJECTIVES (OR) SERVICES OF DBMS:
Database Management System: A Database management system (DBMS) is a collection of
programs that allows users to create and maintain a database. It acts as an intermediator
between user and database.
A DBMS performs several functions that provide the integrity and consistency of data in
the database. DBMS performs following important functions within the database.
Data Dictionary Management :
o The DBMS maintains the definition of data elements in a data dictionary. If any
changes in database is automatically recorded in the data dictionary.
Data storage Management :
o DBMS creates the structure for database in the physical storage devices. It
provides amechanism for permanent storage of data.
Data Definition Management :
o The DBMS creates the structure of data to store in which the data is stored.
Data Manipulation Management :
o The DBMS provides ability to add new data into the database (or) retrieve,
update anddelete existing data in the database.
Authorization :
o The DBMS protects the database against unauthorized access either intentional (or)
accidental.
Backup and recovery :
o The DBMS provides a mechanism for Backup data and recovery from different types
of failures.
Concurrency control :
o The DBMS supports sharing of data among multiple users. The DBMS provides a
mechanismfor concurrent access to the database.
Transaction Management :
o The transaction management provides access or change the content of database.
Integrity Service :
o The DBMS provides integrity rules to minimize data redundancy and maximize the
dataconsistency.
4
[Q]. Define DBMS. Explain the Classifications (Types) of DBMS?
Database Management System:
A Database management system (DBMS) is a collection of programs that allows users to
create and maintain a database. It acts as an intermediator between user and database.
The DBMS classified into different categories based on data models, no. of users
and the purpose.
Based on data models:
Depending on the data models, the DBMS classified into three categories - hierarchical,
network and relational DBMS.
Hierarchical DBMS :
o Organizes the data records in a tree structure i.e Hierarchy of parent and
child relationship.
o In a hierarchical data – base, a parent record may have more than one child, but a
child always has only one parent. This is called „one – to- many relationship‟.
Network DBMS :
o Organizes the data records liked to one another through pointers, which is an
association between two records.
o A network database is similar to a hierarchical database except that each child
can have more than one parent record. This is called “many- to – many
relationship‟.
A relational DBMS :
o Organizes the data records in the form of table and relationship among the tables
are set using fields.
o It is simple in nature because data is simply represented in tabular format.
Based on no. of Users:
Depending on no. of users the DBMS is divided into two categories – single-user system
and multi-user system.
Single - User System :
o In single user system, database resides on one computer and is only accessed by
one user at a time. The user may design, maintain, and write programs for
accessing and manipulating the database according to the requirements.
Multi – User System :
o In multi – user system, multiple users can access the database simultaneously. In
multiuser DBMS, the data is both integrated and shared.
o For example, the online book database is a multi-user database system in which the
data of books, authors, and publishers are stored centrally and can be accessed by
many users.
Based on the purpose :
Depending on the purpose, the DBMS classified into two categories – general purpose
DBMS and special purpose DBMS.
DBMS is a general purpose software system. It can however, be designed for specific
purposes such as airline or railway reservation. Such systems cannot be used for other
applications.
These database systems fall under the category of online transaction processing (OLTP)
systems. Online transaction processing systems is specially used for data entry and
retrieval. It supports large number of concurrent transactions without excessive
delays.
5
An automatic Teller Machine for a bank is an example of online commercial transaction
processing application. The OLTP technology is used in various industries, such as
banking, airlines, supermarkets, manufacturing etc.
[Q]. Write a brief note on Evolution of Database Management System?
EVOLUTION OF DBMS :
At the time of computers there was no data processing on those days. Computers are
only used for engineering and scientific calculations. Gradually computers were
introduced into the business world. For business applications computers must able to
store and manipulate large amount of data.
For this purpose introduce a new concept called file processing system. But file
processing system has number of limitations is there. To overcome the limitations one
more new system introduced called Database management System.
DBMS were first introduced during the 1960s and have continued to evolve during
subsequent decades. The database management system supports different types of
database technologies or architectures or models.
The Evolution (order of development of DBMS) of Database systems is as follows…
Flat files (1960 -1980)
Hierarchical (1970 -1990)
Network (1970 -1990)
Relational (1980 - present)
Object oriented (1990 - present)
Object relational (1990 - present)
Web enabled (1990 - present)
Flat files (1960-1980) :
o In Flat file database system, data is stored in a single file or table. A flat file can be a
plaintext file or a binary file. In a flat file database, there is no relationship between the
records.
o Example:
SNO SNAME GROUP
Record 1 1 A BCOM
Record 2 2 B BSC
6
Relational (1980-present) DBMS :
o In a Relational DBMS, data is stored in the form
of tables. Table contains primary keys and
alternative keys. In a table, each row represents
a Record and each column represents an
attribute. A Relational database model is
proposed by E.F.Codd in 1970.
o Examples: Oracle, SQL Server, MySQL etc.
Object oriented Database (1990-present) :
o In Object oriented database system, data or information is stored in the form of objects
as used in OOP language like C++ or JAVA.
Object relational database (1990-present) :
o Object relational DBMS is a combination of both Relational Database (RDBMS) and
Object- oriented database (OODBMS). It supports basic components of any OODBMS in
its schema and the query language used like objects, classes and inheritance.
[Q]. What is File-Based System? Explain the Drawbacks of File-Based System?
File-based System:
A file based system is a method of storing and organizing the computer filesand data that
make easy to find and access it.
Characteristics:
o It is a group of files for storing data of an organization.
o Each file is independent from one another.
o Each file is called a flat file.
o Files are designed by using programming languages like C,C++ etc.
Drawbacks of File based System:
The following are the drawbacks of file based system like….
Data Redundancy (Duplication of Data) :
o Data Redundancy means duplication of data values, i.e. same information is
duplicated in several files. The file system data management forces the storage of
same basic data in different locations. Duplication is wasteful because it costs time
and money and also takes additional storage space.
Data Inconsistency :
o Data Inconsistency exists when different copies of same data appear in different
places. The data in a file can become inconsistent when more than one person
modifies the data. Entering wrong data is also another reason for inconsistency
Data Security :
o In file based system, the security of data is very low because the data is maintained
in a flat file and it is easy to access.
Data Isolation :
o When the data is stored in separate files it becomes difficult to access. It becomes
more complicated when the data has to be retrieved from more than one file
Difficulty of getting quick answers (Queries) :
o In file based system obtaining answers (results) for new requirements (queries)
takes more time to obtain results.
7
Lack of Backup and recovery :
o In file based system there is no facility for backup and recovery from system failure.
Limited data sharing :
o In file based system, the data is stored in a decentralized manner, hence sharing of
the data is complex.
Unable to represent relationships among data :
o In file based system there is no facility to represent relationship among data in
different file for a single system.
Transactional problems :
o The file based system does not satisfy transactional problems (which are called as
ACID properties (A- Atomic, C - Consistency, I - Integrity, D- Durability).
Concurrency problems :
o When multiple users update same data at a time then it may results in a problem. In
filebased system, it is very difficult to handle this problem.
o Example of File-based System: Consider the example of a Hospital System.
8
Controlled Redundancy of data :
o The database approach is a centralized place to save data. Hence, the amount of data
redundancy is minimized. Data redundancy (or duplication) is minimized by
applying normalization process in database design.
Getting quick answers (Queries) for complex queries :
o DBMS makes possible to produce quick answers to the queries by changing SQL
queries in programs.
Improved Data Sharing :
o In database approach, data is shared by different applications or users
simultaneously. In DBMS, multiple users will access same data and can do changes.
Relationships among data :
o We can apply relationships among data to improve performance of applications and
consistency (or correctness) of data.
Efficient data access :
o DBMS uses techniques to store and retrieve the data efficiently.
Improved security :
o Data is important to any organization and also confidential. When multiple users
access to the data, securing data is more critical. Hence database is protected from
un-authorized users.
o DBMS provides facilities for data security and privacy policies. This can be done by
database administrator (DBA) by providing usernames and passwords only to the
authorized users.
Improved integrity :
o The DBMS promotes and enforces integrity rules, thus minimizing data redundancy
and maximizing data consistence. Data integrity refers to validity and consistency of
data. This is done by applying some conditions.
Improved backup and recovery :
o In DBMS, if a transaction fails in middle of its execution due to system failure then
DBMSwill recovers the data into its original position.
DIS-ADVANGES OF DBMS :
Increased complexity :
9
Increased installation and maintenance cost :
o The DBMS software has a high initial cost. It requires trained person to install,
operateand maintenance and also has more annual maintenance.
Conversion cost :
o The conversion cost from old database technology to modern database environment
is high.
[Q]. Write the Applications of Data Bases?
APPLICATIONS OF DATA BASES :
Some of The applications of database are…
Hierarchical Model :
o The Hierarchical Data Model is the
oldest type of data model, developed
by IBM in1968.
o In Hierarchical database model, data is
organized in tree-like-structure with
one one-to-many relationship.
o A tree structure contains root node
(or) parent node and the child nodes linked to theparent nodes.
o In this model, each child can have only one parent node and a parent node have
anynumber of child nodes.
o For example, one department can have many courses, many professors and many
students.
10
Network Model :
o In Network model, data is organized by collection of records, and a relationship
among data is represented by links like a graph structure with many-to-many
relationship.
o In this, record types are represents are represented by Boxes, links are represented
bylines.
o For Example:
Relational Model :
o In Relational model, the data is organized in the form of tables.
o In relational model, tables are also
known as relations. Each row
represents a tuple,
o each column represents an attribute.
o The Relational data model is
implemented through a Relational
Database Management System
(RDBMS).Relational model was
introduced by E.F Codd in 1970.
o For Example:
Entity-relationship Model (E.R Model)
o Entity Relationship Model is the graphical representation of entities and their
relationship in a database.
o E.R. models are represented in an Entity relationship diagram (ER Diagram).The
EntityRelation data model is introduced by Peter Chen in 1976.
o The ER - Model contains following components:
o Entity: entities are the real time objects.
Entities represented by a rectangle.
Ex: Student, Employee
o Attribute: Attributes are the characteristics of
entities.
Ex: sno, sname, group, Empno, Empname,
Empaddress
o Relationships: A relationship describes
association between the entities.
For Example:
11
[Q]. Explain the Components of Database System?
COMPONENTS OF DATABASE SYSTEM:
The database management system can be divided into five major components, they are:
Hardware
Software
Data
Procedures
Database Access Language
Users
Software:
o Software is the set of programs used to
control and manage the overall database.
o It contains the DBMS software itself, the
Operating System, the network software
being used to share the data among users,
and the application programs used to access
data in the DBMS.
Hardware:
o Hardware contains a set of physical electronic devices such as computers, I/O
devices, storage devices, etc., this provides the interface between computers and the
real world systems.
Data:
o DBMS exists to collect, store, process and access data, the most important
component. The database contains both the actual or operational data and the
metadata.
Procedures:
o Procedures refer to general instructions to use a database management system. This
contains procedures to setup and install a DBMS, To login and logout of DBMS
software, to manage databases, to take backups, generating reports etc.
Database Access Language:
o Database Access Language is a simple language designed to write commands to
access,insert, update and delete data stored in any database.
o A user can write commands in the Database Access Language and submit it to the
DBMS forexecution, which is then translated and executed by the DBMS.
o User can create new databases, tables, insert data, fetch stored data, update
data anddelete the data using the access language.
Users (People):
o Database Administrators: Database Administrator or DBA is the one who manages
the complete database management system. DBA takes care of the security of the
DBMS.
o Application Programmer or Software Developer: This user group is involved in
developing and designing the parts of DBMS.
o End User: End users are the users who store, retrieve, update and delete data.
12
[Q]. Explain the Components of Database Environment in detail?
13
End users:-Persons throughout the organizations who manipulated data in the
database andwho requests and receive information from the database.
[Q]. Explain about Database Architecture? And also explain the types of Database Architecture?
DATABASE ARCHITECTURE:
Database architecture essentially describes the location of all the pieces of information
that make up the database application.
The database architecture can be broadly classified into two-, three-, and multi-tier
architecture.
Two-Tier Architecture:
o The two-tier architecture is a client–
server architecture in which the client
contains the presentation code and the
SQL statements for data access. The
database server processes the SQL
statements and sends query results back
to the client.
o Two-tier client/server provides a basic
separation of tasks. The client, or first
tier, is primarily responsible for the
presentation of data to the user and the
“server,” or second tier, is primarily responsible for supplying data services to the client.
o Presentation Services:
“Presentation services” presents data to the user. In addition, it also provides for the
mechanisms in which the user will interact with the data. More simply, presentation
logic defines and interacts with the user interface.
o Business Services/objects:
“Business services” are a category of application services. Business services
encapsulate an organizations business processes and requirements. These rules are
derived from the steps necessary to carry out day-today business in an organization.
These rules can be validation rules, used to be sure that the incoming information is
of a valid type and format, or they can be process rules, which ensure that the proper
business process is followed in order to complete an operation.
o Application Services:
“Application services” provide other functions necessary for the application.
o Data Services:
“Data services” provide access to data independent of their location. The data can
come from legacy mainframe, SQL RDBMS, or proprietary data access systems. Once
again, the data services provide a standard interface for accessing data.
14
Drawbacks of Two-tier Architecture :
Software maintenance can be difficult because PC clients contain a mixture of
presentation, validation, and business logic code.
To make a significant change in the business logic, code must be modified on many PC
clients.
Performance of two-tier architecture can be poor when a large number of clients submit
requests because the database server may be overwhelmed with managing messages.
Three-Schema (tier) Architecture :
The three schema architecture is also called ANSI/SPARC (American National Standard
Institute/Standards planning and requirements committee) architecture or three-level
architecture.
This framework is used to describe the structure of a specific database system.
The three schema architecture is also used to separate the user applications and
physical database.
A “Multitier,” often referred to as “three-tier” or “N-tier,” architecture provides greater
application scalability, lower maintenance, and increased reuse of components.
Three-tier architecture offers a technology neutral method of building client/server
applications with vendors who employ standard interfaces which provide services for
each logical “tier.”
From this figure, it is clear that in
order to improve the performance;
a second-tier is included between
the client and the server. Through
standard tiered interfaces, services
are made available to the
application.
A single application can employ
many different services which may
reside on dissimilar platforms or
are developed and maintained
with different tools.
This approach allows a developer to leverage investments in existing systems while
creating new application which can utilize existing resources.
Although the three-tier architecture addresses performance degradations of the two-tier
architecture, it does not address division-of-processing concerns. The PC clients and the
database server still contain the same division of code although the tasks of the database
server are reduced.
Multiple-tier architectures provide more flexibility on division of processing.
The three schema architecture contains three-levels. It breaks the database down into
three different categories.
The 3-level of architecture are…
Internal level :
o The internal schema defines the internal level. The internal level is the lowest
level of data abstraction. This level indicates how the data will be stored into
15
the database and describes the file structures, data structures and methods
used by the data base.
Conceptual level
o The conceptual schema defines the conceptual level. The conceptual level is the
middle level abstraction. This level indicates entities, attributes, relationship
between entities and attributes.
External level
o External schema defines the external level. The external level is the highest
level of data abstraction. This level describes part of database, i.e. relevant to
the user.
16
[Q]. Explain the Database vendors and their Products?
Database Vendors:
A database vendor is an entity that offers one or more databases to customers for license
or sale. 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.
Some DBMS examples include MySQL, PostgreSQL, Microsoft Access, SQL Server,
FileMaker, Oracle, RDBMS, dBASE, Clipper, and FoxPro.
The systems are listed by type: relational(R), extended-relational(X), object relational
(OR),object-oriented (OO), network (N) and hierarchical (H).
[Q]. Explain the various cost and risk factors involved in implementing a database system?
Cost and Risk factors involved in implementing a Database System:
The database approach causes some additional costs and risks that must be recognized
and managed when implementing this approach.
In database approach in order to maintain or develop database we should take a risk
and we should invest money, time and environment.
Database approach when we develop a new database or when we maintain an existing
database we should consider the following points.
The various cost and risk factors involved in implementing a database system are:
High cost:
o Installing a new database system may require investment in hardware and
software. The DBMS requires more main memory and disk storage.
o Moreover, DBMS is quite expensive. Therefore, a company needs to consider the
overhead cost of implementing a new database system.
Training new personnel:
o When an organization plans to adopt a database system, it may need to recruit or
hire a specialized data administration group, which can coordinate with different
user-groups for designing views, establishing recovery procedures and fine
tuning the data structures to meet the requirements of the organization. Hiring
such professionals is expensive.
17
Explicit backup and recovery:
o A shared corporate database must be accurate and available at all times.
Therefore, a system using on-line updating requires explicit backupand recovery
procedures.
System failure:
o When a computer system containing the database fails, all users have towait until
the system is functional again.
o Moreover, if DBMS or the application program fails, a permanent damage may
occur to the database.
New, Specialized Personnel:
o Frequently, organizations that adopt the database approach need to hire or train
individuals to design and implement databases.
o This personnel increase seems to be expensive, but an organization should not
minimize the need for these specialized skills.
Installation and Management Cost and Complexity:
o A multi-user database management system is large and complex software that
has a high initial cost. It requires trained personnel to install and operate, and
also has annual maintenance costs.
o Installing such a system may also require upgrades to the hardware and data
communications systems in the organization.
Conversion Costs:
o The term “legacy systems” is used to refer to older applications in an
organization that are based on file processing. The cost of converting these older
systems to modern database technology may seem prohibitive to an organization.
Need for Explicit Backup and Recovery:
o A shared database must be accurate and available at all times. This raises the
need to have backup copies of data for restoring a database when damage occurs.
A modern database management system normally automates recovery tasks.
Organizational Conflict:
o A database requires an agreement on data definitions and ownership as well as
responsibilities for accurate data maintenance.
o The conflicts on data definitions, data formats and coding causes updating of
shared data. Handling these issues requires organizational commitment to the
database approach.
18
UNIT II (ENTITY-RELATIONSHIP MODEL)
[Q]. Write about Entity Relationship Model? And its Advantages and Dis-advantages?
Example:
In the ER diagram, STUDENT and CLASS are two entities.
– The STUDENT having two attributes like Roll number and the name.
– The CLASS having two attributes like Subject Name and Hall Number. And the
relationship between the two entities is Attends.
19
Features of ER Model:
ER diagram is used to represent ER model and easily converted into relations (tables)
ER model is used for the purpose of good database design
It is very simple and easy to understand
It is a top-down approach to database design
Advantages of ER Model:
o Conceptual simplicity: ER model represents the concepts of database along with
entities and relationships. So it is easy to create and manage complex database designs.
o Visual Representation: ER model provides a visual representation of data and
relationships among data. It is easy to understand the structure of data.
o Effective communication tool: The database designer uses ER model to get different
views of data.
o The ER modeling provides an easily understood pictorial map for the database design.
o It is possible to represent the real world problems in a better manner in ER modeling.
o The conversion of ER model to relational model is straightforward.
o The enhanced ER model provides more flexibility in modeling real world problems.
o The symbols used to represent entity and relationships between entities are simple
andeasy to follow.
Disadvantages of ER Model:
o ER model represents limited no. of relationships among entities.
o There is no industry standard notation for developing an ER diagram.
o It is popular for high level database design.
[Q]. Explain the basic building blocks of ER- Diagram with an example?
BASIC BUILDING BLOCKS OF AN ER – DIAGRAM:
Entity Relationship Model (ER Model) is a high-level conceptual data model developed
by Peter Chen in 1976 that helps in designing database.
It describes the structure of a database with the help of diagrams called as Entity
Relationship Diagram. ER diagram contains set of objects called “entities” and
relationships between entities.
The basic building blocks (or components) of Entity-Relationship diagram are…
Entity
Attribute
Relationship.
ENTITY:
o An Entity is a real world object like person, place or thing. Any living and non-living
objects are also called as Entity.
o An entity is represented by rectangle along with entity name. The entity names are
generally written in capital letters.
o Example: STUDENT, CUSTOMER, EMPLOYEE and PRODUCT etc.
20
ATTRIBUTES:
o An Attribute is used represents characteristics or properties of entities or entity
types. An attribute is represented by “Ovals” and are connected to the entity with a
line. Each oval contains name of the Attribute.
o Example: STU_NAME, STU_ADDRESS, ROLL_NO are the attributes of STUDENT.
RELATIONSHIP:
o An association between one or more entities is called “relationship”. There are
three different types of relationships.
One-One relationship
One-Many relationship
Many-Many relationship
o Example:
– Teaches is the relationship type between LECTURER and STUDENT.
– Treatment is the relationship between DOCTOR and PATIENT.
[Q]. What is Entity? Explain different types of entities (or) write aboutclassification of Entity Sets?
ENTITY SET:
An Entity set is a collection of entities that share same attributes. (or) An entity set is a
collection of similar type of entities.
Entity sets are classified into following types:
Strong entity
Weak entity
Associative entity
Strong Entity:
o Strong entity is an entity type whose existence does not depend on other entity. An
entity that has an attribute that acts as a primary key is called Strong Entity. In ER
diagram, strong entity is represented by “single outlined box”.
o Example: Student takes course
Weak Entity:
o Weak entity is an entity whose existence depends on other entity. An entity that does
not has an attribute that acts as a primary key is called Weak Entity. In ER diagram,
weak entity is represented by “double outlined box”.
o Example: each Customer has Address
21
Example:
[Q]. What is Attribute? Explain different types of Attributes (or) write about classification of
Attributes ?
ATTRIBUTE:
An Attribute is used represents characteristics or properties of entities or entity types.
Attributeis classified based on value and structure.
o A Single valued Attribute is an attribute that contains only one value. In ER diagram,
thesingle value attribute is represented by “ellipse”.
o Example: in EMPLOYEE entity, Employee Name, Employee Age
Multivalued Attribute:
22
o
Derived Attribute :
o It is an attribute that’s value is derived from the other attributes or entities then
it is called as derived attribute. In ER diagram, the derived attribute is
represented by “dotted ellipse”.
o Examples: In this example, age is the derived attribute. Because, age is derived
from the date ofbirth of the person.
Simple Attribute:
o A Single Attribute is an attribute that cannot be sub divided.
o Example: in this example, streetNo, city, state, pincode
Composite Attribute:
o A Composite attribute is an attribute which is further subdivided into simple
attributes.
o Example: the “address” attribute is subdivided into Streetname, City, and State etc.
[Q]. Explain about different types of Relationship (or) Explain about classification of
relationship ?
RELATIONSHIP:
An association between one or more entities is called as “Relationship”. The relationship
is classified into one-to-one relation, one-to-many relation, many-to-many relation and
many-to-one relation.
Based on the cardinality of relationships they are classified into the following categories…
23
One – to – many relationship (1:M)
Many- to –many relationship (M:M)
One – to – one relationship (1:1)
One-to-One Relationship Type:
o The relationship that associates exactly one entity to one entity is called one-
to-onerelationship.
o Example 1: President and the country For a particular country there is only one
President. And a country willnot have more than one President.
PRESIDENT COUNTRY
HOUSE LOCATION
o Example 3: PERSON and PASSPORT . A person has exactly only one passport
COUNTRY STATES
Student Colleges
24
EMPLOYEE DEPT
[Q]. What is Relationship Degree? Explain about different types of relationship degree?
Relationship Degree :
The association between one or more entities is called as “Relationship”. The no. of
entities associated with the relationship is called as “degree of relationship”.
The relationship degree is classified into 3 types…
Unary relationship
Binary relationship
Ternary relationship
Quaternary Relationships
Unary Relationship :
o When there is only one entity set is participating in a relation, the relationship is called
as Unaryrelationship.
o Example: one person is married to only one person
Example:
Binary Relationship :
o When there are two entity sets participating in a relation, the relationship is called as
Binaryrelationship.
o Example: Professor and Class. The relationship a PROFESSOR TEACHES ONE or MORE
CLASS.
Teaches
PROFESSOR CLASS
Ternary Relationship :
o When there three entity sets participating in a relation, the relationship is called as
Ternaryrelationship.
o Example: A doctor writes one or more prescriptions.
A patient may receive one or more prescriptions. A drug may appear one or more
prescriptions.
25
Quaternary Relationships:
o When there four entity sets participating in a relation, the relationship is called as
Quaternaryrelationship.
o Example: “A professor teaches a course to students using slides.” PROFESSOR,
SLIDES, COURSE, andSTUDENT are four entities.
Example
o A strong entity set with any number of composite attributes will require only one
tablein relational model.
o While conversion, simple attributes of the composite attributes are taken into
accountand not the composite attribute itself.
26
Rule-03: For Strong Entity Set With Multi Valued Attributes:
o A strong entity set with any number of multi valued attributes will require two
tables inrelational model.
o One table will contain all the simple attributes with the primary key.
o Other table will contain the primary key and all the multi valued attributes.
27
NOTE-
If we consider the overall ER diagram, three tables will be required in relational model-
– One table for the entity set “Employee”
– One table for the entity set “Department”
– One table for the relationship set “Works in”
28
Rule-06: For Binary Relationship With Both Cardinality Constraints and Participation
Constraints:
o Cardinality constraints will be implemented as discussed in Rule-05.
o Because of the total participation constraint, foreign key acquires NOT NULL constraint
i.e. now foreign key cannot be null.
Case-01: For Binary Relationship With Cardinality Constraint and Total Participation
Constraint From One Side:
29
o Because cardinality ratio = 1 : n , so we will combine the entity set B and
relationship set R.Then, two tables will be required-
1. A ( a1 , a2 )
2. BR ( a1 , b1 , b2 )
o Because of total participation, foreign key a1 has acquired NOT NULL constraint, so it
can’t benull now.
Case-02: For Binary Relationship With Cardinality Constraint and Total Participation
Constraint From Both Sides:
o If there is a key constraint from both the sides of an entity set with total participation,
then that binary relationship is represented using only single table.
o ARB ( a1 , a2 , b1 , b2 )
o Weak entity set always appears in association with identifying relationship with
totalparticipation constraint.
o Here, two tables will be required-
1. A ( a1 , a2 )
2. BR ( a1 , b1 , b2 )
[Q]. What is Enhanced Entity–Relationship Model (EER MODEL) (or) Explain about Basic concepts
of EER – Model?
Enhanced Entity–Relationship Model:
The basic concepts of ER modelling are not powerful for some complex applications.
Hence some additional modeling concepts are required. These are provided by
Enhanced ER model.
The Enhanced ER model is the extension of the ER model with new modeling constructs
like super type (super class)/subtype (subclass) relationships.
30
Super type (or) Super class :
o Super type (or) super class is an entity type that has a relationship with one or more
subtypes.
o For example: PLAYER is an entity type which has a relationship with one or more
subtypes like CRICKET PLAYER, FOOTBALLPLAYER, HOCKEY PLAYER, TENNIS
PLAYER, etc.
Subtype (or) Sub class :
o A subtype or subclass is a sub grouping of the entities in an entity type. A subclass
entity type represents a subset or sub grouping of super class entity type’s instances.
o Subtypes inherit the attributes and relationships associated with their super type.
o For example: ENGINE entity type has two subtypes like PETROLENGINE and DIESEL
ENGINE. A STUDENT entity type has two subtypes UNDERGRADUATE and
POSTGRADUATE.
Generalization: (Explain about Generalization and Specialization in detail?)
o Generalization is a process in which the common attributes of more than one
entitiesform a new entity.
o In this, two or more lower level entities combine together to form a higher level
newentity. This newly formed entity is called generalized entity.
o The new generalized entity can further combine together with lower level entity
tocreate a further higher level generalized entity.
o Generalization is a bottom-up process.
o In EER diagram, generalization is represented by labeled with ISA.
o Generalization Example :
Consider Student and Teacher entities. Attributes of Entity Student are: Name, Address
& GradeAttributes of Entity Teacher are: Name, Address & Salary.
o The ER diagram before generalization looks like this:
o These two entities have two common attributes: Name and Address, we can make
ageneralized entity with these common attributes.
31
o These common attributes are now associated with a new entity Person which is in the
relationship withboth the entities (Student & Teacher).
Specialization:
o Specialization is a process in which an entity is divided into sub-entities.
o It is a reverse process of generalization, in generalization two entities combine
together to forma new higher level entity.
o Specialization is a top-down process.
o In EER diagram, generalization is represented by labeled with ISA.
o For example – Consider an entity employee which can be further classified as sub-
entities Technician, Engineer & Accountant because these sub entities have some
distinguish attributes.
o Specialization Example:
o In this diagram, higher level entity “Employee” divided in sub entities “Technician”,
“Engineer” & “Accountant”.
o Just for the example, that Technician handles service requests, Engineer works on a
project and Accountant handles the credit & debit details.
32
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
The terms commonly used by user, model, and programmers are given later.
User Model Programme
r
Row Tuple Record
Column Attribute Field
Table Relation File
33
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
In that above relation:
The degree of the relation (i.e., is the number of column in the relation) = 5. The
cardinality ofthe relation (i.e., the number of rows in the relation) = 3.
[Q]. Explain about CODD’S RULES ?
CODD’S RULES:
In 1985, Edgar Frank Codd defined 12 important relational database rules that make a
database system as relational database system.
After publishing the original article Codd stated that there are no systems that will
satisfy every rule. Any database system that follows minimum 6 Codd‟s rules is known
as RDBMS.
Rule 1: Information:
The data stored in a database, may it be user data or metadata, must be a value of
sometable cell. Everything in a database must be stored in a table format.
Rule 2: Guaranteed Access:
Every item of data must be logically addressable with the help of a table name,
primary key value and column name.
Rule 3: Systematic Treatment of NULL values:
The RDBMS must be able to support null values to represent missing or accessible
to users with appropriate authority and are stored in the data dictionary.
Rule 4: Active online catalog:
The structure description of the entire database must be stored in an online
catalog, known as data dictionary, which can be accessed by authorized users.
These are accessible to users with appropriate authority and are stored in the data
dictionary. (or)
The metadata must be stored as ordinary data in a table within the database. Such
datamust be available to authorized users.
Rule 5: Comprehensive data sub language:
The relational database supports many languages. It must support data definition,
view definition, data manipulation integrity constraints, authorizations and
transaction management.
Rule 6: View Update:
All views that are theoretically updatable must also be updatable by the RDBMS.
Rule 7: High level Insert, Update and Delete:
A database must support high-level insertion, updating, and deletion. This must not
be limited to a single row, that is, it must also support union, intersection and
minus operations to yield sets of data records.
Rule 8: Physical data independency:
The data stored in a database must be independent of the applications that access
the database.
34
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Any change in the physical structure of a database must not have any impact on
how the data is being accessed by external applications.
Rule 9: Logical data independency:
The logical data in a database must be independent of its users view (application).
Anychange in logical data must not affect the applications using it.
o For example, if two tables are merged or one is split into two different tables,
there should beno impact or change on the user application. This is one of the most
difficult rule to apply.
Rule 10: Integrity Independency:
All relational integrity constraints (like primary key, foreign key, unique, check,
default, not null) must be definable in the relational language and stored in the
system catalogs.
o (Note: - Integrity means completeness, correctness and consistency).
Rule 11: Distribution Independency:
The end-user must not be able to see that the data is distributed over various
locations. (Note: - Data independence means users should not have awareness of
whether a database isdistributed at different sites or not.)
Rule 12: Non Sub Version:
If the system supports low – level access to the data, there must not be a way to
bypassthe integrity rules of the database. This is necessary for data integrity.
The data available in the database must be complete and correct data. To maintain
correctness and completeness of data oracle has given some data integrity constraints.
Relational data base integrity rules are very important to good data base design. Many
RDBMSs enforce integrity rules automatically.
Data integrity constraints refer to the correctness, completeness and consistency of
data in the database. It is another form of protecting database.
Integrity constraints are set of rules used to maintain the quality of information. The
different types of data integrity constraints are
Domain integrity constraints
Not null
Check
Entity integrity constraints
Unique
Primary key
35
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Domain integrity constraints:
o It is used to check the validity of entries for a given column and it restricts duplicate
values into table columns.
o Not null: - It is used to restrict null values, any number of duplicate values allowed.
o Check: - It is used to provide conditional restrictions on table columns.
o Example:
36
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Key constraints:
Key constraints are used to uniquely identify fields or attributes in a relation. A
primary key cancontain only unique and null value in the relational table.
Example:
37
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Composite key:
o The key which consist multiple attributes is called as “composite” key (or) If a
primary key contains two or more attributes then that type of primary key is
called composite key.
Candidate Key:
o Candidate key is a minimal (irreducible) super key. A super key doesn’t contain a
subset of attributes that is itself is a super key.
Primary Key:
o The primary key is candidate key that uniquely identify all other attribute values
in any given row. It cannot contain null entries.
Secondary Key:
o An attribute or combination of attributes used to strictly for data retrieval purpose.
Foreign Key:
o An attribute or combination of attributes in one table whose values must either
match the primary key in another table. It is used to establish relation between
two tables.
– Used to define relationship between 2 Tables.
– It allows Null and duplicates values.
o It can be related to either Primary key or unique constraint column of other Table.
PK / UNQ < > FK
[Q]. Define Relational Algebra. And write down the advantages and Limitations?
RELATIONAL ALGEBRA:
Relational algebra is a procedural query language that works on relational model. The
purpose of a query language is to retrieve data from database or perform various
operations such as insert, update, and delete on the data.
When I say that relational algebra is a procedural query language, it means that it tells
what data to be retrieved and how to be retrieved.
On the other hand relational calculus is a non-procedural query language, which means
it tells what data to be retrieved but doesn’t tell how to retrieve it.
Advantages:
o Relational algebra is based on the set theory which is a mathematical concept due to
which it has a scope of development.
o Like mathematics there can be many expressions for the same operation, in a similar
way if there are two relational algebraic expressions for the same operation then the
query optimizer will switch to the most efficient query.
o It is a high-level query language.
Limitations:
o Relational algebra cannot perform arithmetic operations.
o It is unable to do aggregation operations even it cannot compute transitive closure.
o It cannot modify the data present in the database.
38
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
[Q]. What is Relational Algebra Operations? Explain various types of Relational Algebra
Operations?
Relational Algebra Operations :
Some operators of relational algebra are unary that is they operate only on one relation
and some operators are binary that is they operate on two relations.
SELECT, PROJECT and RENAME are the unary operators and UNION, SET DIFFERENCE,
CARTESIAN PRODUCT and JOIN are the binary operators.
The operators or the operations in relational algebra can be classified into two
categories:
Basic/Fundamental Operations:
⚫ Select (σ)
⚫ Project (Π)
⚫ Union (𝖴)
⚫ Set Difference (-)
⚫ Cartesian product (X)
Derived Operations:
⚫ Natural Join (⋈)
⚫ Left, Right, Full outer join (𝔴, ⟖, 𝔴)
⚫ Intersection (∩)
⚫ Division (÷)
Basic/Fundamental Operations:
o Select Operator is denoted by sigma (σ) and it is used to find the tuples (or rows)
in a relation(or table) which satisfy the given condition.
o Syntax of Select Operator (σ): σ Condition/Predicate (Relation/Table_name)
o Example:
σsalary>61000 (instructor)
Project Operator (Π) :
o Project operator is denoted by Π symbol and it is used to select desired columns (or
attributes)from a table (or relation).
o Syntax of Project Operator (Π): Π column_list (table_name)
o Example:
Π Customer_Name, Customer_City (CUSTOMER)
Πname, dept_name (instructor);
Union Operator (𝖴) :
o Union operator is denoted by 𝖴 symbol and it is used to select all the rows
(tuples) from twotables (relations) without duplicate values.
o Syntax of Union Operator ( ): R1 R2
o Example:
Π Student_Name (COURSE) Π Student_Name (STUDENT)
39
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Intersection Operator (∩) :
o Intersection operator is denoted by ∩ symbol and it is used to select common
rows (tuples)from two tables (relations).
o Syntax of Intersection Operator (∩): R1 ∩ R2
o Example:
Π Student_Name (COURSE) ∩ Π Student_Name (STUDENT)
JOIN:
o The JOIN operator combines rows from two or more tables. There are several types
ofjoins.
o Consider the following tables:
PRODUCT VENDOR
Natural Join :
o A Natural Join joins tables by selecting the rows with common values in their
commonattributes.
o Query: PRODUCT NATURALJOIN VENDOR
40
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Equi join :
o In Equijoin the tables on the basis of equality condition that compares specified
columns ofeach table. In Equijoin the comparison operator ‘+’ is used in the condition.
(Or)
o Inner join produces only the set of records that match in both Table A and Table B.
o Query: PRODUCT.Vendor_code = VENDOR.Vendor_code
Outer Join :
o In Outer Join the matched pair of records would be written and any unmatched values
in othertable would be NULL.
o Left Outer Join: In Left Outer Join matched the records would be return and any
unmatchedvalues in the other table would be NULL.
o Query: PRODUCT LEFTOUTERJOIN VENDOR
o Right Outer Join: In Right Outer Join the matched records would be and any
unmatchedvalues in the right table would be NULL.
o Query: PRODUCT RIGHTOUTERJOIN VENDOR
o Full Outer Join: Full outer join produces the set of all records in Table A and Table B,
with matching records from both sides where available. If there is no match, the
missing side will contain null.
o Query: PRODUCT FULLOUTERJOIN VENDOR
41
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Divide:
o The DIVIDE operator uses one single column table as a deviser and two column
tableas the dividend.
o The output of DIVIDE operator is a single column with a values column-A fromthe
dividend table rows where the values of the common column in both tables match.
o Example:
Now if we require the name of the
instructors who teach in all the
departments. Then we will apply division
operation on the two relations i.e.
instructor ÷ department.
[Q]. What is Normalization? Explain the need for Normalization in Database Design?
Normalization:
In the logical database design, we transform the ER diagrams into relations. Before
proceeding with the physical database design we need a method to validate the logical
design.
Normalization is a primary tool to validate and improve the logical design. So
Normalization is a systematic approach of decomposing tables to eliminate data
redundancy and undesirable characteristics like Insertion, Update and Deletion
Anomalies.
It is a multi-step process that puts data into tabular form by removing duplicated data
from the relation tables.
Normalization is used for mainly two purposes…
o Eliminating redundant (useless) data.
o Ensuring data dependencies make sense (only storing related data).
(Or)
o Eliminating data anomalies (insertion, deletion, update).
o Reduce data redundancy.
42
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Problem without Normalization :
Without Normalization, it becomes difficult to handle and update the database, without
facing data loss.
Insertion, Updation and Deletion Anamolies are very frequent if Database is not
Normalized. To understand these anomalies let us take an example of Student table.
Types of anomalies:
Updation Anamoly :
o To update address of a student who occurs twice or more than twice ina table, we will
have to update S_Address column in all the rows, else data will become inconsistent.
Insertion Anamoly:
o Suppose for a new admission, we have a Student id(S_id), name and address of a
student but if student has not opted for any subjects yet then we have to insert NULL
there, leading to Insertion Anamoly.
Deletion Anamoly:
o If (S_id) 401 has only one subject and temporarily he drops it, when we delete that
row, entire student record will be deleted along with it.
FUNCTIONAL DEPENDENCY:
Determinant:- The attributes on the left hand side of the arrow in a functional
dependency is called determinant. In the above example determinants are Sno, Course_Id.
43
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
[Q]. Explain about Basic Normal Forms in detail?
Basic Normal Forms :
Normalization is the process of efficiently organizing the data in database. Normalization
is a primary tool to validate and improve the logical design, so that is satisfies certain
conditions that avoid unnecessary duplication of data.
It is the process decomposing relations with anomalies to produce smaller, well-structures
relations.
Normalization is used for mainly two purposes,
o Eliminating redundant (useless) data.
o Ensuring data dependencies make sense (only storing related data).
(Or)
o Eliminating data anomalies (insertion, deletion, update).
o Reduce data redundancy.
o A relation is said to be in First normal form if the values in the relation are atomic.
Insimple words, there should be no repeating groups in particular column.
o A value can be defined as an atomic value, if it doesn’t contain any multi valued
attribute and no composite attribute.
o Ex: For example consider a table which is not in First normal form.
Student Table:
o In First Normal Form, any row must not have a column in which more than one value is
saved, like separated with commas. Rather than that, we must separate such data into
multiple rows.
44
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Second normal form (2 NF):-
o A relation is said to be in second normal form, if it is in first normal form and contains
no partial functional dependency (partial functional dependency is a functional
dependency in which one or more non-key attributes are functionally dependent on
some part of the primary key).
o That means every non-key attribute is fully functionally dependent on the full set of
primary key attribute. If a relation is in second normal form if any one of the following
conditions applies…
– A relation contains only one primary key.
– No non-key attribute in the relation.
o For example, a relation student contains attribute like Sno, Sname, Course_Id and date_
completed.
o In this example, the primary key is a composite key of Sno, course_Id. Here the relation
STUDENT is not in second normal form because there is a partial functional
dependency.
o Here the non-key attributes Sname, Address is functionally dependent on the part of
the primary key (Sno). So we decompose the above relation into new relations.
45
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
o The above relation contains a transitive dependency because the non-key attribute
Region is functionally dependent on another non-key attribute sales person_name.
o So the relation CUSTOMER is not in third normal form. So we decompose the above
relation into two meaningful relations.
46
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
47
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
VARCHAR2(n):
It is used for to store alphanumeric values. It is used to store variable length
strings. Maximum size is 4000 bytes
VARCHAR (n):
It is used to store variable length strings. No default size. Maximum size is 2000
bytes
Date data type:
DATE :
Data type is used to store both date and time information ranges from 01-jan- 4712to
31-dec-9999. Default format is: DD-MON-YY. It allocates 7 fixed bytes of memory.
Long data type:
Long data type stores variable- length character strings. It stores up to 32760 bytes of
data.
Raw Data type:
RAW data type stores fixed – length binary data with a maximum size of2000 bytes.
It can hold graphic characters or digitized pictures of up to 32k.
Long Raw Data type:
LONG RAW data type stores binary data like graphics characters ordigitized pictures.
It can hold maximum of 2GB data. Hence it allows large set of binary data.
LOB:
Large Object data type stores unstructured information like manage file, video file, and
audio file etc. and its storage capacity up to 4GB.
[Q]. Explain the various types of SQL Commands?
SQL Commands:
SQL commands are instructions used to communicate with the Database to perform
specialtask on data. SQL commands are divided into following categories:
o These commands are used to manipulate data within the ORACLE database. They are
used to insert, delete, update, and query the data in the database objects.
o These commands do not implicitly commit the current transaction.
o DML commands like…
INSERT – is used to insert data values(i.e rows) into a table.
UPDATE – is used to update existing data within a table.
DELETE – is used to delete only records (i.e. rows) from a table.
Data Retrieval/Querying Language (DRL/DQL):
o These SQL commands are used for retrieving or selecting data from Database.
o DRL commands like…
SELECT – is used to retrieve data from the database.
Transaction Control Language (TCL):
o Transaction Control statements manage changes made by Data Manipulation
Language commands. These commands are used to save or cancel the process of DML
commands.
o TCL commands like…
COMMIT– permanently saves data changes.
ROLLBACK–restores data to their original values in case of any error occurs.
SAVEPOINT–sets a save point.
49
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Some of the DDL commands are CREATE, ALTER, DROP, TRUNCATE, RENAME.
CREATE Command :
The CREATE TABLE command is used to create tables to store data.
Syntax:
SQL>CREATE TABLE <table_name> (column1 datatype,column2
datatype, ........ column-n datatype);
Example:
SQL> create table student (sno number(2), sname varchar2(10), marks
number(3));
ALTER Command :
The ALTER TABLE command is used to perform add, modify, delete and
rename columns in anexisting table.
Adding a column :
Syntax: ALTER TABLE table_name ADD COLUMN datatype(size);
Ex: SQL>ALTER TABLE student ADD sdob date;
Modifying a column :
Syntax: ALTER TABLE table_name MODIFY COLUMN datatype;
Ex: SQL> ALTER TABLE student MODIFY sname varchar2(20,2);
Removing a column :
Syntax: ALTER TABLE table_name DROP COLUMN column datatype;
Ex: SQL>ALTER TABLE student DROPCOLUMNsdob;
Renaming a column :
Syntax: ALTER TABLE <table_name> RENAME COLUMN
<old_column_name> TO <new_column_name>;
Ex: SQL>ALTER TABLE student RENAME COLUMN marks to smarks;
TRUNCATE Command:
The TRUNCATE TABLE command is used to remove all rowsand to release
storage space from atable. It is similar to the DELETE command without WHERE
clause.
Syntax: TRUNCATE TABLE table_name;
Ex: SQL>TRUNCATE TABLE student;
DROP Command:
The DROP TABLE command is used to removes structure and all the data of a
table.
Syntax: DROP TABLE table_name;
Ex: SQL>DROP TABLE student;
RENAME Command:
The RENAME command is used to change name of the existing table.
Syntax: RENAME old_table_name TO new_table_name;
Ex: SQL>RENAME student TO stud;
50
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
[Q]. Explain about DML Commands with examples?
DATA MANIPULATION LANGUAGE (DML) COMMANDS :
DML stands for Data Manipulation Language. DML commands are used to insert, delete and
modify the data in database. Some of the DML commands are INSERT, UPDATE and
DELETE.
INSERT Command:
o The INSERT INTO command is used to insert new rows into a table. There are two
methods toinsert values
Syntax: SQL>INSERT INTO table_name VALUES (value1, value2, …. Valuen);
(or)
SQL>INSERT INTO table_name VALUES (&col1, &col2, ….&coln);
Example: SQL>INSERT INTO student values (1, ’rama’, 100);
SQL>INSERT INTO student VALUES (&no, '&name', ‘&sdob’, &marks);
UPDATE Command:
o It is used to update or modify the existing data (i.e. rows)in a table. It modifies
specific rows based on the condition given in WHERE clause or modifies all rows
when condition is not specified.
Syntax:
UPDATE table_name SET col1 = val1, col2 = val2……. Col n = val n WHERE
condition; (Or)
UPDATE table_name SET col1 = value1, col2 = value2…col n = value n;
[Q]. Explain about Table Modification Commands (Or) Alter command with examples?
ALTER COMMAND:
The ALTER TABLE command is used to perform add, modify, delete and rename
columns in anexisting table.
Adding a column
It is used to add a column to a table using ALTER command along with ADD clause.
Syntax: ALTER TABLE table_name ADD COLUMN datatype(size);
Ex: SQL> ALTER TABLE student ADD sdob date;
51
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Modifying a column
It is used to modify a column datatype using ALTER command along with
MODIFY clause.
Syntax: ALTER TABLE table_name MODIFY COLUMN datatype(size);
Ex: SQL> ALTER TABLE student MODIFY sname varchar2(20,2);
Removing a column
It is used to remove a column using ALTER command along with DROP COLUMN.
Syntax: ALTER TABLE table_name DROP COLUMN column_name;
UNION :
o The UNION operator is used to combine two SELECT statements without duplicate
rows. In caseof UNION, no. of columns and datatype must be same in both tables.
UNION ALL:
o The UNION ALL operator is used to combine two SELECT statements with duplicate
rows.
Syntax: SQL>SELECT column list FROM table1 WHERE condition UNION ALL
SELECT column list FROM table2 WHERE condition;
Example: SQL> select *from person1 union all select *from person2;
INTERSECT:
o The INTERSECT operator is used to returns only the common rows from two SELECT
statements.
Syntax: SQL>SELECT column list FROM table1 WHERE condition INTERSECT
SELECT column list FROM table2 WHERE condition;
Example: SQL> select *from person1 intersect select *from person2;
52
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
MINUS:
o The MINUS operator is used to returns rows only by the first query( or statement)
that are notpresent in the second query(or statement)
PROJECTION OPERATION:
SELECTION OPERATION:
This operation is used to select rows from a table (or relation) that specifies a given
logic, which is called as a predicate. In relational algebra, it is denoted by the symbol σ
(lower case sigma).
The condition (Predicate) appears as a subscript to σ. The argument “relation” is given
in parenthesis following to σ. The selection operation can be considered as row-wise
filtering.
Where, σ represents the Select operation, R is the name of relation (i.e. table name). The
comparison (<, >, ≤, ≥, =, ≠) and logical (AND, OR, NOT) operators are allowed in
conditions(i.e. in predicate).
53
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Example :
54
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
LEFT OUTER JOIN
o It displays all the matching records and the records which are not matching in left
hand side table.
o Example :
SQL> select empno,ename,job,dname,loc from emp4 e LEFT OUTER JOIN
dept4 don(e.deptno=d.deptno);
55
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
CARTESIAN JOIN (or) CROSS JOIN :
o The CARTESIAN JOIN (or) CROSS JOIN returns the Cartesian product. In cross join, all
rows in the first table are joined to all rows in the second table.
o Example: SQL> select *from emp4,dept4;
(or)
SQL> select empno,ename,job,dname,loc from emp4 CROSS JOIN dept4 ;
EMPNO ENAME JOB DNAME LOC
[Q]. Define View. Explain the detailed note on Views with examples?
VIEWS:
A view is a virtual table or pseudo table. That is, a view looks like a table and does not
store data, it just displays the data. A view is a named and validated SQL query that is
stored in the database. A View can be created from a single table, multiple tables, or
another view.
Creating a View:
o Views are created from a single table using CREATE VIEW command.
o Syntax:
SQL>CREATE VIEW viewname AS SELECT col_name1,col_name2,………,
col_name n FROM table_name WHERE condition;
o Example:
SQL> create table customers(id number(5),name varchar2(10),age
number(5),addressvarchar2(10),salary number(5));
SQL> select *from customers;
SQL > CREATE VIEW customers_view AS SELECT name, age FROM customers;
SQL > SELECT * FROM customers_view;
Views from multiple tables:
o Views from multiple tables are called as complex views. We can create a view
frommultiple tables by using a JOIN in the SELECT statement.
56
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
o Example:
SQL> create table STAFF (lecid varchar2(10),name varchar2(10),position
varchar2(10));
SQL>create table COURSE (courseid varchar2(10),coursename
varchar2(10),lecid varchar2(10));
SQL>create view COURSE_STAFF AS SELECT coursename, STAFF.name from
COURSE, STAFF where COURSE.lecID=STAFF.lecID;
SQL> SELECT *FROM COURSE_STAFF;
View from view:
o We can create a view from another view using the following format…
SQL>CREATE VIEW2 AS SELECT * FROM VIEW1
Base table
o Example:
SQL> create table STAFF(empid varchar2(10),ename varchar2(10),
View 1
deptnamevarchar2(10),salary number(5),age number(5));
SQL> select *from STAFF;
View 2
o The DROP VIEW is used to drop or delete a view from database. Dropping a view has
not affecton base tables.
o Syntax: SQL>DROP VIEW viewname;
o Example: SQL>DROP VIEW CUSTOMERS_VIEW;
[Q]. Explain the different types of Views with examples?
VIEW: A view is a named and validated SQL query that is stored in the database.SQL contains
following types of views…
Simple View
Complex View
Inline view
Materialized View
Simple View:
o A Simple view derives data from only one table. A simple view does not contain
functions or group of data. A simple view always allows DML operation through the
view.
57
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Complex View:
o A Complex view derives data from many tables. These contain function or group of
data. Complex views can be constructed on more than one base table. A complex
view can contain JOIN conditions, GROUP BY clause, ORDER BY clause
o Example:
SQL>CREATE VIEW view3 AS SELECT e.* FROM empe,dept d WHERE e.deptno =
d.deptno;
Inline View:
o An inline view is a SELECT statement in the FROM clause of another SELECT
statement.
o Example:
SQL> SELECT *FROM (SELECT deptno FROM emp)emp,dept WHERE dept.deptno
= emp.deptno;
[Q]. Define Sub Queries. Explain the types of Sub Queries (or) Nested Queries?
o In single row sub query, it will return only one value. The following operators are used
withsingle row sub queries.< , >, <=, >=,==, !=
o Example: Display all the employees whose job same as allen job.
SQL> select * from emp where job=(select job from emp where ename=‟allen‟);
Display all the employees who belongs to smith employee department.
58
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Multi row sub queries:
o In multi row sub query, it will return more than one value. In such cases we should
includeoperators like any, all, in or not in between the comparison operators are used.
o Example: Display details of employee whose salary greate than the range of 20000 and
30000.
SQL> Select *from emp where sal > any ( select sal from emp where sal between
20000 and30000);
Retrieve that department names in which department does not have any employee.
SQL> select *from dept where deptno not in (select distinct(deptno) from emp);
o There is no limit on the number of sub queries included in a where clause. It allows
nesting of aquery within a sub query.
o Example:
Display details of employee who are getting maximum salry in the employee table.
SQL> select * from emp where sal = (select max(sal) from emp where sal <
(selectmax(sal) fromemp));
59
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
UNIT –V (PL/SQL)
PL/SQL :
PL/SQL stands for "Procedural Language extensions to SQL" developed by Oracle
Corporation in the early 90’s to increase the capabilities of SQL.
It is a combination of SQL along with the procedural features of programming
languages. It allows the users and designers to develop complex database applications
using control structures and procedural elements like procedures, functions, and
modules.
[Q]. Write about the Advantages of PL/SQL?
PL/SQL Advantages:
Support for SQL: PL/SQL allows us to use all SQL commands, SQL functions, operators
and data types.
Block Structure: PL/SQL is a block-structured language. Each program in PL/SQL is
written as a block. Each block performs a task. PL/SQL Blocks are stored in the database
and reused.
Control structure: PL/SQL contains procedural language constructs like conditional
statements and looping statements.
Better Performance: PL/SQL engine processes multiple SQL statements simultaneously
as a single block, thereby reducing network traffic.
Modularity: PL/SQL allows process to be divided into different modules like procedures
and functions, called as subprograms.
Portability: The programs written in PL/SQL are portable to any platform
Error Handling: PL/SQL handles errors (or) exceptions during the execution of a PL/SQL
program. Once an exception is found, specific actions can be performed depending on
the type of the exception or it can be displayed to the user with a message.
60
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Example:
SQL> set serveroutput on;
SQL> BEGIN
dbms_output.put_line (‘Hello World');
END;
/
[Q]. Explain about writing and executing PL/SQL Program with an example?
Example 1:
SQL>Set serveroutput on
SQL>BEGIN
dbms_output.put_line (‘Hello World..');
END;
/
Example 2:
SQL>Set serveroutput on
SQL>DECLARE
text VARCHAR2(25);BEGIN
text:= ‘Hello World’;
dbms_output.put_line (text);
END;
[Q]. Explain about the Elements of PL/SQL?
ELEMENTS OF PL/SQL:
PL/SQL contains set of elements like character set, reserved words, identifiers, literals etc.
Character set :
o PL/SQL programs are written by using a specific set of characters.
o The PL/SQL character set contains upper and lower case letters, numbers, Tabs,
whitespaces, carriage returns, Special symbols etc.
Reserved words :
o A reserved word has special meaning and it cannot be changed. Reserved words are
written in uppercase or lower or mixed cases.
o Example: BEGIN, DECLARE, END
Delimiters :
o Delimiters are simple or compound symbols that have special meaning to PL/SQL.
– Simple symbols are like +, - , * , / , = , @(remote access indicator) , ;(statement
terminator)
– Compound symbols are like <, >, !=, ||( concatenation) , :=(assignment) , --
(single line comment), /* …. */ (multi line comment).
Identifiers :
o In PL/SQL, Identifiers are used for naming constant, variable, exception, cursors,
62
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
VARIABLES IN PL/SQL :
In PL/SQL, variable is an identifier used to store the value that can be changed during
the execution of PL/SQL program.
To declare a variable, use a variable name followed by the data type and terminated by a
semicolon ( ;).
PL/SQL variables must be declared in the declaration section as follows…
Syntax: Variable_name datatype;
(or)
variable_name datatype := default_value;
(or)
variable_name datatype [not null := default_value] ;
Rules :
– Variable name contains alphabets, numbers, dollar signs, underscores.
– Variable names are case-insensitive.
– Keywords are not used as a variable name.
– Variables must be declared in the declaration section.
Examples:
Set serveroutput on
DECLARE
a number := 10;
b number := 20;
c number;
BEGIN
c := a + b;
63
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
A constant refers to fixed value that does not changed during the execution of PL/SQL
program.
In PL/SQL, a constant is declared using the CONSTANT keyword. It requires an initial
value and does not allow to change that value.
%Type: -
o It is column type declaration. It is used to define the variables according to the
specific column structure.
o Syntax: variable <table name>. <Column name>;
o Example: veno emp.empno%type;
%Row type: -
65
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
IF-THEN Statement :
The IF-THEN statement is used to execute sequence of statements based on
condition.
If thecondition is true, then statements inside the IF block is executed, otherwise it
does nothing.
Syntax: Example:
IF <condition> THEN SQL> Set serveroutput onSQL>
statements; DECLARE
END if; a NUMBER :=10;
BEGIN
IF( a > 10 ) THEN
dbms_output.put_line('a is greater than10');
END IF;
END;
/
IF-THEN-ELSE Statement :
Example: Example:
SQL>Set serveroutput on SQL>Set serveroutput on
SQL>DECLARE SQL>DECLARE
a NUMBER:=11; a NUMBER :=10;
BEGIN b NUMBER:=20;
IF( mod(a,2)=0) THEN BEGIN
66
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
IF-THEN-ELSIF Statement :
67
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
–
Simple loop :
It is the simplest loop structure in PL/SQL. The sequence of statements are placed
inside theLOOP and END LOOP. The EXIT or EXIT WHEN is used to break the loop.
Syntax: LOOP
Sequence of statements;
END LOOP;
Example: SQL>set serveroutput on
SQL> declare
a number :=0;
begin
loop
a := a+1;
dbms_output.put_line(' value of a is: '||a);
exit when a>5 ;
end loop;
end;
WHILE LOOP Statement :
o A WHILE LOOP statement is used to execute a statement repeatedly until given
condition is true.
First, the condition is tested. If the condition is TRUE, the sequence of statements
is executed,otherwise loop is terminated and control passes to the next statement.
Syntax: Example:
WHILE condition LOOP SQL> set serveroutput on
Statements; SQL> DECLARE
END LOOP; n NUMBER := 0;
BEGIN
WHILE n < 10 LOOP
n := n + 1;
END LOOP;
DBMS_OUTPUT.PUT_LINE('Sum :' || n);
END;
/
A FOR LOOP is used to execute the code for a no. of times repeatedly.
Syntax : FOR counter IN [REVERSE] initial_value ..final_valueLOOP
statements;
END LOOP;
Example Example
SQL> Set serveroutput on SQL> SET SERVEROUTPUT
ON;
SQL> DECLARE SQL> DECLARE
68
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
CASE statements :
CASE statement:
A CASE statement is similar to IF-THEN-ELSIF statement. The CASE statement
selects one alternative among several alternatives.
The CASE statement uses "selector" to select the alternatives instead of Boolean
expression. Each alternative is assigned with a predefined value.
If the value is matched with selector value then the statements inside WHEN clause
is executed.
Syntax: CASE (selector)
WHEN ‘value 1’ THEN
statements;
WHEN ‘value2’ THEN
statements;
ELSE
Default Statements;
END;
Example:
SQL>Set serveroutput on
SQL>DECLARE
a NUMBER :=55; b NUMBER :=5;
arth_operationVARCHAR2(20) :='MULTIPLY’;
BEGIN
CASE (arth_operation)
WHEN ‘ADD’ THEN dbms_output.put_Iine(‘Addition: '|| a+b );
WHEN ‘SUBTRACT' THEN dbms_output.put_line(‘Subtraction: '||a-b );
WHEN ‘MULTIPLY' THEN dbms_output.put_line(‘Multiplication:'|| a*b);
WHEN ‘DIVIDE' THEN dbms_output.put_line(‘Division:'|| a/b);
ELSE dbms_output.put_line(‘Invalid operation');
END;
END;
69
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Example:
SQL>Set serveroutput on
SQL>DECLARE
a NUMBER :=55; b NUMBER :=5;
arth_operation VARCHAR2(20) :=' MULTIPLY';
BEGIN
CASE WHEN arth_operation = 'ADD' THEN
dbms_output.put_line(‘Addition:'||a+b );
WHEN arth_operation = ‘SUBTRACT' THEN
dbms_output.put_line(‘Subtraction:'|| a-b);
WHEN arth_operation = ‘MULTIPLY’ THEN
dbms_output.put_line(‘Multiplication:'|| a*b );
WHEN arth_operation = ’DIVIDE' THEN
dbms_output.put_line(‘Division:'|| a/b );
ELSE
dbms_output.put_Iine(‘Invalid operation');
END;
END;
[Q]. Explain about Procedure (Or) Stored Procedures in Pl/SQL with examples?
PROCEDURE (or) STORED PROCEDURES in PL/SQL :
A Procedure (or sub-program) is a small part of a program that performs a particular
task, and it does not need to return any value.
A procedure contains header, declaration section, executable section and optional
exception handling section.
Creating a Procedure:
o In PL/SQL, a procedure is created by using CREATE PROCEDURE statement with a
list of parameters. When creating a procedure, define IN/OUT/INOUT parameters:
70
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Calling/Execute a Procedure:
o A procedure is called by using the EXECUTE keyword or called by giving its name
followed byparameters.
o Syntax: SQL>Execute Procedure-Name;
Example: SQL> EXECUTE prog1(10,20);
71
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Alter a Procedure:
o The ALTER statement is used to recompile or re-design an existing procedure.
o Syntax: SQL>Alter Procedure [Procedure-Name];
Delete or Drop a Procedure:
o The DROP keyword is used to delete an existing procedure.
o Syntax: SQL>Drop Procedure [Procedure-Name];
o Example: SQL> drop procedure prog1;
[Q]. Explain about Functions in PL/SQL with examples?
FUNCTIONS in PL/SQL :
A function is a named PL/SQL block that takes one or more parameter and returns one
value. Like procedure, a function contains header, declaration section, executable
section and optional exception handling section.
A function contains RETURN clause in the header section and at least one RETURN
statement in the execution section.
Creating a Function:
o In PL/SQL, a function is created by using CREATE FUNCTION statement with a list
ofparameters. When creating a procedure, define IN/OUT/INOUT parameters.
o Syntax:
CREATE OR REPLACE FUNCTION function_name Parameter_Name
[IN | OUT | IN OUT ] datatype(size)RETURN datatype
IS | AS
DECLARE
declaration_section
BEGIN
executable_section
[EXCEPTION]
exception_section
END function_name;
/
Where,
CREATE FUNCTION keyword is used to create a new function
OR REPLACE option is used to modify an existing function.
function_Name is used to specify the name of the function.
Parameter_Name specifies name of the variable whose value is passed to the function.
RETURN specifies datatype of return value
Datatype specifies datatype of the argument or procedure.
Execute a Function:
o A function accepts one or more parameters but returns only one value.
o Syntax:
Function_Name (parameterlist);
72
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Example:
Creating a Function: Calling a Function:
SQL> create or replace function adder(n1 in SQL> DECLARE
number, n3 number(2);
n2 in number) BEGIN
return number n3 := adder(11,22);
is dbms_output.put_line('Addition is: ' ||
n3 number(8); n3);
begin END;
n3 :=n1+n2; /
return n3; Addition is: 33
end; PL/SQL procedure successfully
/ completed.
[Q]. Explain about Triggers with examples and also write it’s benefits?
TRIGGERS:
Triggers in oracle are blocks of PL/SQL code which are executed automatically based on
someaction or event.
These events can be:
– DDL statements (CREATE, ALTER, DROP, TRUNCATE).
– DML statements (INSERT, SELECT, UPDATE, DELETE).
– Database operation like connecting or disconnecting to oracle (LOGON, LOGOFF,
SHUTDOWN).
Triggers are automatically and repeatedly called upon by oracle engine on satisfying
certaincondition. Triggers can be activated or deactivated depending on the requirements.
Benefits Triggers:
Triggers can be written for the following purposes −
– Generating some derived column values automatically.
– Enforcing referential integrity.
– Event logging and storing information on table access.
– Auditing.
– Synchronous replication of tables.
– Imposing security authorizations.
– Preventing invalid transactions.
Creating Triggers:
o We can create trigger using the CREATE TRIGGER statement. If trigger activated,
implicitly fire DMLstatement and if trigger deactivated can't fire.
o Syntax:
CREATE [OR REPLACE] TRIGGER trigger_name
[BEFORE | AFTER | INSTEAD OF]
[INSERT | UPDATE | DELETE [OF col_name]]
73
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
ON table_name
[REFERENCING OLD AS O, NEW AS N]
[FOR EACH STATEMENT | FOR EACH ROW]
WHEN conditionDECLARE
Declaration statements
BEGIN
PL/SQL Code
END trigger_name;
Where
CREATE [OR REPLACE] TRIGGER trigger_name: Create a trigger with the given name. If
already have overwrite the existing trigger with defined same name.
BEFORE | AFTER : Indicates when the trigger get fire(i.e., specify the timing of the
trigger's occurrences). BEFORE trigger execute before when statement execute before.
AFTER trigger execute after the statement execute. INSTEAD OF is used when a view is
created.
[INSERT, UPDATE, DELETE [COLUMN NAME..]: Determines the performing trigger
event. We can define more than one triggering event separated by OR keyword.
ON table_name: Define the table name to performing trigger event.
Referencing [ OLD AS OLD | NEW AS NEW ]: Give referencing to an old and new
valuesof the data. :old means use existing row to perform event and :new means use
executingnew row to perform event.
FOR EACH ROW | FOR EACH STATEMENT: is the clause used to specify row level
trigger and fire only once when the entire sql statement is execute.
WHEN Condition: it is Optional. Use only for row level trigger. Trigger fire when
specified condition is satisfy.
Example:
CREATE OR REPLACE TRIGGER
CheckAgeBEFORE
INSERT OR UPDATE ON student
FOR EACH ROW
BEGIN
IF :new.Age>30 THEN
raise_application_error(-20001, 'Age should not be greater than 30');END IF;
END;
Output: Trigger created.
11 Anu 20 BSC
12 Asha 21 BCOM
13 Arpit 18 BCA
14 Chetan 20 BCA
15 Nihal 19 BBA
74
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
After initializing the trigger CheckAge, whenever we will insert any new values or
update the existing values in the above table STUDENT our trigger will check the age
before executing INSERT or UPDATE statements and according to the result of
triggering restriction or condition it will execute the statement.
Let's take a few examples and try to understand this concept like….
Example-1:
INSERT into STUDENT values(16, 'Saina', 32, 'BCOM');
Output:
Age should not be greater than 30
Example-2:
INSERT into STUDENT values(17, 'Anna', 22, 'BCOM');
Output:
1 row created
Example-3:
UPDATE STUDENT set age=31 where ROLLNO=12;
Output:
Age should not be greater than 30
Example-4:
UPDATE STUDENT set age=23 where ROLLNO=12;
Output:
1 row updated.
EXAMPLE 2:
Existing data: SQL>Select * from employees;
75
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Note: The above trigger will execute for every INSERT, UPDATE or DELETE operations
performed on the EMPLOYEES table.
Drop a trigger:
SQL>DROP TRIGGER trigger_name;
[Q]. Explain the parts of Triggers and write down the types of Triggers?
PARTS OF A TRIGGER :
Whenever a trigger is created, it contains the following three sequential parts:
Triggering Event or Statement: The statements due to which a trigger occurs is called
triggering event or statement. Such statements can be DDL statements, DML statements
or any database operation, executing which gives rise to a trigger.
Trigger Restriction: The condition or any limitation applied on the trigger is called
trigger restriction. Thus, if such a condition is TRUE then trigger occurs otherwise it
does not occur.
Trigger Action: When the triggering SQL statement is execute, trigger automatically call
and PL/SQL trigger block execute.
TYPES OF TRIGGERS:
A trigger’s type is defined by the type of triggering transaction and by the level at which
the trigger is executed. In the following sections, you will see descriptions of these
classifications, along with relevant restrictions.
Row-Level Triggers:
Row-level triggers execute once for each row in a transaction. Row-level triggers are
the most common type of trigger; they are often used in data auditing applications.
Statement-Level Triggers:
Statement-level triggers execute once for each transaction. For example, if a single
transaction inserted 500 rows into a table, then a statement-level trigger on that table
would only be executed once.
[Q]. Explain various types of Triggers with an example?
TYPES OF TRIGGERS IN PL/SQL :
PL/SQL clearly indicated that Triggers can be classified into three categories:
Level Triggers
Event Triggers
Timing Triggers
Level Triggers
There are 2 different types of level triggers, they are…
o ROW LEVEL TRIGGERS(default for view)-Executed once for the Entire DML Operation.
Executed once for the Entire DML statements like INSERT, UPDATE, DELETE
etc.
It always uses a FOR EACH ROW clause in a triggering statement.
o STATEMENT LEVEL TRIGGERS (default for tables):
Executed once for each row affected by the event
76
DATA BASE MANAGEMENT SYSTEM (DBMS) 2BSC – 3 SEMESTER – PAPER - III
Event Triggers :
There are 3 different types of event triggers, they are…
o DDL EVENT TRIGGER :
It fires with the execution of every DDL statement (CREATE, ALTER, DROP,
TRUNCATE).
o DML EVENT TRIGGER :
It fires with the execution of every DML statement (INSERT, UPDATE, DELETE).
Statement Trigger: Statement trigger fire only once for each statement. If row
deleting is define as trigger event, when trigger file, deletes the five rows at once from
the table.
Combination Trigger: Combination trigger are combination of two trigger types like…
Before Statement Trigger: Trigger fire only once for each statement before
thetriggering DML statement.
Before Row Trigger : Trigger fire for each and every record before the
triggeringDML statement.
After Statement Trigger: Trigger fire only once for each statement after the
triggering DML statement executing.
After Row Trigger: Trigger fire for each and every record after the triggering
DMLstatement executing.
77