Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
23 views52 pages

Unit 1 Basic of DBMS

A Database Management System (DBMS) is software designed to manage, organize, and retrieve data efficiently, playing a crucial role in modern computing for data-driven decision-making. It minimizes data redundancy, ensures data integrity and security, and supports concurrent access, with various types including Relational, NoSQL, and Object-Oriented DBMS. The document also contrasts DBMS with file systems, highlighting advantages such as better data organization, security, and backup capabilities, while also discussing its architecture and applications across different sectors.

Uploaded by

shuklaanchal543
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views52 pages

Unit 1 Basic of DBMS

A Database Management System (DBMS) is software designed to manage, organize, and retrieve data efficiently, playing a crucial role in modern computing for data-driven decision-making. It minimizes data redundancy, ensures data integrity and security, and supports concurrent access, with various types including Relational, NoSQL, and Object-Oriented DBMS. The document also contrasts DBMS with file systems, highlighting advantages such as better data organization, security, and backup capabilities, while also discussing its architecture and applications across different sectors.

Uploaded by

shuklaanchal543
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

Introduction of DBMS (Database Management System):-

A Database Management System (DBMS) is a software solution designed to


efficiently manage, organize, and retrieve data in a structured manner. It serves as a critical
component in modern computing, enabling organizations to store, manipulate, and secure their data
effectively. From small applications to enterprise systems, DBMS plays a vital role in supporting data-
driven decision-making and operational efficiency.

In this article, we will explain the key concepts, benefits, and types of Database Management
Systems (DBMS). We’ll also cover how DBMS solutions work, why they’re important for modern
applications, and what features they offer to ensure data integrity, security, and efficient retrieval.

What is a DBMS?

A DBMS is a system that allows users to create, modify, and query databases while ensuring data
integrity, security, and efficient data access. Unlike traditional file systems, DBMS minimizes data
redundancy, prevents inconsistencies, and simplifies data management with features like concurrent
access and backup mechanisms. It organizes data into tables, views, schemas, and reports, providing
a structured approach to data management.

Example:

A university database can store and manage student information, faculty records, and administrative
data, allowing seamless retrieval, insertion, and deletion of information as required.

Key Features of DBMS

1. Data Modeling: Tools to create and modify data models, defining the structure and
relationships within the database.

2. Data Storage and Retrieval: Efficient mechanisms for storing data and executing queries to
retrieve it quickly.

3. Concurrency Control: Ensures multiple users can access the database simultaneously
without conflicts.

4. Data Integrity and Security: Enforces rules to maintain accurate and secure data, including
access controls and encryption.

5. Backup and Recovery: Protects data with regular backups and enables recovery in case of
system failures

6. Types of DBMS
7. There are several types of Database Management Systems (DBMS), each tailored
to different data structures, scalability requirements, and application needs. The
most common types are as follows:-
1. Relational Database Management System (RDBMS)
RDBMS organizes data into tables (relations) composed of rows and columns. It
uses primary keys to uniquely identify rows and foreign keys to establish
relationships between tables. Queries are written in SQL (Structured Query
Language), which allows for efficient data manipulation and retrieval.
Examples: MySQL, Oracle, Microsoft SQL Server and Postgre SQL.
2. NoSQL DBMS
NoSQL systems are designed to handle large-scale data and provide high
performance for scenarios where relational models might be restrictive. They
store data in various non-relational formats, such as key-value
pairs, documents, graphs, or columns. These flexible data models enable rapid
scaling and are well-suited for unstructured or semi-structured data.
Examples: MongoDB, Cassandra, DynamoDB and Redis.
3. Object-Oriented DBMS (OODBMS)
OODBMS integrates object-oriented programming concepts into the database
environment, allowing data to be stored as objects. This approach supports
complex data types and relationships, making it ideal for applications requiring
advanced data modeling and real-world simulations.
Examples: ObjectDB, db4o.
Database Languages
Database languages are specialized sets of commands and instructions used to
define, manipulate, and control data within a database. Each language type plays
a distinct role in database management, ensuring efficient storage, retrieval, and
security of data. The primary database languages include:
1. Data Definition Language (DDL)
DDL is the short name for Data Definition Language, which deals with database
schemas and descriptions, of how the data should reside in the database.
• CREATE: to create a database and its objects like (table, index, views, store
procedure, function, and triggers)
• ALTER: alters the structure of the existing database
• DROP: delete objects from the database
• TRUNCATE: remove all records from a table, including all spaces allocated for the
records are removed
• COMMENT: add comments to the data dictionary
• RENAME: rename an object
2. Data Manipulation Language (DML)
DML focuses on manipulating the data stored in the database, enabling users to
retrieve, add, update, and delete data.
• SELECT: retrieve data from a database
• INSERT: insert data into a table
• UPDATE: updates existing data within a table
• DELETE: Delete all records from a database table
• MERGE: UPSERT operation (insert or update)
• CALL: call a PL/SQL or Java subprogram
• EXPLAIN PLAN: interpretation of the data access path
• LOCK TABLE: concurrency Control
3. Data Control Language (DCL)
DCL commands manage access permissions, ensuring data security by controlling
who can perform certain actions on the database.
• GRANT: Provides specific privileges to a user (e.g., SELECT, INSERT).
• REVOKE: Removes previously granted permissions from a user.
4. Transaction Control Language (TCL)
TCL commands oversee transactional data to maintain consistency, reliability, and
atomicity.
• ROLLBACK: Undoes changes made during a transaction.
• COMMIT: Saves all changes made during a transaction.
• SAVEPOINT: Sets a point within a transaction to which one can later roll back.
5. Data Query Language (DQL)
DQL is a subset of DML, specifically focused on data retrieval.
• SELECT: The primary DQL command, used to query data from the database without
altering its structure or contents.
Paradigm Shift from File System to DBMS
Before the advent of modern Database Management Systems (DBMS), data was
managed using basic file systems on hard drives. While this approach allowed
users to store, retrieve, and update files as needed, it came with numerous
challenges.
A typical example can be seen in a file-based university management system,
where data was stored in separate sections such as Departments, Academics,
Results, Accounts, and Hostels. Certain information like student names and
phone numbers was repeated across multiple files, leading to the following
issues:
1. Redundancy of data
When the same data exists in multiple places, any update must be manually
repeated everywhere. For instance, if a student changes their phone number, it
must be updated across all sections. Failure to do so leads to unnecessary
duplication and wasted storage.
2. Inconsistency of Data
Data is said to be inconsistent if multiple copies of the same data do not match
each other. If the Phone number is different in Accounts Section and Academics
Section, it will be inconsistent. Inconsistency may be because of typing errors or
not updating all copies of the same data.
3. Complex Data Access
A user should know the exact location of the file to access data, so the process is
very cumbersome and tedious. If the user wants to search the student hostel
allotment number of a student from 10000 unsorted students’ records, how
difficult it can be.
4. Lack of Security
File systems provided limited control over who could access certain data. A
student who gained access to a file with grades might easily alter it without
proper authorization, compromising data integrity.
5. No Concurrent Access
File systems were not designed for multiple users working at the same time. If
one user was editing a file, others had to wait, which hindered collaboration and
slowed down workflows.
6. No Backup and Recovery
File systems lacked built-in mechanisms for creating backups or recovering data
after a loss. If a file was accidentally deleted or corrupted, there was no easy way
to restore it, potentially causing permanent data loss.
Advantages of DBMS
1. Data organization: A DBMS allows for the organization and storage of data in a
structured manner, making it easy to retrieve and query the data as needed.
2. Data integrity: A DBMS provides mechanisms for enforcing data integrity
constraints, such as constraints on the values of data and access controls that
restrict who can access the data.
3. Concurrent access: A DBMS provides mechanisms for controlling concurrent
access to the database, to ensure that multiple users can access the data without
conflicting with each other.
4. Data security: A DBMS provides tools for managing the security of the data, such
as controlling access to the data and encrypting sensitive data.
5. Backup and recovery: A DBMS provides mechanisms for backing up and recovering
the data in the event of a system failure.
6. Data sharing: A DBMS allows multiple users to access and share the same data,
which can be useful in a collaborative work environment.
Disadvantages of DBMS
1. Complexity: DBMS can be complex to set up and maintain, requiring specialized
knowledge and skills.
2. Performance overhead: The use of a DBMS can add overhead to the performance
of an application, especially in cases where high levels of concurrency are required.
3. Scalability: The use of a DBMS can limit the scalability of an application, since it
requires the use of locking and other synchronization mechanisms to ensure data
consistency.
4. Cost: The cost of purchasing, maintaining and upgrading a DBMS can be high,
especially for large or complex systems.
5. Limited Use Cases: Not all use cases are suitable for a DBMS, some solutions don’t
need high reliability, consistency or security and may be better served by other
types of data storage.
Applications of DBMS
1. Enterprise Information: Sales, accounting, human resources, Manufacturing, online
retailers.
2. Banking and Finance Sector: Banks maintaining the customer details, accounts,
loans, banking transactions, credit card transactions. Finance: Storing the
information about sales and holdings, purchasing of financial stocks and bonds.
3. University: Maintaining the information about student course enrolled information,
student grades, staff roles.
4. Airlines: Reservations and schedules.
5. Telecommunications: Prepaid, postpaid bills maintance.

