0% found this document useful (0 votes)
19 views32 pages

UNIT 1 - 2 DBMS Notes

Unit 1 introduces database systems, covering definitions of data, databases, and database management systems (DBMS), along with their characteristics, roles of database administrators and designers, and end-user interactions. It highlights the advantages of using a DBMS, such as improved data integrity and reduced redundancy, while also discussing scenarios where a DBMS may not be suitable. Unit 2 focuses on DBMS architecture, data models, and levels of data abstraction, detailing the physical, conceptual, and external levels of database organization.

Uploaded by

bharathsekar9009
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)
19 views32 pages

UNIT 1 - 2 DBMS Notes

Unit 1 introduces database systems, covering definitions of data, databases, and database management systems (DBMS), along with their characteristics, roles of database administrators and designers, and end-user interactions. It highlights the advantages of using a DBMS, such as improved data integrity and reduced redundancy, while also discussing scenarios where a DBMS may not be suitable. Unit 2 focuses on DBMS architecture, data models, and levels of data abstraction, detailing the physical, conceptual, and external levels of database organization.

Uploaded by

bharathsekar9009
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/ 32

UNIT-1

INTRODUCTION TO DATABASE SYSTEMS:


Data, Database, Database management system, Characteristics of the database approach
(Text book 1: Chapter 1 – 1.1 to 1.3), Role of Database administrators, Role of Database
Designers, End Users (Text book 1: Chapter 1 –1.4), Advantages of Using a DBMS (Text
book 1: Chapter 1 –1.6) and When not to use a DBMS (Text book 1: Chapter 1: 1.8).

UNIT-1

1. What is Data?

 Definition: Data refers to raw facts and figures without context. It can be anything
that is collected and has the potential to be processed into meaningful information.
 Examples: Numbers, dates, names, or measurements.
 Importance: Data is essential for decision-making and analysis in modern
applications and organizations.

2. What is a Database?

 Definition: A database is an organized collection of data that is stored and managed


for easy access, manipulation, and updating.
 Types of Databases:
o Relational Database: Stores data in tables (e.g., MySQL, PostgreSQL).
o NoSQL Database: Designed for unstructured data (e.g., MongoDB,
Cassandra).
o Hierarchical/Network Databases: Organize data in tree-like structures.

3. What is a Database Management System (DBMS)?

 Definition: A DBMS is software that allows users to interact with databases. It


provides tools to create, store, manage, retrieve, and secure data.
 Functions of a DBMS:
o Data Storage: Manages how data is stored and retrieved.
o Data Security: Ensures only authorized access to data.
o Data Integrity: Maintains accuracy and consistency of data.
o Concurrency Control: Manages simultaneous access to data.
o Backup and Recovery: Protects data from loss or corruption.
 Popular DBMS: MySQL, Oracle, Microsoft SQL Server, MongoDB, PostgreSQL.


DBMS: It’s a collection of programs that enables user to create and maintain a
database. In other words it’s a general purpose software that provides the users with
the processes of defining, constructing and manipulating the database for various
applications.

Simplified dbms

It consists of the fallowing:

1) Users/ programmers
2) Application programs/quries
3) Software to process queries/programs
4) Software to access stored data
5) Dbms catalog contains the stored database definition ( Metadata)
6) The physical stored database

4. Characteristics of the Database Approach

 Reduced Data Redundancy: A DBMS centralizes data, reducing the need for
repeated storage of the same data in multiple locations.
 Improved Data Integrity: Ensures data accuracy and consistency using rules and
constraints.
 Data Independence: Applications are insulated from changes in data structure
(logical and physical independence).
 Centralized Management: The DBMS centralizes data storage and access,
simplifying management.
 Security: The DBMS provides strong mechanisms for user authentication and
authorization.

In-brief explanation :

Data duplication and inconsistency: Different programmers create files and programs
over time, often using different structures and programming languages. This can lead to the
same data being stored in multiple places. For example, if a student has two majors, their
contact details might be saved in separate files for each department. If the student’s address
changes and only one file is updated, the data becomes inconsistent. This also increases
storage costs.

Difficulty in accessing data: If a university clerk needs a list of students in a certain


postal code, they may not have an easy way to get it if the system wasn't designed for that.
They either have to manually go through all student records or ask a programmer to create a
new program, which takes time. A more flexible data system is needed for quick and easy
retrieval.

Data isolation: Data is stored in different files and formats, making it hard to retrieve
specific information. Writing new programs to access this scattered data is challenging.

