0% found this document useful (0 votes)
59 views

DBMS Notes

The document provides information about database system applications and the differences between database management systems (DBMS) and file systems. It discusses 10 examples of database applications, including library management systems, banking, education, and online shopping. It then compares DBMS and file systems in terms of meaning, data sharing, abstraction, security/protection, recovery mechanisms, manipulation techniques, and more. DBMS approaches provide centralized data sharing and abstraction while file systems involve distributed data across files of different formats.

Uploaded by

abhishek.kundu
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

DBMS Notes

The document provides information about database system applications and the differences between database management systems (DBMS) and file systems. It discusses 10 examples of database applications, including library management systems, banking, education, and online shopping. It then compares DBMS and file systems in terms of meaning, data sharing, abstraction, security/protection, recovery mechanisms, manipulation techniques, and more. DBMS approaches provide centralized data sharing and abstraction while file systems involve distributed data across files of different formats.

Uploaded by

abhishek.kundu
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 28

1

DEPARTMENT OF COMPUTER
SCIENCE AND ENGINEERING

Study Material

GPCSET-401 – D.B.M.S

for

Diploma – IV Semester

Academic Year (2022-2023)


2

DBMS
UNIT I: Introduction to DBMS Concepts

Data base system Applications


Data base Systems versus Manual Systems
View of data, Data Models
Database languages
Database users and administrators
Transaction management, database system
structure
Application architectures, history of
database Systems

Topic 1 - Database System Applications:

There are different fields where a database management system is utilized. Following are a few
applications which utilize the information base administration framework –
1. Railway Reservation System –
In the rail route reservation framework, the information base is needed to store the record or
information of ticket appointments, status about train’s appearance, and flight. Additionally,
if trains get late, individuals become acquainted with it through the information base update.

2. Library Management System –


There are lots of books in the library so; it is difficult to store the record of the relative
multitude of books in a register or duplicate. Along these lines, the data set administration
framework (DBMS) is utilized to keep up all the data identified with the name of the book,
issue date, accessibility of the book, and its writer.

3. Banking –
Database the executive’s framework is utilized to store the exchange data of the client in the
information base.

4. Education Sector –
Presently, assessments are led online by numerous schools and colleges. They deal with all
assessment information through the data set administration framework (DBMS). In spite of
that understudy’s enlistments subtleties, grades, courses, expense, participation, results, and
so forth all the data is put away in the information base.

5. Credit card exchanges –


The database Management framework is utilized for buying on charge cards and age of
month to month proclamations
6. Social Media Sites –
We all utilization of online media sites to associate with companions and to impart our
perspectives to the world. Every day, many people group pursue these online media
accounts like Pinterest, Facebook, Twitter, and Google in addition to. By the utilization of
the data set administration framework, all the data of clients are put away in the
information base and, we become ready to interface with others.
3

7. Broadcast communications –
Without DBMS any media transmission organization can’t think. The Database the
executive’s framework is fundamental for these organizations to store the call subtleties
and month to month postpaid bills in the information base.

8. Account –
The information base administration framework is utilized for putting away data about
deals, holding and acquisition of monetary instruments, for example, stocks and bonds in
a data set.

9. Online Shopping –
These days, web-based shopping has become a major pattern. Nobody needs to visit the
shop and burn through their time. Everybody needs to shop through web based shopping
sites, (for example, Amazon, Flipkart, Snapdeal) from home. So all the items are sold and
added uniquely with the assistance of the information base administration framework
(DBMS). Receipt charges, installments, buy data these are finished with the assistance of
DBMS.

10. Human Resource Management –


Big firms or organizations have numerous specialists or representatives working under
them. They store data about worker’s compensation, assessment, and work with the
assistance of an information base administration framework (DBMS).

11. Manufacturing –
Manufacturing organizations make various kinds of items and deal them consistently. To
keep the data about their items like bills, acquisition of the item, amount, inventory
network the executives, information base administration framework (DBMS) is utilized.

12. Airline Reservation System –


This framework is equivalent to the railroad reservation framework. This framework
additionally utilizes an information base administration framework to store the records of
flight takeoff, appearance, and defer status.
4

Topic 2 - Data base Systems versus Manual Systems:

There are the following differences between DBMS and File systems:

Basis DBMS Approach File System Approach

Meaning DBMS is a collection of The file system is a collection of data. In


data. In DBMS, the user is this system, the user has to write the
not required to write the procedures for managing the database.
procedures.

Sharing of data Due to the centralized Data is distributed in many files, and it may
approach, data sharing is be of different formats, so it isn't easy to
easy. share data.

Data DBMS gives an abstract The file system provides the detail of the
Abstraction view of data that hides the data representation and storage of data.
details.

Security and DBMS provides a good It isn't easy to protect a file under the file
Protection protection mechanism. system.

Recovery DBMS provides a crash The file system doesn't have a crash
Mechanism recovery mechanism, i.e., mechanism, i.e., if the system crashes while
DBMS protects the user entering some data, then the content of
from system failure. the file will be lost.