database system vs file system:-


A file system and a DBMS are two kinds of data management systems that are
used in different capacities and possess different characteristics. A File System is
a way of organizing files into groups and folders and then storing them in a
storage device. It provides the media that stores data as well as enables users to
perform procedures such as reading, writing, and even erasure.
On the other hand, DBMS is a more elaborate software application that is solely
charged with the responsibility of managing large amounts of structured data. It
provides functionalities such as query, index, transaction, as well as data integrity.
Although the file system serves well for the purpose of data storage for
applications where data is to be stored simply and does not require any great
organization, DBMS is more appropriate for applications where data needs to be
stored and optimized for organizational and structural needs, security, etc.
File System
The file system is basically a way of arranging the files in a storage medium like a
hard disk. The file system organizes the files and helps in the retrieval of files
when they are required. File systems consist of different files which are grouped
into directories. The directories further contain other folders and files. The file
system performs basic operations like management, file naming, giving access
rules, etc.
Example: NTFS(New Technology File System) , EXT(Extended File System).

DBMS ( Database Management System)


Database Management System is basically software that manages the collection
of related data. It is used for storing data and retrieving the data effectively when
it is needed. It also provides proper security measures for protecting the data from
unauthorized access. In Database Management System the data can be fetched
by SQL queries and relational algebra. It also provides mechanisms for data
recovery and data backup.
Example:
Oracle, MySQL, MS SQL server.

Difference Between File System and DBMS:-

Basics File System DBMS

The file system is a way of arranging


DBMS is software for managing the
the files in a storage medium within
database.
Structure a computer.

Data Redundant data can be present in a


In DBMS there is no redundant data.
Redundancy file system.
Basics File System DBMS

It doesn’t provide Inbuilt mechanism


It provides in house tools for backup
Backup and for backup and recovery of data if it
and recovery of data even if it is lost.
Recovery is lost.

Query There is no efficient query Efficient query processing is there in


processing processing in the file system. DBMS.

There is more data consistency


There is less data consistency in the
because of the process
file system.
Consistency of normalization .

It is less complex as compared to It has more complexity in handling as


Complexity DBMS. compared to the file system.

Security File systems provide less security in DBMS has more security mechanisms
Constraints comparison to DBMS. as compared to file systems.

It has a comparatively higher cost


It is less expensive than DBMS.
Cost than a file system.

In DBMS data independence exists,


mainly of two types:
There is no data independence.
1) Logical Data Independence .
Data
Independence 2)Physical Data Independence.

Only one user can access data at a Multiple users can access data at a
User Access time. time.

The users are not required to write The user has to write procedures for
Meaning procedures. managing databases

Data is distributed in many files. So, Due to centralized nature data


Sharing it is not easy to share data. sharing is easy
Basics File System DBMS

Data It give details of storage and It hides the internal details


Abstraction representation of data of Database

Integrity Integrity Constraints are difficult to Integrity constraints are easy to


Constraints implement implement

To access data in a file , user requires


attributes such as file name, file No such attributes are required.
Attribute s location.

Example Cobol , C++ Oracle , SQL Server

The main difference between a file system and a DBMS (Database Management System) is the way
they organize and manage data.

1. File systems are used to manage files and directories, and provide basic operations for
creating, deleting, renaming, and accessing files. They typically store data in a hierarchical
structure, where files are organized in directories and subdirectories. File systems are simple
and efficient, but they lack the ability to manage complex data relationships and ensure data
consistency.

2. On the other hand, DBMS is a software system designed to manage large amounts of
structured data, and provide advanced operations for storing, retrieving, and manipulating
data. DBMS provides a centralized and organized way of storing data, which can be accessed
and modified by multiple users or applications. DBMS offers advanced features like data
validation, indexing , transactions, concurrency control , and backup and recovery
mechanisms. DBMS ensures data consistency, accuracy, and integrity by enforcing data
constraints, such as primary keys, foreign keys, and data types.

In summary, file systems are suitable for managing small amounts of unstructured data , while DBMS
is designed for managing large amounts of structured data, and offers more advanced features for
ensuring data integrity, security, and performance.

Database sysarm concepts and architecture:-


A Database stores a lot of critical information to access data quickly and securely. Hence it is
important to select the correct architecture for efficient data management. Database Management
System (DBMS) architecture is crucial for efficient data management and system performance. It
helps users to get their requests done while connecting to the database. It focuses on how the
database is designed, built and maintained, shaping how users access and interact with it. This article
explains different DBMS architectures like client/server systems and database models.

Types of DBMS Architecture


There are several types of DBMS Architecture that we use according to the usage requirements.
Types of DBMS Architecture are discussed here.

• 1-Tier Architecture

• 2-Tier Architecture

• 3-Tier Architecture

1-Tier Architecture

In 1-Tier Architecture the database is directly available to the user, the user can directly sit on the
DBMS and use it that is, the client, server, and Database are all present on the same machine. This
setup is simple and is often used in personal or standalone applications where the user interacts
directly with the database.
For Example: A Microsoft Excel spreadsheet is a great example of one-tier architecture.

• Everything—the user interface, application logic and data is handled on a single system.

• The user directly interacts with the application, performs operations like calculations or data
entry and stores data locally on the same machine.

This architecture is simple and works well for personal, standalone applications where no external
server or network connection is needed.

Advantages of 1-Tier Architecture

Below mentioned are the advantages of 1-Tier Architecture.

• Simple Architecture: 1-Tier Architecture is the most simple architecture to set up, as only a
single machine is required to maintain it.

• Cost-Effective: No additional hardware is required for implementing 1-Tier Architecture,


which makes it cost-effective.

• Easy to Implement: 1-Tier Architecture can be easily deployed, and hence it is mostly used in
small projects.
2-Tier Architecture

The 2-tier architecture is similar to a basic client-server model . The application at the client end
directly communicates with the database on 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 to communicate with
the DBMS.
For Example: A Library Management System used in schools or small organizations is a classic
example of two-tier architecture.

1. Client Layer (Tier 1): This is the user interface that library staff or users interact with. For
example they might use a desktop application to search for books, issue them, or check due
dates.

2. Database Layer (Tier 2): The database server stores all the library records such as book
details, user information, and transaction logs.

The client layer sends a request (like searching for a book) to the database layer which processes it
and sends back the result. This separation allows the client to focus on the user interface, while the
server handles data storage and retrieval.

Advantages of 2-Tier Architecture

• Easy to Access: 2-Tier Architecture makes easy access to the database, which makes fast
retrieval.

• Scalable: We can scale the database easily, by adding clients or upgrading hardware.

• Low Cost: 2-Tier Architecture is cheaper than 3-Tier Architecture and Multi-Tier
Architecture .

• Easy Deployment: 2-Tier Architecture is easier to deploy than 3-Tier Architecture.

• Simple: 2-Tier Architecture is easily understandable as well as simple because of only two
components.
3-Tier Architecture

In 3-Tier Architecture , 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 the server and the client. This type of architecture is used in the case of
large web applications.
For Example: E-commerce Store
User: You visit an online store, search for a product and add it to your cart.
Processing: The system checks if the product is in stock, calculates the total price and applies any
discounts.
Database: The product details, your cart and order history are stored in the database for future
reference.