Integrity issues: Some rules must be followed when storing data, such as ensuring that a
department’s account balance never goes below zero. These rules are enforced through
coding in different programs. However, if new rules are needed, updating multiple programs
can be difficult, especially when different data sources are involved.
Atomicity problems: Computer systems can fail, and if they do, it’s crucial to ensure that
data remains accurate and complete.

OR

Characteristics of database approach-

1) Self-describing nature of a database system- Ex: data structures, types and


constraints, Meta data-( data about the data)
2) Insulation between data and program-
3) Data Abstraction
4) Support of multiple views of the data
5) Sharing of data and multiple user transaction processing

2) Insulation between data and program


- Data independence- modify a db structure without affecting the application programs
or user views that
Access the data.
- Conceptual level- db users, application programs Use the conceptual representation of
the files
3) Data abstraction:
- A characteristics which allows data independency and
Program operation independence is called data Abstraction.
Ex- hide storage details
4) Support of multiple views of the data
Library database system this db used by different users like researchers, teachers, sudents etc
5) Sharing of data and multiple user transaction processing-
OLTP- airline reservation system

5. Role of Database Administrators (DBAs)

 Responsibilities:
o Database Security: Ensuring only authorized users can access sensitive data.
o Performance Tuning: Optimizing query performance and managing
resources.
o Backup and Recovery: Creating backup strategies to recover data in case of
failure.
o Database Maintenance: Ensuring the database is running smoothly, including
updates and patches.
 Skills Required: Knowledge of database software, system administration,
programming, and troubleshooting.

6. Role of Database Designers

 Responsibilities:
o Database Modeling: Designing the structure of the database using techniques
like Entity-Relationship (ER) diagrams.
o Schema Design: Defining the tables, columns, and relationships in a database.
o Normalization: Ensuring the database is free from redundancy and maintains
data integrity.
o Business Requirements Analysis: Understanding the needs of users and
translating them into database structures.
 Skills Required: Understanding of business processes, data modeling, and database
theory.

7. End Users of a Database

 Types of Database Users:


o Casual Users: Use the database occasionally and interact with predefined
reports or applications.
o Naive Users: Typically interact with the database via simple forms or
interfaces, without knowledge of the underlying structure.
o Sophisticated Users: Skilled users, such as data scientists or analysts, who
write complex queries to extract or manipulate data.
 Interaction with Databases:
o Querying: Writing SQL or other query languages to interact with the data.
o Reports: Viewing and interpreting data in a structured format.
o Applications: Using software systems that interact with the database to
perform business operations.

8. Advantages of Using a DBMS

 Data Sharing: Multiple users can access the database concurrently without conflicts.
 Data Consistency and Integrity: DBMS ensures that the data remains consistent,
accurate, and valid through constraints and validation rules.
 Reduced Redundancy: Storing data in a central location reduces duplicate entries.
 Improved Security: Data is stored securely, with access controlled by user
authentication.
 Backup and Recovery: Provides mechanisms to protect and recover data in case of
failure.
 Better Data Management: Supports complex querying, reporting, and data analysis.

9. When Not to Use a DBMS

 Simple Applications: For applications with minimal data storage and no need for
complex data relationships (e.g., personal projects, small-scale applications).
 High Performance Requirements: When the overhead of using a DBMS slows
down performance, such as in real-time systems with low-latency requirements.
 Cost Considerations: The cost of setting up and maintaining a DBMS may not be
justified for small, simple systems.
 Lack of Need for Complex Queries: If the application doesn’t require complex data
retrieval, DBMS may be unnecessary.

OR

While Database Management Systems (DBMS) offer numerous advantages, there are
scenarios where using a DBMS might not be the best choice. Here are some situations
where a DBMS may not be appropriate:

1. **Small-Scale or Simple Applications**


- If the application is small, has minimal data, or requires simple data storage (e.g., a
to-do list or a small configuration file), a DBMS might be overkill. A flat file or
lightweight storage (e.g., JSON, CSV, or XML) could suffice.

2. **High-Performance, Low-Latency Requirements**

- In systems where performance and latency are critical (e.g., real-time systems,
gaming, or high-frequency trading), the overhead of a DBMS (e.g., query parsing,
transaction management) might introduce unacceptable delays. In-memory data
structures or custom storage solutions may be more suitable.

3. **Limited Resources**

- If the system has limited computational resources (e.g., embedded systems, IoT
devices), a DBMS might consume too much memory, processing power, or storage.
Lightweight alternatives like SQLite or file-based storage may be more appropriate.