Manipulation DBMS contains a wide The file system can't efficiently store and
Techniques variety of sophisticated retrieve the data.
techniques to store and
retrieve the data.

Concurrency DBMS takes care of In the File system, concurrent access has
Problems Concurrent access of data many problems like redirecting the file
using some form of while deleting some information or
locking. updating some information.

Where to use Database approach used in File system approach used in large systems
large systems which which interrelate many files.
interrelate many files.

Cost The database system is The file system approach is cheaper to


expensive to design. design.

Data Due to the centralization In this, the files and application programs
Redundancy of the database, the are created by different programmers so
and problems of data that there exists a lot of duplication of data
Inconsistency redundancy and which may lead to inconsistency.
5

inconsistency are
controlled.

Topic 3 - View of data:

View of data in DBMS narrate how the data is visualized at each level of data abstraction? Data
abstraction allow developers to keep complex data structures away from the users. The developers
achieve this by hiding the complex data structures through levels of abstraction.

View of Data in DBMS


Data Abstraction
Data Independence
Instance and Schema
Key Takeaways

Data Abstraction
Data abstraction is hiding the complex data structure in order to simplify the user’s interface of
the system. It is done because many of the users interacting with the database system are not that
much computer trained to understand the complex data structures of the database system.

To achieve data abstraction, we will discuss a Three-Schema architecture which abstracts the
database at three levels discussed below:
Three-Schema Architecture:
The main objective of this architecture is to have an effective separation between the user
interface and the physical database

The three-schema architecture defines the view of data at three levels:


1. Physical level (internal level)
2. Logical level (conceptual level)
3. View level (external level)

1. Physical Level/ Internal Level

The physical or the internal level schema describes how the data is stored in the hardware. It also
describes how the data can be accessed. The physical level shows the data abstraction at the lowest
level and it has complex data structures. Only the database administrator operates at this level.

2. Logical Level/ Conceptual Level

It is a level above the physical level. Here, the data is stored in the form of the entity set, entities,
their data types, the relationship among the entity sets, user operations performed to retrieve or
modify the data and certain constraints on the data. Well adding constraints to the view of data
adds the security. As users are restricted to access some particular parts of the database.

It is the developer and database administrator who operates at the logical or the conceptual level.

3. View Level/ User level/ External level


6

It is the highest level of data abstraction and exhibits only a part of the whole database. It exhibits
the data in which the user is interested. The view level can describe many views of the same data.
Here, the user retrieves the information using different application from the database.

Now, the entity sets Student, Lecturer, Department, Course will be stored in the storage as
the consecutive blocks of the memory location. This is the physical or internal level and is
hidden from the programmers but the database administrator is it aware of it.
At the logical level, the programmers define the entity sets and relationship among these entity sets
using a programming language like SQL. So, the programmers work at the logical level and even
the database administrator also operates at this level.
At the view level, the users have the set of applications which they use to retrieve the data they are
interested in.

Data Independence
Data independence defines the extent to which the data schema can be changed at one level
without modifying the data schema at the next level. Data independence can be classified as shown
below:
Logical Data Independence:
Logical data independence describes the degree up to which the logical or conceptual schema can
be changed without modifying the external schema. Now, a question arises what is the need to
change the data schema at a logical or conceptual level?
Physical Data Independence:
Physical data independence defines the extent up to which the data schema can be changed at the
physical or internal level without modifying the data schema at logical and view level.
Well, the physical schema is changed if we add additional storage to the system or we reorganize
some files to enhance the retrieval speed of the records.

Topic 4 – Data Models:

What are the Data Models in DBMS?


The Data Model gives us an idea of how the final system would look after it has been fully
implemented. It specifies the data items as well as the relationships between them. In a database
management system, data models are often used to show how data is connected, stored, accessed,
and changed. We portray the information using a set of symbols and language so that members of
an organisation may understand and comprehend it and then communicate.

Types of Data Models in DBMS


Though there are other data models in use today, the Relational model is the most used. Aside from
the relational model, there are a variety of different data models that we shall discuss in-depth in
this article. Data Models in DBMS include the following:

Hierarchical Model
This concept uses a hierarchical tree structure to organise the data. The hierarchy begins at the root,
which contains root data, and then grows into a tree as child nodes are added to the parent node. If
you wish to learn more about the hierarchical model, click here.

Network Model
The main difference between this model and the hierarchical model is that any record can have
several parents in the network model. It uses a graph instead of a hierarchical tree. If you wish to
learn more about the network model, click here.
7

Entity-Relationship Model
The real-world problem is depicted in visual form in this model to make it easier for stakeholders
to comprehend. The ER diagram also makes it very simple for developers to comprehend the
system. If you wish to learn more about the entity-relationship model, click here.

Relational Model
The data in this model is kept in the form of a table that is two-dimensional. All of the data is kept
in the form of rows and columns. Tables are the foundation of a relational paradigm. If you wish to
learn more about the relational model, click here.