Advantages of 3-Tier Architecture

• Enhanced scalability: Scalability is enhanced due to the distributed deployment of


application servers. Now, individual connections need not be made between the client and
server.

• Data Integrity: 3-Tier Architecture maintains Data Integrity. Since there is a middle layer
between the client and the server, data corruption can be avoided/removed.

• Security: 3-Tier Architecture Improves Security. This type of model prevents direct
interaction of the client with the server thereby reducing access to unauthorized data.

Disadvantages of 3-Tier Architecture

• More Complex: 3-Tier Architecture is more complex in comparison to 2-Tier Architecture.


Communication Points are also doubled in 3-Tier Architecture.

• Difficult to Interact: It becomes difficult for this sort of interaction to take place due to the
presence of middle layers.
views of data-levels of 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.

Level of Abstraction in a DBMS

There are mainly 3 levels of data abstraction:

• Physical or Internal Level

• Logical or Conceptual Level

• View or External Level

Physical or Internal Level

This is the lowest level of data abstraction. It tells us how the data is actually stored in memory.
Access methods like sequential or random access and file organization methods like B+ trees and
hashing are used for the same. Usability, size of memory, and the number of times the records are
factors that we need to know while designing the database.
Suppose we need to store the details of an employee. Blocks of storage and the amount of memory
used for these purposes are kept hidden from the user.

Logical or Conceptual Level

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.
We can store the various attributes of an employee and relationships, e.g. with the manager can also
be stored.

The logical level thus describes the entire database in terms of a small number of relatively simple
structures. Although implementation of the simple structures at the logical level may involve
complex physical-level structures, the user of the logical level does not need to be aware of this
complexity. This is referred to as physical data independence. Database administrators, who must
decide what information to keep in the database, use the logical level of abstraction.

View or External Level

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. Even though the logical level uses simpler structures,
complexity remains because of the variety of information stored in a large database. Many users of
the database system do not need all this information; instead, they need to access only a part of the
database. The view level of abstraction exists to simplify their interaction with the system

Example: In case of storing customer data,

• Physical level – it will contains block of storages (bytes,GB,TB,etc)

• Logical level – it will contain the fields and the attributes of data.
• View level – it works with CLI or GUI access of database

The main purpose of data abstraction is to achieve data independence in order to save the time and
cost required when the database is modified or altered.

Data Independence

Data Independence is mainly defined as a property of DBMS that helps you to change the database
schema at one level of a system without requiring to change the schema at the next level. it helps to
keep the data separated from all program that makes use of it.
We have namely two levels of data independence arising from these levels of abstraction:

• Physical level data independence

• Logical level data independence


Physical Level Data Independence

It refers to the characteristic of being able to modify the physical schema without any alterations to
the conceptual or logical schema, done for optimization purposes, e.g., the Conceptual structure of
the database would not be affected by any change in storage size of the database system server.
Changing from sequential to random access files is one such example. These alterations or
modifications to the physical structure may include:

• Utilizing new storage devices.

• Modifying data structures used for storage.

• Altering indexes or using alternative file organization techniques etc.

Logical Level Data Independence

It refers characteristic of being able to modify the logical schema without affecting the external
schema or application program. The user view of the data would not be affected by any changes to
the conceptual view of the data. These changes may include insertion or deletion of attributes,
altering table structures entities or relationships to the logical schema, etc.
Data models:-
A Data Model in Database Management System (DBMS) is the concept of tools that are developed
to summarize the description of the database. Data Models provide us with a transparent picture of
data which helps us in creating an actual database. It shows us from the design of the data to its
proper implementation of data.

Types of Relational Models

1. Conceptual Data Model

2. Representational Data Model

3. Physical Data Model

It is basically classified into 3 types:-

1. Conceptual Data Model

The conceptual data model describes the database at a very high level and is useful to understand
the needs or requirements of the database. It is this model, that is used in the requirement-gathering
process i.e. before the Database Designers start making a particular database. One such popular
model is the entity/relationship model (ER model). The E/R model specializes in entities,
relationships, and even attributes that are used by database designers. In terms of this concept, a
discussion can be made even with non-computer science(non-technical) users and stakeholders, and
their requirements can be understood.

Entity-Relationship Model( ER Model): It is a high-level data model which is used to define the data
and the relationships between them. It is basically a conceptual design of any database which is easy
to design the view of data.

Components of ER Model:

1. Entity: An entity is referred to as a real-world object. It can be a name, place, object, class,
etc. These are represented by a rectangle in an ER Diagram.
2. Attributes: An attribute can be defined as the description of the entity. These are
represented by Ellipse in an ER Diagram. It can be Age, Roll Number, or Marks for a Student.

3. Relationship: Relationships are used to define relations among different entities. Diamonds
and Rhombus are used to show Relationships.

Characteristics of a conceptual data model

• Offers Organization-wide coverage of the business concepts.

• This type of Data Models are designed and developed for a business audience.

• The conceptual model is developed independently of hardware specifications like data


storage capacity, location or software specifications like DBMS vendor and technology. The
focus is to represent data as a user will see it in the “real world.”

Conceptual data models known as Domain models create a common vocabulary for all stakeholders
by establishing basic concepts and scope

2. Representational Data Model

This type of data model is used to represent only the logical part of the database and does not
represent the physical structure of the database. The representational data model allows us to focus
primarily, on the design part of the database. A popular representational model is a Relational
model. The relational Model consists of Relational Algebra and Relational Calculus. In the Relational
Model, we basically use tables to represent our data and the relationships between them. It is a
theoretical concept whose practical implementation is done in Physical Data Model.

The advantage of using a Representational data model is to provide a foundation to form the base for
the Physical model.

Characteristics of Representational Data Model

• Represents the logical structure of the database.

• Relational models like Relational Algebra and Relational Calculus are commonly used.

• Uses tables to represent data and relationships.

• Provides a foundation for building the physical data model.

3. Physical Data Model

The physical Data Model is used to practically implement Relational Data Model. Ultimately, all data
in a database is stored physically on a secondary storage device such as discs and tapes. This is stored
in the form of files, records, and certain other data structures. It has all the information on the
format in which the files are present and the structure of the databases, the presence of external
data structures, and their relation to each other. Here, we basically save tables in memory so they
can be accessed efficiently. In order to come up with a good physical model, we have to work on the
relational model in a better way. Structured Query Language (SQL) is used to practically implement
Relational Algebra.

This Data Model describes HOW the system will be implemented using a specific DBMS system. This
model is typically created by DBA and developers. The purpose is actual implementation of the
database.
Characteristics of a physical data model:

• The physical data model describes data need for a single project or application though it
maybe integrated with other physical data models based on project scope.

• Data Model contains relationships between tables that which addresses cardinality and
nullability of the relationships.

• Developed for a specific version of a DBMS, location, data storage or technology to be used
in the project.

• Columns should have exact datatypes, lengths assigned and default values.

• Primary and Foreign keys, views, indexes, access profiles, and authorizations, etc. are defined

Some Other Data Models

1. Hierarchical Model

The hierarchical Model is one of the oldest models in the data model which was developed by IBM,
in the 1950s. In a hierarchical model, data are viewed as a collection of tables, or we can say
segments that form a hierarchical relation. In this, the data is organized into a tree-like structure
where each record consists of one parent record and many children. Even if the segments are
connected as a chain-like structure by logical associations, then the instant structure can be a fan
structure with multiple branches. We call the illogical associations as directional associations.

2. Network Model

The Network Model was formalized by the Database Task group in the 1960s. This model is the
generalization of the hierarchical model. This model can consist of multiple parent segments and
these segments are grouped as levels but there exists a logical association between the segments
belonging to any level. Mostly, there exists a many-to-many logical association between any of the
two segments.

3. Object-Oriented Data Model

In the Object-Oriented Data Model, data and their relationships are contained in a single structure
which is referred to as an object in this data model. In this, real-world problems are represented as
objects with different attributes. All objects have multiple relationships between them. Basically, it is
a combination of Object Oriented programming and a Relational Database Model.