4. **Temporary or Ephemeral Data**

- For data that is short-lived or only needed temporarily (e.g., cache data, session
data), a DBMS might add unnecessary complexity. In-memory stores like Redis or
simple file storage could be more efficient.

5. **Unstructured or Semi-Structured Data**

- If the data is unstructured (e.g., multimedia files, logs) or semi-structured (e.g.,


JSON documents), a traditional relational DBMS might not be the best fit. NoSQL
databases (e.g., MongoDB, Cassandra) or file systems might be more suitable

6. **Cost Constraints**

- DBMS solutions, especially commercial ones, can be expensive in terms of licensing,


hardware, and maintenance. For budget-constrained projects, simpler alternatives
might be more cost-effective.

7. **Lack of Expertise**

- If the team lacks the expertise to design, manage, and optimize a DBMS, using one
could lead to poor performance, security vulnerabilities, or data integrity issues. In such
cases, simpler solutions might be more manageable.

8. **Single-User or Standalone Applications**

- For applications that are single-user or standalone (e.g., a personal diary app), the
advanced features of a DBMS (e.g., concurrency control, multi-user support) are
unnecessary. A local file system or lightweight database might be sufficient.

9. **Experimental or Prototype Projects**

- For experimental or prototype projects where the data model is not yet stable, using
a DBMS might slow down development. Flexible, schema-less storage options (e.g.,
NoSQL databases or flat files) might be more appropriate.
10. **High Data Volatility**

- If the data changes very frequently and requires constant schema updates, a DBMS
might not be the best choice. Schema-less databases or file-based systems might offer
more flexibility.

UNIT-2

UNIT-2 DBMS Architecture


Data Models – Categories of data models, Schemas, Instances, and Database state. DBMS
Architecture and Data Independence – The Three schema architecture, Data independence,
DBMS Languages and Interfaces (Text book 1: Chapter 2: 2.1 to 2.3), Classifications of
Database Management Systems (Text book 1: Chapter 2: 2.6).

View Levels of DBMS Architecture/ Level of Data Abstraction in DBMS This


architecture describe the various views and levels of data abstraction in DBMS system which
are as Physical Level, Conceptual Level and External Level
1. Physical Level: Physical level describes the physical storage structure of data in
database, as well it also describe how the data is stored and retrieve in database and also
describe compression and encryption techniques applied on data. It is also known as
Internal Level. This level is very close to physical storage of data. At lowest level, it is
stored in the form of bits with the physical addresses on the secondary storage device. At
highest level, it can be viewed in the form of files. The internal schema defines the
various stored data types. It uses a physical data model.
2. Conceptual Level: Conceptual level also called logical or global level describes the
structure of the whole database for a group of users. It describe how the data will be
appeared to various user and relationship between various data. Conceptual schema is a
representation of the entire content of the database. This schema contains all the
information to build relevant external records. It hides the internal details of physical
storage.
3. External Level: External level is also called view level is related to the data which is
viewed by individual end users. This level includes a no. of user views or external
schemas. This level is closest to the user. External view describes the segment of the
database that is required for a particular user group and hides the rest of the database
from that user group. The different user may have different views.

A data model is a set of tools used to describe how data is organized, related, and maintained
in a database. It helps define:

 Data structure – How data is stored.


 Data relationships – How different data elements are connected.
 Data meaning – What the data represents.
 Data rules – Conditions to keep data accurate and consistent.

A data model helps design a database at three levels:

1. Physical level – How data is stored on a computer.


2. Logical level – How data is organized and connected.
3. View level – How users see and use the data.
There are different types of data models, which help define how data is stored and
organized. These models can be grouped into four main categories:

1. Relational Model – This model organizes data into tables (also called relations),
where each row represents a record, and each column represents an attribute. It is the
most commonly used model in databases today.

2. Entity-Relationship (E-R) Model – This model represents data using entities (real-
world objects) and their relationships. It is mainly used in database design.
What is Entity?
An Entity may be an object with a physical existence – a particular person, car, house, or
employee – or it may be an object with a conceptual existence – a company, a job, or a
university course.

What is Entity Set?


An Entity is an object of Entity Type and a set of all entities is called an entity set. For
Example, E1 is an entity having Entity Type Student and the set of all students is called Entity
Set. In ER diagram, Entity Type is represented as:

Entity Set