Object-Oriented Data Model


Both the data and the relationship are contained in a single structure that is known as an object in
this model. We can now store audio, video, pictures, and other types of data in databases, which
was previously impossible with the relational approach (Although you can store video and audio in
relational DB, it is advised not to store them in the relational database). If you wish to learn more
about the object-oriented data model, click here.

Object-Relational Data Model


It is a hybrid of relational and object-oriented models. This model was developed to bridge the gap
between the object-oriented and relational models. If you wish to learn more about the object-
relational data model, click here.

Flat Data Model


It’s a straightforward model in which the DB is depicted as a table with rows and columns. If you
wish to learn more about the flat data model, click here.

Semi-Structured Data Model


The relational model has evolved into the semi-structured model. In this model, we can’t tell the
difference between data and schema. If you wish to learn more about the semi-structured data
model, click here.

Associative Data Model


It is a model in which the data is separated into two sections. Everything that has its own existence
is referred to as an entity, and the relationships between these entities are referred to as
associations. Items and links are two types of data that are separated into two components. If you
wish to learn more about the associative data model, click here.

Context Data Model


The Context Data Model is made up of various models. This includes models such as network
models and relational models, among others.

Topic 5 - database languages:


Once data is stored or filled it requires manipulation like insertion, deletion, updating, and
modification of data. For these operations a set of languages are provided by the database
8

management system (DBMS). So, the database languages are used to read, update and store data in
the database.

The different types of DBMS languages are as follows −

 Data Definition Language (DDL) − Create, Drop, Truncate, Rename.


 Data Manipulation language (DML) − Select, Insert, Delete, Update.
 Data Control Language (DCL) − Revoke, Grant.
 Transaction Control Language (TCL) − Rollback, Commit.

The DBMS languages are pictorially represented as follows −

Data Definition Language (DDL)


It is a language that allows the user to define the data and their relationship to other types of data.
The DDL commands are: Create, Alter, Rename, Drop, Truncate.
Data Manipulation Language (DML)
It is a language that provides a set of operations to support the basic data manipulation operation
on data held in the database. The DML commands are: Insert, delete, update, select, merge, call.
9

Data Control Language (DCL)


DCL is used to access the stored data. It is mainly used for revoke and grant the user access to a
database. The DCL commands are: Grant, Revoke.
Transaction Control Language (TCL)
TCL is a language which manages the transactions within the database. It is used to execute the
changes made by the data manipulation language statements. The TCL commands are: Commit,
Rollback.

Topic 6 - database users and administrators

Database users are categorized based up on their interaction with the database. These are seven
types of database users in DBMS.
1. Database Administrator (DBA): Database Administrator (DBA) is a person/team who
defines the schema and also controls the 3 levels of database. The DBA will then create a
new account id and password for the user if he/she need to access the database. DBA is also
responsible for providing security to the database and he allows only the authorized users to
access/modify the data base. DBA is responsible for the problems such as security breaches
and poor system response time.
 DBA also monitors the recovery and backup and provide technical support.
 The DBA has a DBA account in the DBMS which called a system or superuser
account.
 DBA repairs damage caused due to hardware and/or software failures.
 DBA is the one having privileges to perform DCL (Data Control Language)
operations such as GRANT and REVOKE, to allow/restrict a particular user from
accessing the database.
2. Naive / Parametric End Users: Parametric End Users are the unsophisticated who don’t
have any DBMS knowledge but they frequently use the database applications in their daily
life to get the desired results. For examples, Railway’s ticket booking users are naive users.
Clerks in any bank is a naive user because they don’t have any DBMS knowledge but they
still use the database and perform their given task.
3. System Analyst:
System Analyst is a user who analyzes the requirements of parametric end users. They
check whether all the requirements of end users are satisfied.
4. Sophisticated Users: Sophisticated users can be engineers, scientists, business analyst,
who are familiar with the database. They can develop their own database applications
according to their requirement. They don’t write the program code but they interact the
database by writing SQL queries directly through the query processor.
5. Database Designer: Data Base Designers are the users who design the structure of
database which includes tables, indexes, views, triggers, stored procedures and constraints
which are usually enforced before the database is created or populated with data. He/she
controls what data must be stored and how the data items to be related. It is responsibility
of Database Designers to understand the requirements of different user groups and then
create a design which satisfies the need of all the user groups.
6. Application Programmers: Application Programmers also referred as System Analysts or
simply Software Engineers, are the back-end programmers who writes the code for the
application programs. They are the computer professionals. These programs could be
written in Programming languages such as Visual Basic, Developer, C, FORTRAN,
COBOL etc. Application programmers design, debug, test, and maintain set of programs
called “canned transactions” for the Naive (parametric) users in order to interact with
database.
7. Casual Users / Temporary Users: Casual Users are the users who occasionally use/access
the database but each time when they access the database they require the new information,
for example, Middle or higher level manager.
10

Topic 7 - Transaction management:

TRANSACTION MANAGEMENT IN DBMS:


 A transaction is a set of logically related operations.
 Now that we understand what is transaction, we should understand what are the
problems associated with it.
 The main problem that can happen during a transaction is that the transaction can fail
before finishing the all the operations in the set. This can happen due to power failure,
system crash etc.
TRANSACTION MANAGEMENT IN DBMS:
 A transaction is a set of logically related operations.
 Now that we understand what is transaction, we should understand what are the
problems associated with it.
 The main problem that can happen during a transaction is that the transaction can fail
before finishing the all the operations in the set. This can happen due to power failure,
system crash etc.
To solve this problem, we have the following two operations
Commit: If all the operations in a transaction are completed successfully then commit those
changes to the database permanently.
To solve this problem, we have the following two operations
Commit: If all the operations in a transaction are completed successfully then commit those
changes to the database permanently.
TRANSACTION MANAGEMENT IN DBMS:
 A transaction is a set of logically related operations.
 Now that we understand what is transaction, we should understand what are the
problems associated with it.
 The main problem that can happen during a transaction is that the transaction can fail
before finishing the all the operations in the set. This can happen due to power failure,
system crash etc.
 This is a serious problem that can leave database in an inconsistent state. Assume that
transaction fail after third operation (see the example above) then the amount would
be deducted from your account but your friend will not receive it.
To solve this problem, we have the following two operations
Commit: If all the operations in a transaction are completed successfully then commit those
changes to the database permanently.
Rollback: If any of the operation fails then rollback all the changes done by previous
operations

STATES OF TRANSACTION
Transactions can be implemented using SQL queries and Server. In the below-given
diagram, you can see how transaction states works.
STATES OF TRANSACTION
Transactions can be implemented using SQL queries and Server. In the below-given
diagram, you can see how transaction states works.
11

Active state
The active state is the first state of every transaction. In this state, the transaction is
being executed.
For example: Insertion or deletion or updating a record is done here. But all the
records are still not saved to the database.

Partially committed
In the partially committed state, a transaction executes its final operation, but the data
is still not saved to the database.
In the total mark calculation example, a final display of the total marks step is
executed in this state.

Committed
A transaction is said to be in a committed state if it executes all its operations successfully. In
this state, all the effects are now permanently saved on the database system.

Failed state
If any of the checks made by the database recovery system fails, then the transaction
is said to be in the failed state.
In the example of total mark calculation, if the database is not able to fire a query to
fetch the marks, then the transaction will fail to execute.

Aborted
o If any of the checks fail and the transaction has reached a failed state then the
database recovery system will make sure that the database is in its previous consistent
state. If not then it will abort or roll back the transaction to bring the database into a
consistent state.
o If the transaction fails in the middle of the transaction then before executing the
transaction, all the executed transactions are rolled back to its consistent state.
o After aborting the transaction, the database recovery module will select one of the two
operations:
Aborted
If any of the checks fail and the transaction has reached a failed state then the
database recovery system will make sure that the database is in its previous consistent
state. If not then it will abort or roll back the transaction to bring the database into a
12

consistent state.
If the transaction fails in the middle of the transaction then before executing the
transaction, all the executed transactions are rolled back to its consistent state.
After aborting the transaction, the database recovery module will select one of the two
operations:
1. Re-start the transaction
2. Kill the transaction

TRANSACTION PROPERTY
The transaction has the four properties. These are used to maintain consistency in a database,
before and after the transaction.
Property of Transaction
1. Atomicity
2. Consistency
3. Isolation
4. Durability

Atomicity
It states that all operations of the transaction take place at once if not, the transaction
is aborted.
There is no midway, i.e., the transaction cannot occur partially. Each transaction is
treated as one unit and either run to completion or is not executed at all.
Atomicity involves the following two operations:
Abort: If a transaction aborts then all the changes made are not visible.

Commit: If a transaction commits then all the changes made are visible.

Consistency
The integrity constraints are maintained so that the database is consistent before and
after the transaction.
o The execution of a transaction will leave a database in either its prior stable state or a
new stable state.
o The consistent property of database states that every transaction sees a consistent
database instance.
o The transaction is used to transform the database from one consistent state to another
consistent state.

Isolation
o It shows that the data which is used at the time of execution of a transaction cannot be
used by the second transaction until the first one is completed.
o In isolation, if the transaction T1 is being executed and using the data item X, then
that data item can't be accessed by any other transaction T2 until the transaction T1
ends.
o The concurrency control subsystem of the DBMS enforced the isolation property.

Durability
o The durability property is used to indicate the performance of the database's
consistent state. It states that the transaction made the permanent changes.
o They cannot be lost by the erroneous operation of a faulty transaction or by the
system failure. When a transaction is completed, then the database reaches a state
known as the consistent state. That consistent state cannot be lost, even in the event of
a system's failure.
o The recovery subsystem of the DBMS has the responsibility of Durability property.
13

Topic 8 - Database system structure:

DBMS (Database Management System) acts as an interface between the user and the database. The
user requests the DBMS to perform various operations (insert, delete, update and retrieval) on the
database. The components of DBMS perform these requested operations on the database and
provide necessary data to the users. The various components of DBMS are shown below: -

Structure of DBMS

1. DDL Compiler - Data Description Language compiler processes schema definitions


specified in the DDL. It includes metadata information such as the name of the files, data items,
storage details of each file, mapping information and constraints etc.

2. DML Compiler and Query optimizer - The DML commands such as insert, update,
delete, retrieve from the application program are sent to the DML compiler for compilation into
object code for database access. The object code is then optimized in the best way to execute a
query by the query optimizer and then send to the data manager.

3. Data Manager - The Data Manager is the central software component of the DBMS also
knows as Database Control System.

Topic 9 - Application architectures:

A Database store a lot of critical information to access data quickly and securely. Hence it is
important to select a correct Architecture for efficient data management.
Types of DBMS Architecture:
 1- Tier Architecture
 2- Tier Architecture
 3- Tier Architecture

One- Tier Architecture:


In One-Tier Architecture the database is directly available to the user, the user can directly sit on
the DBMS and use it i.e.; the client, server, and the Database are all present on the same machine.
For Example- To learn SQL we set up an SQL server and the database on the local system. This
enables us to directly interact with the relational database and execute operations. The industry
14

won’t use this architecture they logically go for 2-Tier and 3-Tier Architecture.

Two-tier architecture:
The two-tier architecture is similar to a basic client-server model. The application at the client end
directly communicates with the database at the server side. APIs like ODBC and JDBC are used
for this interaction. The server side is responsible for providing query processing and transaction
management functionalities. On the client side, the user interfaces and application programs are
run. The application on the client side establishes a connection with the server side in order to
communicate with the DBMS.
An advantage of this type is that maintenance and understanding are easier, and compatible with
existing systems. However, this model gives poor performance when there are a large number of
users.

Three Tier architecture:


In this type, there is another layer between the client and the server. The client does not directly
communicate with the server. Instead, it interacts with an application server which further
communicates with the database system and then the query processing and transaction
management takes place. This intermediate layer acts as a medium for the exchange of partially
processed data between server and client. This type of architecture is used in the case of large web
applications.
15

Topic 10 - History of database Systems:

1960s
Computerized databases started in the 1960s, when the use of computers became a more cost-
effective option for private organizations. The history of computers and databases are interlinked.
As prices dropped it became easier to shift data storage and databases to computers.
There were two popular data models in this decade: a network model called CODASYL and a
hierarchical model called IMS. One database system that proved to be a commercial success was
the SABRE system that was used by IBM to help American Airlines manage its reservations data.

1970s
The Introduction of the Relational Database
E.F. Codd published an important paper that served as the introduction of the relational database,
and his ideas changed the way people thought about databases. In his model, the database’s
schema, or logical organization, is disconnected from physical information storage, and this
became the standard principle for database systems.
Two major relational database system prototypes were created between the years 1974 and 1977,
and they were the Ingres, which was developed at UBC, and System R, created at IBM San Jose.
Ingres used a query language known as QUEL, and it led to the creation of systems such as Ingres
Corp., MS SQL Server, Sybase, Wang’s PACE, and Britton-Lee. On the other hand, System R
used the SEQUEL query language, and it contributed to the development of SQL/DS, DB2,
Allbase, Oracle, and Non-Stop SQL. It was also in this decade that Relational Database
Management System, or RDBMS, became a recognized term.
In 1976, new database model called Entity-Relationship, or ER, was proposed by P. Chen this year.
This model made it possible for designers to focus on data application, instead of logical table
structure.

1980s
Structured Query Language, or SQL, became the standard query language, selected by the
American National Standards Institute in 1986 and the International Organization for
Standardization in 1987.
Relational database systems became a commercial success as the rapid increase in computer sales
boosted the database market, and this caused a major decline in the popularity of network and
hierarchical database models. DB2 became the flagship database product for IBM, and the
introduction of the IBM PC resulted in the establishments of many new database companies and
the development of products such as PARADOX, RBASE 5000, RIM, Dbase III and IV, OS/2
Database Manager, and Watcom SQL.

1990s
The 1990s served a pivotal role in the advancement of databases and database software. Similar to
the 1960s, a broader culture shift led to further developments in the industry. After a shakeout,
most of the surviving companies sold complex database products at high prices.
Around this time, new client tools for application development were released, and these included
the Oracle Developer, PowerBuilder, VB, and others. A number of tools for personal productivity,
such as ODBC and Excel/Access, were also developed. Prototypes for Object Database
Management Systems, or ODBMS, were created in the early 1990s.
During the middle of the decade the advent of the Internet led to exponential growth of the
database industry. Average desktop users began to use client-server database systems to access
computer systems that contained legacy data. As more and more users purchased personal
computers and went online, there became a larger need to enhance databases.
Toward the end of the 1990s, increased investment in online businesses resulted in a rise in
demand for Internet database connectors, such as Front Page, Active Server Pages, Java Servelets,
Dream Weaver, ColdFusion, Enterprise Java Beans, and Oracle Developer 2000. The use of CGI,
16