4. Float Data Model

The float data model basically consists of a two-dimensional array of data models that do not contain
any duplicate elements in the array. This data model has one drawback it cannot store a large
amount of data that is the tables can not be of large size.

5. Context Data Model

The Context data model is simply a data model which consists of more than one data model. For
example, the Context data model consists of ER Model, Object-Oriented Data Model, etc. This model
allows users to do more than one thing which each individual data model can do.

6. Semi-Structured Data Model


Semi-Structured data models deal with the data in a flexible way. Some entities may have extra
attributes and some entities may have some missing attributes. Basically, you can represent data
here in a flexible way.

Advantages of Data Models

1. Data Models help us in representing data accurately.

2. It helps us in finding the missing data and also in minimizing Data Redundancy.

3. Data Model provides data security in a better way.

4. The data model should be detailed enough to be used for building the physical database.

5. The information in the data model can be used for defining the relationship between tables,
primary and foreign keys, and stored procedures.

Disadvantages of Data Models

1. In the case of a vast database, sometimes it becomes difficult to understand the data model.

2. You must have the proper knowledge of SQL to use physical models.

3. Even smaller change made in structure require modification in the entire application.

4. There is no set data manipulation language in DBMS.

5. To develop Data model one should know physical data stored characteristics.

Schema and instances:-


“Schema” and “Instance” are key ideas in a database management system (DBMS) that help organize
and manage data. A schema can be referred to as the blueprint of the database while an instance is
the actual contents of the database at a given point of time. This article will look at these ideas in
detail to understand their importance, their difference, and how they relate to each other in a DBMS.

What is Schema?

Schema is the overall description of the database. The basic structure of how the data will be stored
in the database is called schema. In DBMS, the term schema refers to the architecture of the
database which describes how it will appear or will be constructed. It describes the organization of
data such as tables, relationships as well as constraints. A schema is a template that dictates how
data items in a database will be stored, arranged, and accessed.
Schema is of three types: Logical Schema, Physical Schema and view Schema.

• Logical Schema – It describes the database designed at a logical level.

• Physical Schema – It describes the database designed at the physical level.

• View Schema – It defines the design of the database at the view level.

Example:

Let’s say a table teacher in our database named school, the teacher table requires the name, dob,
and doj in their table so we design a structure as:

Teacher table
name: String
doj: date
dob: date

Advantages of Schema

• Consistency: Guarantees proper storage of data in order to allow easy access and
expandability.

• Structure: Helps in easy arrangement of the data base in an organized manner and hence
makes it easy to comprehend.

• Data Integrity: Puts in place restrictions that ensure the data’s maintaining of its accuracy
and subsequent reliability.

Disadvantages of Schema
• Rigidity: Schemas, defined, may be rigid for alteration, and may take a huge amount of effort
in order to alter the scheme.

• Complexity: Developing a schema may be difficult or time consuming in case of large


databases.

What is Instance?

An instance of DBMS refers to real data in a database coming at some particular point in time.
Instance on the other hand refers to the content in the database in as much as it refers to the
structure defined under a particular schema at a given point.

Example

Let’s say a table teacher in our database whose name is School, suppose the table has 50 records so
the instance of the database has 50 records for now and tomorrow we are going to add another fifty
records so tomorrow the instance has a total of 100 records. This is called an instance.

Advantages of Instance

• Real-Time Representation: It a return of the data in the database at a certain point in time
as may be required for analysis or for performing operations.

• Flexibility: While a schema remains fixed in time, instances can be quite volatile, as data is
written, updated, or deleted.

Disadvantages of Instance

• Volatility: Those are occurrences may be dynamic in a way they are different over time and
this may make it a challenge to keep track without the necessary intervention.

• Data Integrity Issues: If not well regulated, it is evident that the data in an instance could
become very inconsistent and at times even incorrect.

• Difference Between Schema and Instance


Schema Instance

It is the collection of information stored in a


It is the overall description of the database.
database at a particular moment.

Data in instances can be changed using


The schema is same for the whole database.
addition, deletion, and updation.

Does not change Frequently. Changes Frequently.


Schema Instance

Defines the basic structure of the database


It is the set of Information stored at a particular
i.e. how the data will be stored in the
time.
database.

Affects the entire database structure. Affects only the current state of data.

Requires significant effort and planning to Easily altered by performing CRUD (Create,
change. Read, Update, Delete) operations.

Table structures, relationships, constraints. Data entries, records in tables.

Data independence:-
Data independence is a property of a database management system by which we can change the
database schema at one level of the database system without changing the database schema at the
next higher level. In this article, we will learn in full detail about data independence and will also see
its types. If you read it completely, you will understand it easily.

In the context of a database management system, data independence is the feature that allows the
schema of one layer of the database system to be changed without any impact on the schema of the
next higher level of the database system. ” Through data independence, we can build an
environment in which data is independent of all programs, and through the three schema
architectures, data independence will be more understandable. Data via two card stencils along with
centralized DBMS data is a form of transparency that has value for someone.

It can be summed up as a sort of immunity of user applications that adjusts correctly and does not
change addresses, imparting the class of data and their order. I want the separate applications not to
be forced to deal with data representation and storage specifics because this decreases quality and
flexibility. DBMS permits you to see data with such a generalized sight. It actually means that the
ability to change the structure of the lower-level schema without presenting the upper-level schema
is called data independence.
Types of Data Independence

There are two types of data independence.

• logical data independence

• Physical data independence

Logical Data Independence

• Changing the logical schema (conceptual level) without changing the external schema (view
level) is called logical data independence.

• It is used to keep the external schema separate from the logical schema.

• If we make any changes at the conceptual level of data, it does not affect the view level.

• This happens at the user interface level.

• For example, it is possible to add or delete new entities, attributes to the conceptual schema
without making any changes to the external schema.

Physical Data Independence

• Making changes to the physical schema without changing the logical schema is called
physical data independence.
• If we change the storage size of the database system server, it will not affect the conceptual
structure of the database.

• It is used to keep the conceptual level separate from the internal level.

• This happens at the logical interface level.

• Example – Changing the location of the database from C drive to D drive.

• Difference Between Physical and Logical Data


Independence
Physical Data Independence Logical Data Independence

It mainly concerns how the data is stored in It mainly concerns about changes to the
the system. structure or data definition.

It is easier to achieve than logical It is difficult to achieve compared to physical


independence. independence.

To make changes at the physical level we


To make changes at the logical level, we need to
generally do not require changes at the
make changes at the application level.
application program level.

It tells about the internal schema. It tells about the conceptual schema.

There may or may not be a need for changes Whenever the logical structure of
to be made at the internal level to improve the database has to be changed, the changes
the structure. made at the logical level are important.

Example- change in compression


Example – adding/modifying or deleting a new
technology, hashing algorithm, storage
attribute.
device etc.

Database languages and interfaces:-


Databases are essential for efficiently storing, managing, and retrieving large volumes of data. They
utilize both software and hardware components. The software provides an interface that enables
users or applications to interact with the database, while the hardware consists of servers and
storage systems responsible for physically storing and organizing the data, either in memory or on
physical devices like hard drives.
In this article, we will explore the types of database languages used in a Database Management
System (DBMS). These languages are crucial for performing operations such as data
creation, manipulation, retrieval, and management. They provide the tools necessary to define,
control, and manipulate the data effectively.

What is a Database?

A database is a structured collection of data stored electronically. It allows users to


easily access, manage, and update data. For example, a phone contact list on our smartphone is a
small database. It keeps track of names, phone numbers, and addresses, allowing us to search and
access this information quickly when needed. Databases are widely used in businesses, websites, and
applications to store and manage large volumes of data efficiently.

A Database Management System (DBMS) is the software that interacts with the database, providing
an interface to users and applications. It ensures the efficient storage and retrieval of data, maintains
data integrity, and provides security features like access control and authentication.

Types of Database Languages in DBMS

Database languages are specialized languages used to interact with a database. They allow users to
perform different tasks such as defining, controlling, and manipulating the data. There are several
types of database languages in DBMS, categorized into the following four main types:

1. DDL (Data Definition Language)

2. DCL (Data Control Language)

3. DML (Data Manipulation Language)