We can represent the entity set in ER Diagram but can’t represent entity in ER Diagram
because entity is row and column in the relation and ER Diagram is graphical representation
of data.
Types of Entity
There are two types of entity:
1. Strong Entity
A Strong Entity is a type of entity that has a key Attribute. Strong Entity does not depend on
other Entity in the Schema. It has a primary key, that helps in identifying it uniquely, and it
is represented by a rectangle. These are called Strong Entity Types.
2. Weak Entity
An Entity type has a key attribute that uniquely identifies each entity in the entity set. But
some entity type exists for which key attributes can’t be defined. These are called Weak
Entity types .
For Example, A company may store the information of dependents (Parents, Children,
Spouse) of an Employee. But the dependents can’t exist without the employee. So Dependent
will be a Weak Entity Type and Employee will be Identifying Entity type for Dependent,
which means it is Strong Entity Type .

A weak entity type is represented by a Double Rectangle. The participation of weak entity
types is always total. The relationship between the weak entity type and its identifying strong
entity type is called identifying relationship and it is represented by a double diamond.

Strong Entity and Weak Entity

What is Attributes?
Attributes are the properties that define the entity type. For example, Roll_No, Name, DOB,
Age, Address, and Mobile_No are the attributes that define entity type Student. In ER
diagram, the attribute is represented by an oval.

Attribute

Types of Attributes
1. Key Attribute
The attribute which uniquely identifies each entity in the entity set is called the key
attribute. For example, Roll_No will be unique for each student. In ER diagram, the key
attribute is represented by an oval with underlying lines.

Key Attribute
2. Composite Attribute
An attribute composed of many other attributes is called a composite attribute. For
example, the Address attribute of the student Entity type consists of Street, City, State, and
Country. In ER diagram, the composite attribute is represented by an oval comprising of
ovals.

Composite Attribute

3. Multivalued Attribute
An attribute consisting of more than one value for a given entity. For example, Phone_No
(can be more than one for a given student). In ER diagram, a multivalued attribute is
represented by a double oval.

Multivalued Attribute

4. Derived Attribute
An attribute that can be derived from other attributes of the entity type is known as a derived
attribute. e.g.; Age (can be derived from DOB). In ER diagram, the derived attribute is
represented by a dashed oval.

Derived Attribute

The Complete Entity Type Student with its Attributes can be represented as:
3. Object-Based Model – This model is based on object-oriented programming and
combines features of the relational and E-R models. It allows data to be stored as
objects with methods (functions) and identities.

Components of Object Oriented Data Model:

 Object: An object is a real-world entity or an instance of a class. It contains both


data and functions that operate on the data. Example: A student, doctor, or
engineer is an object.
 Attribute: Attributes are properties of an object. Example: A Student object may
have attributes like Roll Number, Branch, and Marks.
 Method: A method defines what an object can do. Example: A Student object may
have a method like SetMarks() to store marks.
 Class: A class is a blueprint for creating objects. It groups similar objects with
shared attributes and methods. Example: A Person class can have sub-classes like
Student, Doctor, and Engineer.

Example of a Class in C++:


cpp
CopyEdit
class Student {
char Name[20];
int Roll_No;

public:
void search();
void update();
};

Here, Student is a class, and objects like S1, S2 can be created from it in the main function.

 Inheritance: It allows a new class to inherit properties from an existing class.


Example: The Student, Doctor, and Engineer classes inherit from the Person class.

Advantages of Object-Oriented Data Model:

✔ Code Reusability – Inheritance allows code to be reused.


✔ Easy to Understand – Objects represent real-world entities.
✔ Lower Maintenance Cost – Reusing attributes and functions saves time and effort.

Disadvantages of Object-Oriented Data Model:

❌ Not Fully Developed – It is not widely accepted due to its complexity.

4. Semistructured Model – Unlike the previous models, this allows data items of the
same type to have different attributes. XML is a common format for semistructured
data.

Characteristics:

 Does not follow a strict format like traditional databases but has some structure.
 Cannot be stored in rows and columns like relational databases.
 Uses tags and metadata to organize and describe data.
 Data is arranged in a hierarchy, grouping similar entities together.
 Entities in the same group may have different attributes.
 Lacks enough metadata, making automation and management difficult.
 The size and type of attributes in the same group may vary.
 Not easily processed by computer programs due to its flexible structure.

Examples of Semi-Structured Data:

 Emails
 XML and markup languages (e.g., HTML)
 Binary files
 Network data (TCP/IP packets)
 Compressed files (ZIP, RAR)
 Data from multiple sources
 Web pages
Advantages:

✔ No fixed schema – Data is not restricted by a strict format.


✔ Flexible – Structure can change easily.
✔ Portable – Can be moved across different systems.
✔ Structured data can be converted into semi-structured data.
✔ Useful for non-SQL users – Supports those who struggle with structured queries.
✔ Handles diverse data sources efficiently.

Older models, such as the network and hierarchical models, were more complex and are
now rarely used, except in older systems.

Network Model

The network model is a type of database model where data is organized using records
(nodes) and relationships (edges) in a graph-like structure. It allows complex relationships
between data and supports many-to-many relationships, unlike the hierarchical model,
which follows a strict parent-child structure.

Key Features of the Network Model:

1. Graph Structure – Data is represented using records (entities) connected by links


(relationships).
2. Many-to-Many Relationships – A record can have multiple parent and child records,
making it more flexible than the hierarchical model.
3. Pointers for Connections – Relationships are defined using pointers, meaning data
retrieval is faster but requires more manual management.
4. Schema Representation – Uses a schema (set structure) to define how records are
linked.

Example:

Imagine a university database where:

 A student can enroll in multiple courses.


 A course can have many students enrolled.

In the network model, both students and courses can have multiple connections, unlike the
hierarchical model, which would force a single-parent structure.

Advantages:

✔ Faster Data Access – Because of direct pointer-based navigation.


✔ Efficient for Complex Relationships – Supports many-to-many connections.
✔ Flexible Structure – Can adapt to different types of relationships.

Disadvantages:

✖ Complex to Design – Managing relationships using pointers is difficult.


✖ Difficult to Modify – Any structure change requires updating multiple pointers.
The network model was widely used before the relational model became dominant, as
relational databases offer easier data handling and querying with SQL.

Hierarchical Model

The Hierarchical Model is a type of database model where data is organized in a tree-like
structure. It follows a parent-child relationship, meaning each parent record can have
multiple child records, but each child has only one parent.

Key Features of the Hierarchical Model:

1. Tree Structure – Data is stored in a hierarchical (tree) format, where a single root
node connects to multiple child nodes.
2. Parent-Child Relationship – Each child record has only one parent, but a parent
can have multiple children.
3. Fast Data Access – Because of predefined relationships, retrieving related data is
quick.
4. Uses Pointers – Relationships between records are maintained using pointers.

Example:

Consider an organization database:

 The Company is the root (parent).


 The Departments (HR, IT, Finance) are child nodes under the company.
 Each Department has multiple Employees (children), but an Employee belongs to
only one Department.

markdown
CopyEdit
Company

├── HR
│ ├── Employee 1
│ ├── Employee 2

├── IT
│ ├── Employee 3
│ ├── Employee 4

├── Finance
├── Employee 5
├── Employee 6

Advantages of the Hierarchical Model:

✔ Efficient for one-to-many relationships – Best suited for hierarchical data like
organizational structures.
✔ Fast data retrieval – Since relationships are predefined, searching is quick.
✔ Ensures data integrity – The parent-child structure prevents orphan records.

Disadvantages of the Hierarchical Model:


❌ Rigid structure – If relationships change, restructuring the database is difficult.
❌ Difficult to manage many-to-many relationships – The model does not support direct
connections between child nodes.
❌ Complex implementation – Requires navigation through levels, making queries
challenging.

Schema, Instances in DBMS

Similar to types and variables in programming languages

- The overall design of a database is called schema.

- A schema contains schema objects like table, foreign key, primary key, views, columns,
data types, stored procedure, etc

- A database schema is the skeleton structure of the database. It represents the logical
view of the entire database.
- A database schema can be represented by using the visual diagram. That diagram shows
the database objects and relationship with each other.

Logical Schema – The overall logical structure of the database

Example: The database consists of information about a set of customers and accounts in a bank
and the relationship between them

Analogous to type information of a variable in a program

Physical schema – the overall physical structure of the database

Instance – The actual content of the database at a particular point in time.

Analogous to the value of a variable

Example : schema: student (name, student_number, class, Major)

Instance: student table list will be listed


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.
• For Example: to learn SQL we set up an SQL server and the database on the local
system. This enables us to directly interact with the relational database and execute
operations.
• 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.
An advantage of this type is that maintenance and understanding are easier, and
compatible with existing systems. However, this model gives poor performance when
there are a large number of users.
• 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.

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

Data Independence in DBMS

Data Independence refers to the ability to modify the database structure without affecting
the applications or programs that use the data. This helps in easy maintenance and scalability
of databases.

