DBMS Unit - 1
DBMS Unit - 1
For better understanding watch this youtube playlist along with the
topics covered in this written material--
https://youtube.com/playlist?list=PLxCzCOWd7aiFAN6I8CuViBuCdJgiOkT2Y
What is Data?
Data is a collection of a distinct small unit of information. It can be used in a variety
of forms like text, numbers, media, bytes, etc. it can be stored in pieces of paper or
electronic memory, etc.
Word 'Data' originated from the word 'datum' that means 'single piece of
information.' It is the plural of the word datum.
In computing, Data is information that can be translated into a form for efficient
movement and processing. Data is interchangeable.
What is Database?
A database is an organized collection of data, so that it can be easily accessed and
managed.
You can organize data into tables, rows, columns, and index it to make it easier to
find relevant information.
Database handlers create a database in such a way that only one set of software
programs provides access of data to all the users.
There are many dynamic websites on the World Wide Web nowadays which are
handled through databases. For example, a model that checks the availability of
rooms in a hotel. It is an example of a dynamic website that uses a database.
There are many databases available like MySQL, Sybase, Oracle, MongoDB,
Informix, PostgreSQL, SQL Server, etc.
https://cgccollegespace.live
SQL or Structured Query Language is used to operate on the data stored in a
database. SQL depends on relational algebra and tuple relational calculus.
● DBMS provides the interface to perform the various operations like creation,
● DBMS allows the user to create their databases as per their requirement.
● DBMS accepts the request from the application and provides specific data
● DBMS contains the group of programs which acts according to the user
instruction.
Advantage of DBMS
Controls redundancy
It stores all the data in a single database file, so it can control data redundancy.
Data sharing
Backup
https://cgccollegespace.live
It providesBackup and recovery subsystem. This recovery system creates automatic
data from system failure and restores data if required.
Disadvantage of DBMS
Size
Cost
DBMS requires a high-speed data processor and larger memory to run DBMS
software, so it is costly.
Complexity
● Table
● Record/ Tuple
● Instance
● Schema
● Keys
https://cgccollegespace.live
An RDBMS is a tabular DBMS that maintains the security, integrity, accuracy, and
consistency of the data.
DBMS, the user is not required to system, the user has to write the procedures
DBMS gives an abstract view of data File system provides the detail of the data
DBMS provides a crash recovery File system doesn't have a crash mechanism,
mechanism, i.e., DBMS protects the i.e., if the system crashes while entering
user from system failure. some data, then the content of the file will be
lost.
DBMS provides a good protection It is very difficult to protect a file under the
DBMS contains a wide variety of File system can't efficiently store and retrieve
DBMS takes care of Concurrent In the File system, concurrent access has
access of data using some form of many problems like redirecting the file while
information.
https://cgccollegespace.live
DBMS Architecture
● The DBMS design depends upon its architecture. The basic client/server
database servers and other components that are connected with networks.
● DBMS architecture depends upon how users are connected to the database to
1-Tier Architecture
● In this architecture, the database is directly available to the user. It means
the user can directly sit on the DBMS and uses it.
● Any changes done here will directly be done on the database itself. It doesn't
https://cgccollegespace.live
● The 1-Tier architecture is used for development of the local application, where
programmers can directly communicate with the database for the quick
response.
2-Tier Architecture
● The 2-Tier architecture is the same as basic client-server. In the two-tier
architecture, applications on the client end can directly communicate with the
database at the server side. For this interaction, API's like: ODBC, JDBC are
used.
● The user interfaces and application programs are run on the client-side.
three-level architecture.
https://cgccollegespace.live
● 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
● Mapping is not good for small DBMS because it takes more time.
https://cgccollegespace.live
● In External / Conceptual mapping, it is necessary to transform the request
1. Internal Level
● The internal level has an internal schema which describes the physical storage
● It uses the physical data model. It is used to define that how the data will be
stored in a block.
detail.
2. Conceptual Level
● The conceptual level describes what data are to be stored in the database and
3. External Level
https://cgccollegespace.live
● At the external level, a database contains several schemas that sometimes
the database.
● Each view schema describes the database part that a particular user group is
interested and hides the remaining database from that user group.
● The view schema describes the end user interaction with database systems.
Data Abstraction
Database systems comprise complex data-structures. In order to make the
system efficient in terms of retrieval of data, and reduce complexity in terms of
usability of users, developers use abstraction i.e. hide irrelevant details from
the users. This approach simplifies database design.
Physical: This is the lowest level of data abstraction. It tells us how the
data is actually stored in memory. The access methods like sequential or
random access and file organisation methods like B+ trees, hashing used for
the same. Usability, size of memory, and the number of times the records are
factors which we need to know while designing the database.
Logical: This level comprises the information that is actually stored in the
database in the form of tables. It also stores the relationship among the data
entities in relatively simple structures. At this level, the information available to
the user at the view level is unknown.
https://cgccollegespace.live
We can store the various attributes of an employee and relationships, e.g. with
the manager can also be stored.
View: This is the highest level of abstraction. Only a part of the actual
database is viewed by the users. This level exists to ease the accessibility of
the database by an individual user. Users view data in the form of rows and
columns. Tables and relations are used to store data. Multiple views of the
same database may exist. Users can just view the data and interact with the
database, storage and implementation details are hidden from them.
https://cgccollegespace.live
Data Independence
● Data independence can be explained using the three-schema
architecture.
https://cgccollegespace.live
schema. It refers to the characteristic of being able to modify the
affected.
https://cgccollegespace.live
Database Language
● A DBMS has appropriate languages and interfaces to express database
● Database languages can be used to read, store and update the data in
the database.
database.
● Using the DDL statements, you can create the skeleton of the
database.
https://cgccollegespace.live
● Data definition language is used to store the information of metadata
like the number of tables and schemas, their names, indexes, columns
in each table, constraints, etc.
These commands are used to update the database schema that's why they
https://cgccollegespace.live
2. Data Manipulation Language
DML stands for Data Manipulation Language. It is used for accessing and
manipulating data in a database. It handles user requests.
operations.
subprogram.
https://cgccollegespace.live
3. Data Control Language
(But in Oracle database, the execution of data control language does not
● https://www.geeksforgeeks.org/difference-between-grant-and-revoke/
#:~:text=SQL%20Grant%20command%20is%20specifically,permissio
ns%20for%20other%20users%20too.
or
● https://www.studytonight.com/dbms/dcl-command.php
There are the following operations which have the authorization of Revoke:
https://cgccollegespace.live
4. Transaction Control Language
TCL is used to run the changes made by the DML statement. TCL can be
grouped into a logical transaction.
https://www.geeksforgeeks.org/sql-transactions/
or
https://www.tutorialspoint.com/sql/sql-transactions.htm
Data Models
Data Model is the modeling of the data description, data semantics, and consistency
constraints of the data. It provides the conceptual tools for describing the design of
a database at each level of data abstraction. A database model shows the logical
structure of a database, including the relationships and constraints that determine how data
can be stored and accessed. Individual database models are designed based on the rules
https://cgccollegespace.live
and concepts of whichever broader data model the designers adopt. Most data models can
be represented by an accompanying database diagram.
Hierarchical model
The hierarchical model organizes data into a tree-like structure, where each record has a single
parent or root. Sibling records are sorted in a particular order. That order is used as the physical
order for storing the database. This model is good for describing many real-world relationships.
This model was primarily used by IBM’s Information Management Systems in the 60s and 70s,
but they are rarely seen today due to certain operational inefficiencies.
Hierarchical data model is the oldest type of data model. It was developed by IBM in 1968. It
organizes data in tree-like structure. Hierarchical model consists of following :
https://cgccollegespace.live
In the above figure, Electronics is root node which has two children i.e. Televisions and
Portable Electronics. These two have further children for which they act as parents. For
example: Television has children as Tube, LCD and Plasma, for these three Television act
as parents. It follows one to many relationships.
ADVANTAGES:
• Hierarchical Model is simple to construct and operate on depicts a set of one-to-many (1:M)
relationships between a parent and its children segments
DISADVANTAGES:
• Navigational and procedural nature of processing
• Inconsistency during updation of database because when parent node is deleted that
results in deletion of child node force fully.
• Not flexible.
https://cgccollegespace.live
Commercially available Hierarchical
Database system:
• IBM’s information management system
Relational model
The most common model, the relational model sorts data into tables, also known as relations,
each of which consists of columns and rows. Each column lists an attribute of the entity in
question, such as price, zip code, or birth date. Together, the attributes in a relation are called a
domain. A particular attribute or combination of attributes is chosen as a primary key that can be
referred to in other tables, when it’s called a foreign key.
Each row, also called a tuple, includes data about a specific instance of the entity in question,
such as a particular employee.
The model also accounts for the types of relationships between those tables, including
one-to-one, one-to-many, and many-to-many relationships. Here’s an example:
https://d2slcw3kip6qmk.cloudfront.net/marketing/pages/chart/seo/database/discovery/relational-
model.svg
Within the database, tables can be normalized, or brought to comply with normalization rules that
make the database flexible, adaptable, and scalable. When normalized, each piece of data is
atomic, or broken into the smallest useful pieces.
Relational databases are typically written in Structured Query Language (SQL). The model was
introduced by E.F. Codd in 1970.
https://cgccollegespace.live
The Relational Model represents how data is stored in Relational Databases.
A relational database stores data in the form of relations (tables). Consider a
relation STUDENT with attributes ROLL_NO, NAME, ADDRESS, PHONE and
AGE shown in Table 1.
STUDENT
4 SURESH DELHI 18
https://cgccollegespace.live
IMPORTANT TERMINOLOGIES
https://cgccollegespace.live
ROLL_NO
ADVANTAGES:-
• Ease of use: The revision of any information as tables consisting of rows and
columns is quite natural and therefore even first time users find it attractive.
https://cgccollegespace.live
2. Flexibility: Different tables from which information has to be linked and extracted can be
easily manipulated by operators such as project and join to give information in the form in which
it is desired.
3. Precision: The usage of relational algebra and relational calculus in the manipulation of
the relations between the tables ensures that there is no ambiguity.
4. Security: Security control and authorization can also be implemented more easily by
moving sensitive attributes in a given table into a separate relation with its own authorization
controls.
5. Structural Independence
6. Easy to Design
Disadvantage:-
• A major constraint and therefore disadvantage in the use of relational database systems is
machine performance. If the number of tables between which relationships to be established are
large and the tables themselves are voluminous, the performance in responding to queries is
definitely degraded.
• Need more powerful computing H/W and data storage devices that increase the cost and H/W
overhead.
https://cgccollegespace.live
Network Data Model :
It is the advanced version of the hierarchical data model. To organize data it
uses directed graphs instead of the tree-structure. In this child can have more
than one parent. It uses the concept of the two data structures i.e. Records
and Sets.
ADVANTAGES
https://cgccollegespace.live
• Ability to handle more relationship types: The network model can handle the one-to-many and
many-to-many relationships.
• Ease of data access: In the network database terminology, a relationship is a set. Each set
comprises of two types of records.- an owner record and a member record, In a network model
an application can access an owner record and all the member records within a set..
• Data Independence: The network model draws a clear line of demarcation between programs
and the complex physical storage details. The application programs work independently of the
data. Any changes made in the data characteristics do not affect the application program.
DISADVANTAGES
https://cgccollegespace.live
This model defines a database as a collection of objects, or reusable software elements, with
associated features and methods. There are several kinds of object-oriented databases:
A multimedia database incorporates media, such as images, that could not be stored in a
relational database.
A hypertext database allows any object to link to any other object. It’s useful for organizing lots
of disparate data, but it’s not ideal for numerical analysis.
The object-oriented database model is the best known post-relational database model, since it
incorporates tables, but isn’t limited to tables. Such models are also known as hybrid database
models.Object oriented data model is based upon real world situations. These
situations are represented as objects, with different attributes. All these objects have
multiple relationships between them.
The real world entities and situations are represented as objects in the Object
oriented database model.
Every object has certain characteristics. These are represented using Attributes. The
behaviour of the objects is represented using Methods.
Class
Similar attributes and methods are grouped together using a class. An object can be
called as an instance of the class.
Inheritance
A new class can be derived from the original class. The derived class contains
attributes and methods of the original class as well as its own.
https://cgccollegespace.live
Example
An Example of the Object Oriented data model is −
Shape, Circle, Rectangle and Triangle are all objects in this model.
The objects Circle, Rectangle and Triangle inherit from the object Shape.
https://cgccollegespace.live
Entity-Relationship Data Model: An ER model is the logical
representation of data as objects and relationships among them. These
objects are known as entities, and relationship is an association among these
entities. This model was designed by Peter Chen and published in 1976
papers. It was widely used in database designing. A set of attributes describe
the entities. For example, student_name, student_id describes the 'student'
entity. A set of the same type of entities is known as an 'Entity set', and the set
of the same type of relationships is known as 'relationship set'.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.
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.
https://cgccollegespace.live
Component of ER Diagram
1. Entity:
An entity may be any object, class, person or place. In the ER diagram, an entity
can be represented as rectangles.
https://cgccollegespace.live
a. Weak Entity
An entity that depends on another entity called a weak entity. The weak entity
doesn't contain any key attribute of its own. The weak entity is represented by a
double rectangle.
2. Attribute
The attribute is used to describe the property of an entity. Eclipse is used to
represent an attribute.
For example, id, age, contact number, name, etc. can be attributes of a student.
a. Key Attribute
https://cgccollegespace.live
The key attribute is used to represent the main characteristics of an entity. It
represents a primary key. The key attribute is represented by an ellipse with the
text underlined.
b. Composite Attribute
c. Multivalued Attribute
https://cgccollegespace.live
An attribute can have more than one value. These attributes are known as a
multivalued attribute. The double oval is used to represent multivalued attribute.
For example, a student can have more than one phone number.
d. Derived Attribute
An attribute that can be derived from other attribute is known as a derived attribute.
It can be represented by a dashed ellipse.
For example, A person's age changes over time and can be derived from another
attribute like Date of birth.
3. Relationship
https://cgccollegespace.live
A relationship is used to describe the relation between entities. Diamond or rhombus
is used to represent the relationship.
a. One-to-One Relationship
When only one instance of an entity is associated with the relationship, then it is
known as one to one relationship.
For example, A female can marry to one male, and a male can marry to one
female.
b. One-to-many relationship
When only one instance of the entity on the left, and more than one instance of an
entity on the right associates with the relationship then this is known as a
one-to-many relationship.
For example, Scientist can invent many inventions, but the invention is done by
the only specific scientist.
https://cgccollegespace.live
c. Many-to-one relationship
When more than one instance of the entity on the left, and only one instance of an
entity on the right associates with the relationship then it is known as a
many-to-one relationship.
For example, Student enrolls for only one course, but a course can have many
students.
d. Many-to-many relationship
When more than one instance of the entity on the left, and more than one instance
of an entity on the right associates with the relationship then it is known as a
many-to-many relationship.
For example, Employee can assign by many projects and project can have many
employees.
https://cgccollegespace.live
Integrity Constraints
● Integrity constraints are a set of rules. It is used to maintain the quality of
information.
● Integrity constraints ensure that the data insertion, updating, and other
affected.
database.
1. Domain constraints
● Domain constraints can be defined as the definition of a valid set of values for
an attribute.
https://cgccollegespace.live
● The data type of domain includes string, character, integer, time, date,
corresponding domain.
Example:
● The entity integrity constraint states that primary key value can't be null.
● This is because the primary key value is used to identify individual rows in
relation and if the primary key has a null value, then we can't identify those
rows.
● A table can contain a null value other than the primary key field.
Example:
https://cgccollegespace.live
3. Referential Integrity Constraints
Primary Key of Table 2, then every value of the Foreign Key in Table 1 must
Example:
4. Key constraints
● Keys are the entity set that is used to identify an entity within its entity set
uniquely.
https://cgccollegespace.live
● An entity set can have multiple keys, but out of which one key will be the
primary key. A primary key can contain a unique and null value in the
relational table.
Example:
UNIT - 1 COMPLETED
https://cgccollegespace.live
https://cgccollegespace.live