4. TCL (Transaction Control Language)

Each category serves a different purpose within the database management process. Let's break down
each one.

1. DDL (Data Definition Language)


The DDL stands for Data Definition Language, Which is used to define the database's internal
structure and Pattern of the Database. It is used to define and modify the structure of the database
itself, including the tables, views, indexes, and other schema-related objects. It deals with the
creation and modification of database schema, but it doesn't deal with the data itself.

Following are the five DDL commands in SQL:

• CREATE: Used to create database objects like tables, indexes, or views.

• ALTER: Used to modify the structure of an existing database object, such as adding a new
column to a table.

• DROP: Used to delete database objects.

• TRUNCATE: Used to remove all rows from a table, without affecting the structure.

• RENAME: Used to change the name of a database object.

Now we will explain each command with examples for better understanding of the concepts.

CREATE Command

The CREATE is a DDL command used to create databases, tables, triggers and other database objects.

Syntax

CREATE TABLE Students (


column1 INT,
column2 VARCHAR(50),
column3 INT
);

Example:

Alter Command
ALTER is a DDL command which changes or modifies the existing structure of the database, and it
also changes the schema of database objects. We can also add and drop constraints of the table
using the ALTER command.

Syntax

ALTER TABLE Students ADD column_name;

Example:

Drop Command

DROP is a DDL command used to delete/remove the database objects from the SQL database. We
can easily remove the entire table, view, or index from the database using this DDL command.

Syntax

DROP Table Table_name;

Example:

Truncate Command

The TRUNCATE command is used to delete all the records from a table without removing the
structure. Unlike the DELETE command, which can remove specific rows and can be rolled
back, TRUNCATE is a more efficient way to delete all rows in a table without logging individual row
deletions.

Syntax

TRUNCATE TABLE table_name;

Example:
Rename Command

The RENAME command in a Database Management System (DBMS) is used to change the name of a
database object, such as a table, column, or index. This command is helpful when we want to give a
more meaningful or appropriate name to an object without needing to recreate it.

Syntax:

ALTER TABLE Old_Table_Name RENAME TO New_Table_Name;

DCL (Data Control Language)

DCL stands for Data Control Language. It is used to control the access permissions of users to the
database. DCL commands help grant or revoke privileges to users, determining who can perform
actions like reading or modifying data. DCL commands are transactional, meaning they can be rolled
back if necessary.

The two main DCL commands are:

• Grant: Gives user access to the database

• Revoke: Removes access or permissions from the user

Now we will explain these commands with proper examples for better understanding

Grant Command

The GRANT command in a Database Management System (DBMS) is used to provide


specific permissions or privileges to users or roles. This command allows administrators to control
access to database objects, ensuring that only authorized users can perform certain actions, such as
selecting, inserting, updating, or deleting data.

Syntax
GRANT privileges
ON object
TO user_or_role [WITH GRANT OPTION];

Example:

GRANT SELECT, INSERT ON students TO user;

Revoke Command

The REVOKE command in a Database Management System (DBMS) is used to remove previously
granted permissions or privileges from users or roles. This command is essential for managing access
control, ensuring that users do not have more privileges than necessary to perform their tasks.

Syntax

REVOKE privileges ON object FROM user_or_role;

Example

REVOKE ALL PRIVILEGES ON students FROM user;

DML (Data Manipulation Language)

The DML (Data Manipulation Language) is used toto manage and manipulate data within a database.
With DML, you can perform various operations such as inserting, updating, selecting, and deleting
data. These operations allow you to work with the actual content in your database tables.

Here are the key DML commands:

• SELECT: Retrieves data from the table based on specific criteria.

• INSERT: Adds new rows of data into an existing table.

• UPDATE: Modifies existing data in a table.

• DELETE: Removes data from a table.

• MERGE: Performs an "upsert" operation, which means updating existing records or inserting
new ones if they don’t exist.

• CALL: Executes stored procedures or functions.

• LOCK TABLE: Prevents other users from accessing the table while changes are being made.

Now, we will explain these commands with examples for better understanding:

SELECT Command

The SELECT command in SQL (Structured Query Language) is used to retrieve data from one or more
tables in a database. It is the most commonly used commands in SQL, allowing users to specify which
columns and rows of data they want to retrieve and how they want that data organized.
The SELECT statement can be used in various ways, such as selecting all data from a table, filtering
records based on conditions, or sorting the results.

Syntax

SELECT * FROM Table_Name


Example:

Insert Command

The INSERT command in SQL (Structured Query Language) is used to add new records or rows to a
table in a database. It is a key operation in database management, essential for populating tables
with new data. This command can insert data into all columns or specific columns of a table.

Syntax

INSERT INTO Table_Name (Column 1, Column 2, Column 3, Column 4) VALUES (Value 1, Value 2,Value
3, Value 4);

Update Command

The UPDATE command in SQL (Structured Query Language) is used to modify existing records in a
table. This command enables users to change the values of one or more columns for specific rows
based on a condition (criteria). It is crucial for maintaining and adjusting data in a database when
necessary.

Syntax

UPDATE Table_Name SET Name = 'New_Value' WHERE Name = 'Ola_Value';

Example:
Delete Command

The DELETE command in SQL (Structured Query Language) is used to remove one or more existing
records from a table in a database. It is an essential operation for managing data, enabling users to
delete specific rows that meet certain conditions or criteria.

Syntax:

DELETE FROM Table_Name WHERE Column = Value;

Example:

Merge Command

The Merge command in SQL is used to perform an upsert operation, which combines
both UPDATE and INSERT actions. It allows you to insert new rows if they do not exist, or update
existing rows if they match a certain condition. This command is particularly useful for synchronizing
two tables by inserting new records and updating existing ones in a single operation.

Syntax:
MERGE INTO target_table AS target
USING source_table AS source
ON (target.id = source.id)
WHEN MATCHED THEN
UPDATE SET target.name = source.name
WHEN NOT MATCHED THEN
INSERT (id, name) VALUES (source.id, source.name);

Example:

MERGE INTO Employees AS target


USING New_Hires AS source
ON target.EmployeeID = source.EmployeeID
WHEN MATCHED THEN
UPDATE SET target.Name = source.Name, target.Salary = source.Salary
WHEN NOT MATCHED THEN
INSERT (EmployeeID, Name, Salary)
VALUES (source.EmployeeID, source.Name, source.Salary);

Table 1. Employees Table (Before Merge):

Employee Table

Table 2: New_Hires Table:

New_Hires Table

Output

CALL Command
The Call command is used to invoke a stored procedure or user-defined function, which is a set of
precompiled SQL statements. It allows you to execute complex operations within a database as a
single unit.

Syntax:

CALL user_defined_function(parameter 1, parameter 2);

Example:

CALL UpdateEmployeeSalary(101, 55000);

LOCK TABLE

The lock table command is used to lock the table for preventing access from others, ensuring no
other operations (like insertions, updates, or deletions) can be performed on the table while it's
locked. Useful for transactional operations where consistency is important.

Syntax:

LOCK TABLE your_table IN EXCLUSIVE MODE;

Example:

LOCK TABLE ClassMembers IN EXCLUSIVE MODE;

TCL ( Transaction Control Language )

The TCL full form is Transaction Control Language commands are used to manage and control
transactions in a database, grouping them into logical units. These commands help ensure the
integrity of data and consistency during complex operations. Here are the two main commands in
this category:

• Commit: Saves all the changes made during the current transaction to the database. These
are very useful in the banking sector.

• Rollback: used to restore the database to its original state from the last commit. This
command also plays an important role in Banking Sectors.

Now we will explain these two commands for better understanding with examples

Commit Command

The COMMIT command is used to save all changes made during a transaction in the database. This
command ensures that modifications made by DML statements (such as INSERT, UPDATE, or DELETE)
become permanent in the database.

Syntax

Database Operation
Commit

Example:
ROLLBACK Command

The rollback command is used to restore the database to its state at the last COMMIT, effectively
undoing any changes made since that point. It helps ensure data consistency by allowing the reversal
of partial or erroneous operations.

Syntax

ROLLBACK;

Example:

Conclusion