Types of Data Independence:

1. Logical Data Independence:


o Changes in the logical structure (schema) do not affect the applications.
o Example: Adding a new column to a table should not affect existing queries or
programs.
2. Physical Data Independence:
o Changes in the physical storage of data do not impact the database structure
or applications.
o Example: Moving data to a different storage device should not affect how
users access it.

Why is Data Independence Important?

✔ Reduces maintenance costs – Developers don’t need to rewrite applications when


changes are made.
✔ Increases flexibility – Easy to make changes without disrupting users.
✔ Improves database efficiency – Allows better data organization and storage management.

In short, data independence ensures that database changes do not break existing
applications, making the system more stable and efficient.
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:
• DDL (Data Definition Language)
• DCL (Data Control Language)
• DML (Data Manipulation Language)

TCL (Transaction Control Language)


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.

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
);

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;
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;

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
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.
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 ;
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';
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;

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.
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);existing ones in a single
operation.

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):

Table 2. 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
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;

Interfaces in DBMS
A database management system (DBMS) interface is a user interface that allows for the
ability to input queries to a database without using the query language itself.
• Menu-Based Interfaces
• These interfaces present the user with lists of options (called menus) that lead the user
through the formation of a request. The basic advantage of using menus is that they
remove the tension of remembering specific commands and syntax of any query
language. The query is basically composed step by step by collecting or picking
options from a menu that is shown by the system. Pull-down menus are a very popular
technique in Web-based interfaces. They are also often used in browsing interfaces
which allow a user to look through the contents of a database in an exploratory and
unstructured manner.
• Forms-Based Interfaces
• A forms-based interface displays a form to each user. Users can fill out all of the form
entries to insert new data, or they can fill out only certain entries, in which case the
DBMS will redeem the same type of data for other remaining entries. These types of
forms are usually designed or created and programmed for users that have no
expertise in operating systems. Many DBMS’s have form specification languages
which are special languages that help specify such forms.

• Example: SQL Forms is a form-based language that specifies queries using a form
designed in conjunction with the relational database schema.
• Graphical User Interface
• A GUI typically displays a schema to the user in diagrammatic form. The user then
can specify a query by manipulating the diagram. In many cases, GUI utilise both
menus and forms. Most GUI use a pointing device such as a mouse, to pick a certain
part of the displayed schema diagram.
• Graphical user interface of Coordi system: Information stored in the database
management system is represented as visual icon objects. Relevant objects can be
linked through the lines, which can be manually created by simply drawing lines
between the objects.

• A Natural Language Interface (NLI) is a system that can understand and process
requests written in English or other languages. It works by using a special schema,
which is like a blueprint, and a dictionary of important words to understand the
meaning behind the request.
• When you make a request, the NLI checks the words in its schema and dictionary to
figure out what you're asking. If it understands your request, it translates it into a
high-level query that a database management system (DBMS) can process. If it
doesn't understand, it starts a conversation with you to clarify what you mean.
However, the main disadvantage is that these interfaces are not very advanced, meaning they
might not understand complex requests very well.

The generalized includes the following main steps: 1. Acquiring information about the
desired database as a whole.
2. Getting information algorithm of users’ interaction with NLIDB system modules about the
described entity as a whole.
3. Gets information about the set of attributes of the selected entity.
4. Perform a managed dialogue to find dependencies and relationships between entity
attributes, establish their type and a multiplicity of these relation. On the system side, the
received data is normalized, primary keys are added if necessary, new tables are formed from
subsets of attributes.
5. Performing a managed dialogue, the purpose of which is to find dependencies between
entities and establish a multiplicity of these relations. If it is necessary, the system adds
foreign keys and additional tables.
6. Obtaining a data domain abstraction of an entry-level.
7. Check, edit, adjust business rules and inputted data.
8. Generate SQL queries and create a database file.
Speech Input and Output Interfaces
• There is limited use of speech be it for a query or an answer to a question or being a
result of a request it is becoming commonplace. Applications with limited vocabulary
such as inquiries for telephone directory, flight arrival/departure, and bank account
information are allowed speech for input and output to enable ordinary folks to access
this information.
• The Speech input is detected using predefined words and used to set up the
parameters that are supplied to the queries. For output, a similar conversion from text
or numbers into speech takes place

• Interface for Parametric Users


• Interfaces for Parametric Users contain some commands that can be handled with a
minimum of keystrokes. It is generally used in bank transactions for transferring
money. These operations are performed repeatedly.

You might also like