GCC, MySQL, Apache, and other systems brought open source solution to the Internet. With the
increased use of point-of-sale technology, online transaction processing and online analytic
processing began to come of age.

The Beginning of the NoSQL Database


Since the 1980s SQL had served as the standard query language. But in 1998 Carlo Strozzi coined
the term “NoSQL” when naming his database Strozzi NoSQL. This initial offering was still
relational in nature, however. It would take until 2009 for NoSQL to re-enter the industry’s
vocabulary, when developer Johan Oskarsson organized an event to discuss non-relational
databases. Since that point, NoSQL has remained in the zeitgeist and there are numerous databases
that fit the bill.

2000s
Although the Internet industry experienced a decline in the early 2000s, database applications
continued to grow. New interactive applications were developed for PDAs, point-of-sale
transactions, and consolidation of vendors. Presently, the three leading database companies in the
western world are Microsoft, IBM, and Oracle.
17

UNIT: 2

Basic concepts
Constraints Keys, design issues
Entity Relationship diagram, Weak entity
sets
Extended E - R features, Design of an E –
R database schema
Reduction of an E – R Schema of tables
The unified modeling language UML

Topic1 – Basic concepts:

The ER model defines the conceptual view of a database. It works around real-world entities and
the associations among them. At view level, the ER model is considered a good option for
designing databases.
Entity
An entity can be a real-world object, either animate or inanimate, that can be easily identifiable.
For example, in a school database, students, teachers, classes, and courses offered can be
considered as entities. All these entities have some attributes or properties that give them their
identity.
An entity set is a collection of similar types of entities. An entity set may contain entities with
attribute sharing similar values. For example, a Students set may contain all the students of a
school; likewise a Teachers set may contain all the teachers of a school from all faculties. Entity
sets need not be disjoint.
Attributes
Entities are represented by means of their properties, called attributes. All attributes have values.
For example, a student entity may have name, class, and age as attributes.
There exists a domain or range of values that can be assigned to attributes. For example, a student's
name cannot be a numeric value. It has to be alphabetic. A student's age cannot be negative, etc.
Types of Attributes:
 Simple attribute − Simple attributes are atomic values, which cannot be divided further.
For example, a student's phone number is an atomic value of 10 digits.
 Composite attribute − Composite attributes are made of more than one simple attribute.
For example, a student's complete name may have first_name and last_name.
 Derived attribute − Derived attributes are the attributes that do not exist in the physical
database, but their values are derived from other attributes present in the database. For
example, average_salary in a department should not be saved directly in the database,
instead it can be derived. For another example, age can be derived from data_of_birth.
18

 Single-value attribute − Single-value attributes contain single value. For example −


Social_Security_Number.
 Multi-value attribute − Multi-value attributes may contain more than one values. For
example, a person can have more than one phone number, email_address, etc.
These attribute types can come together in a way like −

 simple single-valued attributes


 simple multi-valued attributes
 composite single-valued attributes
 composite multi-valued attributes

Entity-Set and Keys:


Key is an attribute or collection of attributes that uniquely identifies an entity among entity set.
For example, the roll_number of a student makes him/her identifiable among students.
 Super Key − A set of attributes (one or more) that collectively identifies an entity in an
entity set.
 Candidate Key − A minimal super key is called a candidate key. An entity set may have
more than one candidate key.
 Primary Key − A primary key is one of the candidate keys chosen by the database designer
to uniquely identify the entity set.
Relationship
The association among entities is called a relationship. For example, an employee works_at a
department, a student enrolls in a course. Here, Works_at and Enrolls are called relationships.
Relationship Set
A set of relationships of similar type is called a relationship set. Like entities, a relationship too can
have attributes. These attributes are called descriptive attributes.
Degree of Relationship
The number of participating entities in a relationship defines the degree of the relationship.

 Binary = degree 2
 Ternary = degree 3
 n-ary = degree

Mapping Cardinalities:
Cardinality defines the number of entities in one entity set, which can be associated with the
number of entities of other set via relationship set.
 One-to-one − One entity from entity set A can be associated with at most one entity of
entity set B and vice versa.

 One-to-many − One entity from entity set A can be associated with more than one entities
of entity set B however an entity from entity set B, can be associated with at most one
entity.
19

 Many-to-one − More than one entities from entity set A can be associated with at most one
entity of entity set B, however an entity from entity set B can be associated with more than
one entity from entity set A.

 Many-to-many − One entity from A can be associated with more than one entity from B
and vice versa.

Topic 2 - Key Constraints in DBMS:

 Constraints are nothing but the rules that are to be followed while entering data into
columns of the database table

 Constraints ensure that data entered by the user into columns must be within the criteria