In conclusion, database languages play a crucial role in managing and manipulating data in a
database management system (DBMS). There are different type of database language
like DDL, DCL, DML, and TCL. The DDL language is used for used for defining the database's internal
structure and Pattern of the Database. The DCL commands are used to control the data from the user
means They can provide control of the Database, Table, and Data. The DML commands are used to
manipulate the Data in the Table like Inserting, updating, and deleting the Data finally the TCL
commands are used to save and restore the previous state of the Database.

Data definition languages:-


DDL stands for Data Definition Language. These are the commands that are used to change the
structure of a database and database objects. For example, DDL commands can be used to add,
remove, or modify tables within a database.

In this article, We will learn about the DDL Full Form by understanding various examples and so on.
What is DDL?

DDL actually represents Data Definition Language, which is actually a set of commands used to
create a structure and maintain databases. Those would
include CREATE, ALTER, DROP, TRUNCATE, and RENAME statements for creating, changing the
structure of, and dropping structures in the database, such as tables. DDL basically deals with the
storage of the data and not the data itself.

Example: The ‘CREATE TABLE’ command defines a new table called “Employees” with columns
including EmployeeID, FirstName, LastName, and HireDate along with their datatypes.

CREATE TABLE Employees (

EmployeeID INT PRIMARY KEY,

FirstName VARCHAR(50),

LastName VARCHAR(50),

HireDate DATE

);

Types of DDL Commands

DDL includes the following commands:

• CREATE

• ALTER

• DROP

• TRUNCATE

• RENAME

1. CREATE

This command is used to create table in the relational database.


This can be done by specifying the names and datatypes of various columns.

Syntax:

CREATE TABLE TABLE_NAME

column_name1 datatype1,

column_name2 datatype2,

column_name3 datatype3,

column_name4 datatype4

);
The column_name in create table command will tell the name of the column and corresponding
datatype will specify the datatype of that column. Here in this table the three column_names namely
– Student_id is of type int, Name is of type varchar and Marks is of type int.
for example:

CREATE TABLE

Student

(Student_id INT,

Name VARCHAR(100),

Marks INT);

Student_id Name Marks

2. ALTER

Alter command is used for altering the table in many forms like:

1. Add a column

2. Rename existing column

3. Drop a column

4. Modify the size of the column or change datatype of the column

• ADD using ALTER:


Syntax to add column :

ALTER TABLE table_name ADD(

column_name datatype);

The above command will add a new column to the table.And the resulting table will have one more
column like this:

ALTER TABLE Student

ADD

(Address VARCHAR(200));

Here this command will add a new column “Address” in the table Student of datatype varchar(200);

Student_id Name Marks Address

• RENAME using ALTER:


Syntax to rename column:

ALTER TABLE

table_name

RENAME
old_column_name TO new_column_name;

The above command will rename the existing column to new column.

ALTER TABLE

Student

RENAME

Marks TO Age;

The command above will change the column_name from Marks to Age;

Student_id Name Age Address

• DROP using ALTER:


Syntax to Drop a column:

ALTER TABLE

table_name

DROp

(column_name);

The above command will delete the existing column.


For example:

ALTER TABLE Student

DROP

(Age);

Here the column_name =”Age”, has been deleted by this command;

Student_id Name Address

• MODIFY using ALTER:


Syntax to Modify a column:

ALTER TABLE

Student MODIFY

(column_name datatype);

The above command will modify the existing column .


For example:

ALTER TABLE

Student

MODIFY
(name varchar(300));

The above command will modify the column_name “Name” by changing the size of that column.

Student_id Name Address

3. TRUNCATE

This command removes all the records from a table. But this command will not destroy the table’s
structure.
Syntax :

TRUNCATE TABLE table_name

This will delete all the records from the table. For example the below command will remove all the
records from table student.

Example:

TRUNCATE TABLE Student;

4. DROP

This command completely removes the table from the database along with the destruction of the
table structure.

Syntax –

DROP TABLE table_name

This will delete all the records as well as the structure of the table.

This is the main difference between TRUNCATE AND DROP.-TRUNCATE only removes the records
whereas DROP completely destroys the table.

Example:

DROP TABLE Student;

This command will remove the table records as well as destroys the schema too.
This is all about the DDL commands.

Advantages of DDL

• Defines Structure: DDL commands like CREATE and ALTER allow you to set up and modify the
structure of database objects (tables, indexes, views), organizing data effectively.

• Manages Schema: You can easily create, update, or remove entire database schemas,
making it simpler to maintain and update the database structure over time.

• Enforces Data Integrity: DDL allows the implementation of rules and constraints (PRIMARY
KEY, FOREIGN KEY, UNIQUE, NOT NULL) that ensure data remains accurate and consistent.

• Boosts Performance: By creating indexes and partitions using DDL commands, you can
significantly improve query performance and speed up data retrieval.
• Standardized: DDL commands are standardized across most SQL-based databases, making it
easier to apply knowledge across different database systems.

Disadvantages of DDL

• Irreversible Changes: DDL commands, especially DROP and TRUNCATE, are auto-committed,
meaning changes can’t be undone once executed. This can result in permanent data loss if
not used carefully.

• Risk of Data Loss: Misuse of commands like DROP can delete entire tables along with their
data, leading to significant data loss, particularly if no backup is available.

• Complex for Large Databases: Altering the structure of large databases can be complicated
and may require downtime or additional planning to avoid disrupting operations.

• Causes Locking: DDL operations can lock database objects during execution, which might
slow down or block other operations, impacting overall database performance.

• Compatibility Issues: While DDL is standardized, different databases (like MySQL, Oracle, or
PostgreSQL) may have variations in syntax and features, leading to compatibility issues
during migration.

Applications of DDL

• Creating Database Objects: DDL statements can be used to create various database objects
such as tables, views, indexes, and stored procedures.

• Modifying Database Objects: DDL statements can be used to modify the structure of existing
database objects such as adding or dropping columns from tables, modifying the data type
of columns, renaming tables or columns, etc.

• Managing Database Constraints: DDL statements can be used to create or alter database
constraints such as primary keys, foreign keys, unique constraints, and check constraints.

• Granting or Revoking Permissions: DDL statements can be used to grant or revoke


permissions to various database objects such as tables, views, stored procedures, and
indexes.

• Indexing: DDL statements can be used to create or modify indexes on database tables, which
can improve the performance of SQL queries.

• Partitioning: DDL statements can be used to create or modify partitioned tables, which can
improve the performance of queries that access large amounts of data.

Overall, DDL is an essential part of SQL and is used extensively in database management systems to
create, modify and manage database objects.

DML:-
DML stands for Data Manipulation Language. Tables and formulas are helpful when communicating
with data stored up to a point in a database through SQL (Structured Query Language), but a time
comes when we actually want to execute some fairly complicated data interactions. We will also
need the Data Manipulation Language in that situation. DML is a way to inform a database precisely
what we want it to do by conversing in a manner that it has been built to comprehend from scratch.
When it comes to interacting with existing data, whether adding, moving, or deleting data, it
provides a convenient way to do so.

Transaction control is required for the DML statements. Any modification that a DML statement
makes to the database will be called a transaction. Any adjustment made by the DML statement
must, therefore, be controlled by TCL statements (Transaction Control Language). DML is a subset of
SQL statements that alter the information stored in tables. As, it mainly concentrates on database
performance, as well as it utilizes HDFS (Hadoop Distributed File System) storage’s append-only
nature.

Generally, DML commands fall into one of four primary categories:

• INSERT adds fresh data to a table.

• UPDATE Change the data that is already in a table.

• DELETE takes a record out of a table.

• SELECT Get information out of one or more tables.

Types of Data Manipulation Language

There are basically two types of Data Manipulation Language. These are mentioned below. We have
described them in the difference between format.

• High-Level or Non-Procedural DML

• Low-Level or Procedural DML

High-Level or Non-Procedural DML vs Low-level or Procedural DML

High-Level or Non-Procedural DML Low-level or Procedural DML

It is also labelled as set-at-a-time or series oriented It is also labelled as track-at-a-time


DML. DML.

It can be used on its own for precisely specifying It must be integrated to a general-
complex operations in the database. purpose programming language.

It is prescriptive in nature. It is indispensable in nature.

It demands that a user must clearly state which data is It demands that a user must clearly
needed without clarifying how and when to obtain state which data is needed and how to
those data. obtain those data.
High-Level or Non-Procedural DML Low-level or Procedural DML

For Example: Every SQL statement is a prescriptive For Example: DB2’s SQL PL,
command. Oracle’s PL/SQL.

Characteristics of DML

It performs interpret-only data queries. It is used in a database schema to recall and manipulate the
information. DML It is a dialect which is used to select, insert, delete and update data in a database.
Data Manipulation Language (DML) commands are as follows:

SELECT Command

This command is used to get data out of the database. It helps users of the database to access from
an operating system, the significant data they need. It sends a track result set from one tables or
more.

Syntax :

SELECT *

FROM <table_name>;

Example:

SELECT *

FROM students;

OR

SELECT *

FROM students

where due_fees <=20000;

INSERT Command

This command is used to enter the information or values into a row. We can connect one or more
records to a single table within a repository using this instruction. This is often used to connect an
unused tag to the documents.

Syntax:

INSERT INTO <table_name> ('column_name1' <datatype>, 'column_name2' <datatype>)

VALUES ('value1', 'value2');

Example :

INSERT INTO students ('stu_id' int, 'stu_name' varchar(20), 'city' varchar(20))


VALUES ('1', 'Nirmit', 'Gorakhpur');

UPDATE Command

This command is used to alter existing table records. Within a table, it modifies data from one or
more records. This command is used to alter the data which is already present in a table.

Syntax:

UPDATE <table_name>

SET <column_name = value>

WHERE condition;

Example:

UPDATE students

SET due_fees = 20000

WHERE stu_name = 'Mini';

DELETE Command

It deletes all archives from a table. This command is used to erase some or all of the previous table’s
records. If we do not specify the ‘WHERE’ condition then all the rows would be erased or deleted.

Syntax:

DELETE FROM <table_name>

WHERE <condition>;

Example:

DELETE FROM students

WHERE stu_id = '001';

Advantages of DML

• DML statements could alter the data that is contained or stored in the database.

• It delivers effective human contact with the machine.

• User could specify what data is required.

• DML aims to have many different varieties and functionalities between vendors providing
databases.

Disadvantages of DML

• We cannot use DML to change the structure of the database.

• Limit table view i.e., it could conceal some columns in tables.

• Access the data without having the data stored in the object.

• Unable to build or erase lists or sections using DML.


Conclusion

DML statements allow you to query, edit, add, and remove data stored in database objects. The
primary DML commands are SELECT, INSERT, DELETE, and UPDATE. Using DML statements, you can
perform powerful actions on the actual data stored in your system. You’ll typically see DML SELECT
statements written in data models to conduct data analysis or create new tables and views. In many
ways, DML is the air that us data folks breathe.

In a Database Management System (DBMS), the overall structure of a database typically consists of
several layers and components that work together to store, manage, and retrieve data efficiently.
Here's an outline of the key components and structure:

overall database structure:-


1. Database Schema

• Definition: The schema is the logical view of the entire database, specifying how the data is
organized and how the relationships between the data are structured.

• Types of Schemas:

o External Schema: User views of the database (e.g., different user interfaces or access
levels).

o Conceptual Schema: Represents the logical view of the entire database, abstracted
from physical details (i.e., a unified structure of all data).

o Internal Schema: Describes the physical storage of the data, how the data is stored
on disk (e.g., indexing, file organization).

2. Tables (Relations)

• Definition: A table is the most fundamental structure where data is stored. Each table is
composed of rows and columns.

• Columns: Represent attributes of the entities (fields in the table).

• Rows: Represent individual records or instances of entities.

3. Indexes

• Definition: Indexes are special data structures that improve the speed of data retrieval
operations by providing a faster way to look up data in a table.

• Types: Can be created on one or more columns of a table.

• Usage: Indexing is typically used to improve performance in SELECT queries, although they
can slow down write operations (INSERT, UPDATE, DELETE).

4. Primary Keys

• Definition: A primary key is a unique identifier for a row in a table. Each table typically has
one primary key, which uniquely identifies each record in that table.

• Uniqueness: The primary key ensures that no two rows have the same value for the key
attribute(s).
5. Foreign Keys

• Definition: A foreign key is a column or set of columns in a table that establishes a link
between data in two tables. It refers to the primary key in another table.

• Usage: Used to enforce referential integrity between tables, ensuring consistency in the
relationships between records.

6. Relationships

• One-to-One (1:1): Each record in the first table is related to one and only one record in the
second table.

• One-to-Many (1:N): A single record in the first table can be related to multiple records in the
second table.

• Many-to-Many (M:N): Multiple records in one table can be related to multiple records in
another table (often implemented using a junction table).

7. Views

• Definition: A view is a virtual table that represents the result of a query. It doesn't store data
itself but presents a specific subset of data from one or more tables.

• Usage: Useful for creating customized user views, aggregating data, or simplifying complex
queries.

8. Transactions

• Definition: A transaction is a sequence of operations performed as a single logical unit. It


ensures that the database is in a consistent state even in the case of failures.

• ACID Properties:

o Atomicity: All operations in a transaction are either fully completed or fully rolled
back.

o Consistency: The database moves from one valid state to another.

o Isolation: Transactions are isolated from each other, ensuring that concurrent
transactions do not interfere with each other.

o Durability: Once a transaction is committed, its changes are permanent even in case
of a system failure.

9. Normalization

• Definition: The process of organizing data to reduce redundancy and improve data integrity.
It involves breaking a database into smaller tables and ensuring that relationships between
data are consistent.

• Forms: There are several levels of normalization (1NF, 2NF, 3NF, BCNF) to avoid anomalies in
data insertion, deletion, and updates.

10. Stored Procedures and Triggers


• Stored Procedures: A set of SQL queries that are stored in the database and can be executed
repeatedly. They encapsulate logic to be executed on the server-side.

• Triggers: Special types of stored procedures that automatically execute in response to certain
events on a table (e.g., INSERT, UPDATE, DELETE).

11. Backup and Recovery Mechanisms

• Backup: Regular snapshots of the database are taken to ensure that data can be recovered in
case of failure.

• Recovery: Methods to restore the database to a consistent state after a crash, based on logs
and backup data.

12. Data Dictionary (System Catalog)

• Definition: A repository that contains metadata about the database, such as table
definitions, columns, data types, indexes, and constraints.

• Usage: Used by the DBMS to manage the structure and integrity of the database.

Example of a DBMS Structure:


Consider a simple database for a bookstore:

• Tables:

o Books: BookID (Primary Key), Title, Author, Price, Publisher

o Customers: CustomerID (Primary Key), Name, Email, PhoneNumber

o Orders: OrderID (Primary Key), CustomerID (Foreign Key), Date, TotalAmount

o OrderDetails: OrderDetailID (Primary Key), OrderID (Foreign Key), BookID (Foreign


Key), Quantity

• Indexes: Index on BookID for faster book lookup, and on CustomerID for faster customer
search.

• Views: A view might combine information from Books, Orders, and OrderDetails to show a
summary of orders placed by a customer.

• Stored Procedures: A procedure to calculate total sales for a specific time period.

This is just a general overview. The actual DBMS structure will depend on the type of DBMS
(relational, NoSQL, etc.) and the complexity of the application it supports.

Transaction Management :-

Transactions are a set of operations used to perform a logical set of work. A transaction usually
means that the data in the database has changed. One of the major uses of DBMS is to protect the
user data from system failures. It is done by ensuring that all the data is restored to a consistent state
when the computer is restarted after a crash. The transaction is any one execution of the user
program in a DBMS. One of the important properties of the transaction is that it contains a finite
number of steps. Executing the same program multiple times will generate multiple transactions.

Example: Consider the following example of transaction operations to be performed to withdraw


cash from an ATM vestibule.

Steps for ATM Transaction

1. Transaction Start.

2. Insert your ATM card.

3. Select a language for your transaction.

4. Select the Savings Account option.

5. Enter the amount you want to withdraw.

6. Enter your secret pin.

7. Wait for some time for processing.

8. Collect your Cash.

9. Transaction Completed.

A transaction can include the following basic database access operation.