specified by the condition
 For example, if you want to maintain only unique IDs in the employee table or if you want
to enter only age under 18 in the student table etc
 We have 5 types of key constraints in DBMS
o NOT NULL: ensures that the specified column doesn’t contain a NULL value.
o UNIQUE : provides a unique/distinct values to specified columns.
o DEFAULT: provides a default value to a column if none is specified.
o CHECK :checks for the predefined conditions before inserting the data inside the
table.
o PRIMARY KEY: it uniquely identifies a row in a table.
o FOREIGN KEY: ensures referential integrity of the relationship

1. Not Null :
20

 Null represents a record where data may be missing data or data for that record may be
optional
 Once not null is applied to a particular column, you cannot enter null values to that
column and restricted to maintain only some proper value other than null
 A not-null constraint cannot be applied at table level

Example
CREATE TABLE Orders (
OrderID int NOT NULL,
OrderNumber int NOT NULL,
PersonID int,
PRIMARY KEY (OrderID),
FOREIGN KEY (PersonID) REFERENCES Persons(PersonID)
);

2. Unique:

 Sometimes we need to maintain only unique data in the column of a database table, this is
possible by using a unique constraint
 Unique constraint ensures that all values in a column are unique

Example

CREATE TABLE Persons (


ID int UNIQUE,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int,
);

3. DEFAULT:

 Default clause in SQL is used to add default data to the columns


 When a column is specified as default with some value then all the rows will use the same
value i.e each and every time while entering the data we need not enter that value
 But default column value can be customized i.e it can be overridden when inserting a data
for that row based on the requirement.

Example

CREATE TABLE emp (


ID int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
21

Age int,
City varchar(255) DEFAULT 'hyderabad'
);

4. Check:

 Suppose in real-time if you want to give access to an application only if the age entered by
the user is greater than 18 this is done at the back-end by using a check constraint
 Check constraint ensures that the data entered by the user for that column is within the
range of values or possible values specified.

Example for check constraint

CREATE TABLE STUDENT (


ID int ,
Name varchar(255) ,
Age int,
CHECK (Age>=18)
);

5. Primary Key:
A primary key is a constraint in a table that uniquely identifies each row record in a database table
by enabling one or more the columns in the table as the primary key.

Creating a primary key

A particular column is made as a primary key column by using the primary key keyword followed
with the column name

CREATE TABLE EMP (


ID INT
NAME VARCHAR (20)
AGE INT
COURSE VARCHAR(10)
PRIMARY KEY (ID)
);

6. Foreign Key:

 The foreign key a constraint is a column or list of columns that points to the primary key

column of another table

 The main purpose of the foreign key is only those values are allowed in the present table

that will match the primary key column of another table.


22

Example to create a foreign key

Reference Table

CREATE TABLE CUSTOMERS1(


ID INT ,
NAME VARCHAR (20) ,
COURSE VARCHAR(10) ,
PRIMARY KEY (ID)
);

Child Table

CREATE TABLE CUSTOMERS2(


ID INT ,
MARKS INT,
REFERENCES CUSTOMERS1(ID)
);

Topic 4 - Entity Relationship diagram

ER (Entity Relationship) Diagram in DBMS


o ER model stands for an Entity-Relationship model. It is a high-level data model. This
model is used to define the data elements and relationship for a specified system.
o It develops a conceptual design for the database. It also develops a very simple and easy to
design view of data.
o In ER modeling, the database structure is portrayed as a diagram called an entity-
relationship diagram.

For example, Suppose we design a school database. In this database, the student will be an entity
with attributes like address, name, id, age, etc. The address can be another entity with attributes
like city, street name, pin code, etc and there will be a relationship between them.
23

Component of ER Diagram

Topic 5- Weak Entity Set:

 A weak entity set is an entity set that does not contain sufficient attributes to uniquely identify its
entities.
 In other words, a primary key does not exist for a weak entity set.
 However, it contains a partial key called as a discriminator.
 Discriminator can identify a group of entities from the entity set.
 Discriminator is represented by underlining with a dashed line.

NOTE-

 The combination of discriminator and primary key of the strong entity set makes it possible to
uniquely identify all entities of the weak entity set.
 Thus, this combination serves as a primary key for the weak entity set.
 Clearly, this primary key is not formed by the weak entity set completely.
24

Symbols Used-

 A double rectangle is used for representing a weak entity set.


 A double diamond symbol is used for representing the relationship that exists between the strong
and weak entity sets and this relationship is known as identifying relationship.
 A double line is used for representing the connection of the weak entity set with the relationship
set.
 Total participation always exists in the identifying relationship.

Example-

Consider the following ER diagram-

In this ER diagram,
 One strong entity set “Building” and one weak entity set “Apartment” are related to each other.
 Strong entity set “Building” has building number as its primary key.
 Door number is the discriminator of the weak entity set “Apartment”.
 This is because door number alone can not identify an apartment uniquely as there may be