• Read/Access data (R): Accessing the database item from disk (where the database stored
data) to memory variable.

• Write/Change data (W): Write the data item from the memory variable to the disk.

• Commit: Commit is a transaction control language that is used to permanently save the
changes done in a transaction

Example: Transfer of 50₹ from Account A to Account B. Initially A= 500₹, B= 800₹. This data is
brought to RAM from Hard Disk.

R(A) -- 500 // Accessed from RAM.


A = A-50 // Deducting 50₹ from A.
W(A)--450 // Updated in RAM.
R(B) -- 800 // Accessed from RAM.
B=B+50 // 50₹ is added to B's Account.
W(B) --850 // Updated in RAM.
commit // The data in RAM is taken back to Hard Disk.

Desirable Properties of Transaction (ACID Properties)

Transaction management in a Database Management System (DBMS) ensures that database


transactions are executed reliably and follow ACID properties: Atomicity, Consistency, Isolation, and
Durability. These principles help maintain data integrity, even during failures or concurrent user
interactions, ensuring that all transactions are either fully completed or rolled back if errors occur.

For a transaction to be performed in DBMS, it must possess several properties often called ACID
properties.

• A – Atomicity

• C – Consistency

• I – Isolation

• D – Durability
Transaction States

Transactions can be implemented using SQL queries and Servers. In the diagram, you can see
how transaction states work.

Desirable Properties of Transaction (ACID Properties)

Transaction management in a Database Management System (DBMS) ensures that database


transactions are executed reliably and follow ACID properties: Atomicity, Consistency, Isolation, and
Durability. These principles help maintain data integrity, even during failures or concurrent user
interactions, ensuring that all transactions are either fully completed or rolled back if errors occur.

For a transaction to be performed in DBMS, it must possess several properties often called ACID
properties.

• A – Atomicity

• C – Consistency

• I – Isolation

• D – Durability

Transaction States

Transactions can be implemented using SQL queries and Servers. In the diagram, you can see
how transaction states work.

The transaction has four properties. These are used to maintain consistency in a database, before
and after the transaction.
Property of Transaction:

• Atomicity

• Consistency

• Isolation
• Durability

Atomicity

• States that all operations of the transaction take place at once if not, the transactions are
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 stops or fails, none of the changes it made will be saved or visible.

• Commit: If a transaction completes successfully, all the changes it made will be saved and
visible.

Consistency

• The rules (integrity constraint) that keep the database accurate and consistent are followed
before and after a transaction.

• When a transaction is completed, it leaves the database either as it was before or in a new
stable state.

• This property means every transaction works with a reliable and consistent version of the
database.

• The transaction is used to transform the database from one consistent state to another
consistent state. A transaction changes the database from one consistent state to another
consistent state.

Isolation

• 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.

• 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 T1ends.

• The concurrency control subsystem of the DBMS enforced the isolation property

Durability

• The durability property is used to indicate the performance of the database’s consistent
state. It states that the transaction made the permanent changes.

• 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.

• The recovery subsystem of the DBMS has the responsibility of Durability property.

Implementing of Atomicity and Durability

The recovery-management component of a database system can support atomicity and durability by
a variety of schemes. E.g. the shadow-database scheme:
Shadow copy

• In the shadow-copy scheme, a transaction that wants to update the database first creates a
complete copy of the database.

• All updates are done on the new database copy, leaving the original copy, the shadow copy,
untouched. If at any point the transaction has to be aborted, the system merely deletes the
new copy. The old copy of the database has not been affected.

• This scheme is based on making copies of the database, called shadow copies, assumes that
only one transaction is active at a time.

• The scheme also assumes that the database is simply a file on disk. A pointer called db
pointer is maintained on disk, It points to the current copy of the database.

Transaction Isolation Levels in DBMS

Some other transaction may also have used value produced by the failed transaction. So we also
have to rollback those transactions. The SQL standard defines four isolation levels:

• Read Uncommitted: Read Uncommitted is the lowest isolation level. In this level, one
transaction may read not yet committed changes made by other transaction, there by
allowing dirty reads. In this level, transactions are not isolated from each other.

• Read Committed: This isolation level guarantees that any data read is committed at the
moment it is read. Thus it does not allows dirty read. The transaction holds a read or write
lock on the current row, and thus prevent other transactions from reading, updating or
deleting it.

• Repeatable Read: This is the most restrictive isolation level. The transaction holds locks on
all rows it references and writes locks on all rows it inserts, updates, deletes. Since other
transaction cannot read, update or delete these rows, consequently it
avoids non-repeatable read.

• Serializable: This is the Highest isolation level. A serializable execution is guaranteed to be


serializable. Serializable execution is defined to be an execution of operations in which
concurrently executing transactions appears to be serially executing.

Failure Classification

To find that where the problem has occurred, we generalize a failure into the following categories:

• Transaction failure

• System crash

• Disk failure

1. Transaction failure

The transaction failure occurs when it fails to execute or when it reaches a point from where it can’t
go any further. If a few transactions or process is hurt, then this is called as transaction failure.

Reasons for a transaction failure could be –


1. Logical errors: If a transaction cannot complete due to some code error or an internal error
condition, then the logical error occurs.

2. Syntax error: It occurs where the DBMS itself terminates an active transaction because the
database system is not able to execute it. For example, The system aborts an active
transaction, in case of deadlock or resource unavailability.

2. System Crash

System failure can occur due to power failure or other hardware or software failure. Example:
Operating system error.

• Fail-stop assumption: In the system crash, non-volatile storage is assumed not to be


corrupted.

3. Disk Failure

• It occurs where hard-disk drives or storage drives used to fail frequently. It was a common
problem in the early days of technology evolution.

• Disk failure occurs due to the formation of bad sectors, disk head crash, and unreachability
to the disk or any other failure, which destroy all or part of disk storage.

Serializability

It is an important aspect of Transactions. In simple meaning, you can say that serializability is a way
to check whether two transactions working on a database are maintaining database consistency or
not.

It is of two types:

1. Conflict Serializability

2. View Serializability

Schedule

Schedule, as the name suggests is a process of lining the transactions and executing them one by
one. When there are multiple transactions that are running in a concurrent manner and the order of
operation is needed to be set so that the operations do not overlap each other, Scheduling is brought
into play and the transactions are timed accordingly.

It is of two types:

1. Serial Schedule

2. Non-Serial Schedule

Uses of Transaction Management

• The DBMS is used to schedule the access of data concurrently. It means that the user can
access multiple data from the database without being interfered with by each other.
Transactions are used to manage concurrency.

• It is also used to satisfy ACID properties.

• It is used to solve Read/Write Conflicts.


• It is used to implementRecoverability , Serializability , and Cascading.

• Transaction Management is also used forConcurrency Control Protocols and the Locking of
data.

Advantages of using a Transaction

• Maintains a consistent and valid database after each transaction.

• Makes certain that updates to the database don’t affect its dependability or accuracy.

• Enables simultaneous use of numerous users without sacrificing data consistency.

Disadvantages of using a Transaction

• It may be difficult to change the information within the transaction database by end-users.

• We need to always roll back and start from the beginning rather than continue from the
previous state.

Database user and administrator :-


A Database User is defined as a person who interacts with data daily, updating, reading, and
modifying the given data. Database users can access and retrieve data from the database through
the Database Management System (DBMS) applications and interfaces.

Types of Database Users

Database users are categorized based on their interaction with the database. There are seven types
of database users in DBMS. Below mentioned are the types of database users:

1. Database Administrator (DBA)

A Database Administrator (DBA) is a person/team who defines the schema and also controls the 3
levels of the database. The DBA will then create a new account ID and password for the user if
he/she needs to access the database. DBA is also responsible for providing security to the database
and he allows only authorized users to access/modify the database. DBA is responsible for problems
such as security breaches and poor system response time.

• DBA also monitors the recovery and backup and provides technical support.

• The DBA has a DBA account in the DBMS which is 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 example,
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. A System Analyst
A 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 Designers

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 the 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.

8. Specialized users

Specialized users are sophisticated users who write specialized database application that does not fit
into the traditional data-processing framework. Among these applications are computer aided-
design systems, knowledge-base and expert systems etc.

You might also like