several other buildings having the same door number.
 Double line between Apartment and relationship set signifies total participation.
 It suggests that each apartment must be present in at least one building.
 Single line between Building and relationship set signifies partial participation.
 It suggests that there might exist some buildings which has no apartment.

Topic 6 - extended E - R features:


25

 Specialization – The process of designating to sub grouping within an entity set is called
specialization. In above figure, the “person” is distinguish in to whether they are
“employee” or “customer”.

Formally in above figure specialization is depicted by a triangle component labelled (is a), means
the customer is a person.

Sometime this ISA (is a) referred as a superclass-subclass relationship. This is also used to
emphasize on to creating the distinct lower level entity sets.

 Generalization – generalization is relationship that exist between higher level entity set
and one or more lower level entity sets. Generalization synthesizes these entity sets into
single entity set.

 Higher level and lower level entity sets – This property is created by specialization and
generalization. The attributes of higher level entity sets are inherited by lower level entity
sets.

For example: In above figure “customers” and “employee” inherits the attributes of “person”.

 Attribute inheritance: When given entity set is involved as a lower entity set in only one
“ISA” (is a) relationship, it is referred as a single attribute inheritance. If lower entity set is
involved in more than one ISA (is a) relationship, it is referred as a multi attribute
inheritance.

 Aggregation: there is a one limitation with E-R model that it cannot express relationships
among relationships. So aggregation is an abstraction through which relationship is treated
as higher level entities.
26

Topic 7 - Design of an E – R database schema:

Types of Database Schema:

The database schema is divided into three types, which are:

1. Logical Schema
2. Physical Schema
3. View Schema

Topic 8 - Reduction of an E-R Schema to Tables:

A database that conforms to an E-R database schema can be represented by a collection of tables.
For each entity set and for each relationship set, there is a unique table. A table is a chart with rows
and columns. The set of all possible rows is the Cartesian product of all columns.
A row is also known as a tuple or a record. A table has an unlimited number of rows.
Each column is also known as a field.
Strong Entity Sets:
It is common practice for the table to have the same name as the entity set. There is one column for
each attribute.
Weak Entity Sets:
There is one column for each attribute, plus the attribute(s) the form the primary key of the strong
entity set that the weak entity set depends upon.
27

Relationship Sets:
We represent a relationship with a table that includes the attributes of each of the primary keys plus
any descriptive attributes (if any).
There is a problem that if one of the entities in the relationship is a weak entity set, there would be
no unique information in the relationship table, and therefore may be omitted.
Another problem can occur if there is an existence dependency. In that case, you can combine the
two tables.
Multivalued Attributes:
When an attribute is multivalued, remove the attribute from the table and create a new table with
the primary key and the attribute, but each value will be a separate row.
Generalization:
Create a table for the higher-level entity set. For each lower-level entity set, create a table with the attributes
for that specialization and include the primary key from the higher-le vel entity set.

Topic 9 - The unified modeling language UML:

Unified Modeling Language (UML) is a general purpose modelling language. The main aim of
UML is to define a standard way to visualize the way a system has been designed. It is quite
similar to blueprints used in other fields of engineering.
UML is not a programming language, it is rather a visual language. We use UML diagrams to
portray the behavior and structure of a system. UML helps software engineers, businessmen
and system architects with modelling, design and analysis. The Object Management Group
(OMG) adopted Unified Modelling Language as a standard in 1997. Its been managed by OMG
ever since. International Organization for Standardization (ISO) published UML as an approved
standard in 2005. UML has been revised over the years and is reviewed periodically. UML is
linked with object oriented design and analysis. UML makes the use of elements and forms
associations between them to form diagrams. Diagrams in UML can be broadly classified as:
1. Structural Diagrams – Capture static aspects or structure of a system. Structural Diagrams
include: Component Diagrams, Object Diagrams, Class Diagrams and Deployment
Diagrams.
2. Behavior Diagrams – Capture dynamic aspects or behavior of the system. Behavior
diagrams include: Use Case Diagrams, State Diagrams, Activity Diagrams and Interaction
Diagrams.

The image below shows the hierarchy of diagrams according to UML 2.2
28

DATABASE MANAGEMENT SYSTEMS Page 126

UNIT-4

TRANSACTION MANAGEMENT IN DBMS:


 A transaction is a set of logically related operations.
 Now that we understand what is transaction, we should understand what are the
problems associated with it.
 The main problem that can happen during a transaction is that the transaction can fail
before finishing the all the operations in the set. This can happen due to power failure,
system crash etc.
 This is a serious problem that can leave database in an inconsistent state. Assume that
transaction fail after third operation (see the example above) then the amount would
be deducted from your account but your friend will not receive it.
To solve this problem, we have the following two operations
Commit: If all the operations in a transaction are completed successfully then commit those
changes to the database permanently.
Rollback: If any of the operation fails then rollback all the changes done by previous
operations.
STATES OF TRANSACTION
Transactions can be implemented using SQL queries and Server. In the below-given
diagram, you can see how transaction states works.

You might also like