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:
[Link] (Data Definition Language)
[Link] (Data Control Language)
[Link] (Data Manipulation Language)
[Link] (Transaction Control Language)
1. DDL (Data Definition Language)
The DDL 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.
2. DCL (Data Control Language)
DCL 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, it 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.
•Revoke: Removes access or permissions from the user, remove previously granted permissions or privileges from users
or roles
3. DML (Data Manipulation Language)
The DML is used to 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.
4. TCL ( Transaction Control Language )
TCL 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. This command ensures that modifications made by DML statements (such as INSERT, UPDATE or DELETE) become
permanent in the database.
•Rollback: used to restore the database to its original state from the last commit. This command also plays an important role in
Banking Sectors.
TYPES OF USERS IN DBMS
In a Database Management System (DBMS), various types of users interact with the database,
each with distinct roles and levels of access. These users can be broadly categorized as follows:
1. Database Administrator (DBA):This user or team is responsible for the overall management
and maintenance of the database system. Their tasks include schema definition, physical
organization modification, granting authorization for data access, performing backups and
recovery, and monitoring system performance.
2. Database Designers:
These individuals are responsible for identifying the data to be stored in the database and choosing
appropriate data structures to represent and store that data effectively. They focus on the logical
and physical design of the database.
3. Application Programmers:
These users develop software applications that interact with the database. They write programs in
various programming languages (e.g., Java, Python, C++) that embed database query languages
(like SQL) to access and manipulate data.
4. End Users:
This is a broad category encompassing individuals who directly interact with the database to retrieve or update
information. End users can be further classified:
•Naive/Parametric Users: These users interact with the database through pre-built application interfaces
(e.g., a banking application, a railway ticket booking system). They have little to no knowledge of the
underlying DBMS or query languages. Examples include users of online banking systems or e-commerce
websites.
•Sophisticated Users: These users are familiar with the database structure and can directly interact with the
DBMS using query languages like SQL to retrieve and analyze data. Examples include engineers, scientists,
and business analysts.
•Casual Users: These users access the database occasionally and may require different information each
time. They often use query languages to specify their requests. A store manager using Gmail to reply to customer
emails or Excel to track inventory, A customer using an ATM to withdraw cash, without needing in-depth knowledge of
the database system.
•Standalone Users: These users typically work with personal databases, often on a single machine, without
the need for complex multi-user access or advanced security features. Examples include individuals using tax
software, personal finance managers, or simple database applications for tasks like managing contacts or creating
documents
5. Specialized Users:
These users develop specialized database applications that cater to specific needs, often involving complex
data types or unique processing requirements (e.g., CAD systems, expert systems, environmental modeling
systems those involving artificial intelligence, data mining, or multimedia databases.
6. System Analysts:
These individuals analyze the requirements of end-users and design database solutions to meet those
DATABASE
Databases are essential for storing, retrieving,MODELS
and managing structured or unstructured data efficiently. They form the
backbone of modern applications—from mobile apps to enterprise systems. The choice of database impacts performance,
scalability, consistency, and data integrity. Databases are classified based on structure, data model, storage method, and use
case.
Hierarchical Databases
Hierarchical databases organize data in a tree-like structure, where each parent record can have multiple child records. This
model works well for scenarios where data follows a predefined hierarchical relationship, where data is arranged in levels or
ranks.
Hierarchical Database Example
For example, in a university, "University" is at the top level, while "Departments" and "Administration" are at lower levels,
even though they are distinct entities. This structure can also be viewed as a parent-child relationship, where each parent
record can have multiple child records, but a child record can only have one parent. As more data are added, the structure
expands like a tree.
• Example: IBM's Information Management System (IMS) is a well-known hierarchical database.
Network Databases
A network databases build on the hierarchical model but allow child records to be linked to multiple parent records,
creating a web-like structure of interconnected data. This results in a more flexible structure, often referred to as a
graph model, where entities can be connected in many different ways.
For example: club<---->students. In a University database, a student can join multiple clubs and a club can have
multiple students. This model is ideal for complex frameworks as it effectively represents many-to-many
relationships. Additionally, its structure simplifies the use of certain database management languages.
Object-Oriented Databases
Object-oriented databases are based on the principles of object-oriented programming (OOP), where
data is stored as objects. These objects include attributes (data) and methods (functions), making them
easily referenced and manipulated. These databases are designed to handle complex data structures
such as multimedia, graphics, and large files.
For instance, a "Person" object in the database could include attributes like Name and Address and
methods like getLatestAddress() to retrieve information. This approach reduces the workload on the
database by allowing objects to be reused and linked directly, streamlining data access and
manipulation.
Each object behaves as an instance of the database model, enabling efficient operations.
Relational Databases
Relational databases are the most widely used type of database today. They store data in tables, with rows
representing records and columns representing attributes of the records. In these databases, every piece of
information has a relationship with every other piece of information. This is on account of every data value in
the database having a unique identity in the form of a record. Note that all the data are tabulated in this model.
Therefore, every row of data in the database is linked with another row using a primary key. Similarly, every
table is linked with another table using a foreign key. Refer to the diagram below and notice how the concept of
'Keys' is used to link two tables.
Relational Database Example
Due to this introduction of tables to organize data, it has become exceedingly popular. In consequence, they are
widely integrated into Web-App interfaces to serve as ideal repositories for user data.
What makes it further interesting is the ease in mastering it, since the language used to interact with the
database is simple (SQL in this case) and easy to comprehend. In Relational databases, scaling and traversing
through data is quite a lightweight task in comparison to Hierarchical Databases.
• Example: MySQL, PostgreSQL, and Oracle Database are some popular relational databases.
Cloud Databases
A cloud database operates in a virtual environment hosted on cloud computing platforms. It is designed for storing,
managing, and executing data over the internet, providing flexibility and scalability. Cloud databases are widely used for
applications requiring dynamic workloads, as they eliminate the need for on-premises infrastructure.
Common cloud services for accessing and managing databases include SaaS (Software as a Service) and PaaS (Platform as a
Service), which simplify database operations for businesses. Popular cloud platforms offering database services include:
Amazon Web Services (AWS), Google Cloud Platform (GCP), Microsoft Azure, ScienceSoft, etc.
Centralized Databases
A centralized database is a database stored and managed at a single location, such as a central server or data center. It
ensures higher security and consistency as all data are maintained in one place, making it easier to control and manage.
Users can access the database remotely to fetch or update information. Centralized databases are commonly used in
enterprise systems where data consistency and security are critical. However, scalability and performance limitations should
be carefully considered.
NoSQL Databases
A NoSQL database (short for "non-SQL" or "non-relational") provides a mechanism for storing and retrieving data that does
not rely on traditional table-based relational models. Instead, it uses flexible data models like key-value pairs, documents,
column families, or graphs, making it ideal for handling unstructured, semi-structured, and structured data.
NoSQL databases are known for their simplicity of design, horizontal scalability (adding more servers for scaling), and high
availability. Unlike relational databases, their data structures allow faster operations in certain use cases. MongoDB, for
instance, is a widely used document-based NoSQL database
Different managers in DBMS model and their functionalities
A Database Management System (DBMS) utilizes various "managers" or components to handle different aspects of data
management. These managers work together to ensure efficient storage, retrieval, and manipulation of data, while also
maintaining data integrity and security.
The key managers in a DBMS model and their functionalities are:
Storage Manager: This component acts as an interface between the data stored on disk and the queries received. It is
responsible for managing the physical storage of data, including:
File Manager: Manages the allocation and deallocation of disk space for data files and the data structures used to represent
information.
Buffer Manager: Handles the transfer of data between main memory (buffer) and secondary storage (disk) to optimize
performance.
Authorization Manager: Enforces access control, verifying if a user has the necessary privileges to perform requested
operations.
Integrity Manager: Checks and enforces integrity constraints (e.g., primary keys, foreign keys, check
constraints) when data is modified.
Transaction Manager:
This manager ensures the atomicity, consistency, isolation, and durability (ACID properties) of transactions.
It controls concurrent access to the database, ensuring that multiple transactions can execute without
interfering with each other and that the database remains in a consistent state.
Query Processor:
This component is responsible for interpreting and executing database queries (e.g., SQL queries). It
includes:
DDL Interpreter: Processes Data Definition Language (DDL) statements to define the database schema.
DML Compiler/Optimizer: Compiles Data Manipulation Language (DML) statements into an execution
plan and optimizes the plan for efficient data retrieval and modification.
Query Execution Engine: Executes the optimized query plan to retrieve or modify data.
DBMS Components (Actors)
A database management system (DBMS) consists of several key components that work together to manage
data. These components can be broadly categorized as: Hardware, Software, Data, Procedures, and People.
Additionally, actors within a DBMS can be categorized as either Actors on the Screen (end-users or applications
interacting directly with the database) or Workers Behind the Screen (those managing and maintaining the
database).
1. Hardware:
•This includes the physical components like computers, storage devices (hard drives, SSDs), and network
infrastructure that house and provide access to the database.
•It's the foundation upon which the DBMS operates.
2. Software:
•This encompasses the DBMS software itself, including the database engine, utilities, and application
programs that interact with the database.
•The software manages data storage, retrieval, and manipulation.
3. Data:
•This is the core information stored within the database, including raw facts, figures, text, images, and other
digital content.
•Data can be further categorized into user data (actual information), metadata (data about data), and
application metadata (structure and format of queries).
4. Procedures:
•These are the rules, instructions, and guidelines that govern how the DBMS is designed, used, and
maintained.
5. People: include steps for installing software, backing up data, and managing user access.
•Examples
•Users: Individuals, applications, or other systems that interact with the database.
• End-users: Interact with the database through applications to retrieve or modify data.
• Application Programmers: Develop applications that interact with the database.
• Database Administrators (DBAs): Manage and maintain the database system.
• Database Designers: Design the database structure and schema.
• Database Developers: Create and implement database solutions.
• Database Testers: Ensure the quality and reliability of the database.
Actors
Actors on the Screen (End-users and Applications):
•These are the users or applications that directly interact with the DBMS to perform operations such as
querying, updating, or deleting data.
Workers Behind the Screen (DBAs, Developers, etc.):
•These are the individuals who work behind the scenes to manage, maintain, and develop the DBMS and its
associated applications.
In essence, the DBMS acts as a bridge between the physical hardware and the users, providing a
structured and efficient way to manage data.
Data Models- Schemas and Instances
In a Database Management System (DBMS), schemas and instances represent distinct but related aspects
of a database.
Schema:
A schema is the logical design or blueprint of a database. It defines the structure of the data, including:
•Table definitions: The names of tables, their columns, and the data types of those columns.
•Relationships: How different tables are related to each other (e.g., through foreign keys).
•Constraints: Rules and limitations on the data, such as primary keys, unique constraints, check constraints,
and referential integrity constraints.
•Views: Virtual tables based on the results of a query.
•Indexes: Structures that improve the speed of data retrieval.
Schemas are relatively static and change infrequently, typically only when the fundamental structure of the
database needs modification.
Instance:
An instance refers to the actual data stored in the database at a specific point in time. It is a snapshot of the
database's content, reflecting the current values within the defined schema.
•Data values: The rows and columns of data within each table.
•Current state: The exact information present in the database at that moment.
Instances are dynamic and change frequently as data is added, modified, or deleted through various
database operations (e.g., INSERT, UPDATE, DELETE).
PRACTICAL EXAMPLE TO UNDERSTAND THE CONCEPT
Consider a house. The schema is like the architectural blueprint, defining the number of rooms, their
dimensions, the location of doors and windows, and the plumbing and electrical systems. The instance is
the actual house built according to that blueprint, with all the furniture, appliances, and occupants present at
a given time. The blueprint (schema) remains largely unchanged, while the contents of the house (instance)
can be constantly rearranged or updated.
Data Modeling
Data modeling is the process of creating a visual or conceptual representation of data objects and their relationships to one
another within a system. It provides a structured way to define and organize data, ensuring consistency, accuracy, and
efficiency in data storage and retrieval.
Various Ways of Data Modeling:
Conceptual Data Model:
Purpose: Provides a high-level view of the business entities and their relationships, independent of any specific technology
or implementation details. It focuses on "what" the business needs.
Example: In an e-commerce system, a conceptual model might show entities like "Customer," "Order," and "Product," with
relationships such as "Customer places Order" and "Order contains Product." It would not specify data types or database
tables.
Logical Data Model:
Purpose: Translates the conceptual model into a more detailed representation that defines the structure of data, including
attributes, data types, and relationships, without specifying the physical storage mechanism. It focuses on "how" the data is
structured.
Example: Building on the e-commerce example, a logical model would define attributes for "Customer" (e.g., CustomerID,
Name, Email), "Order" (e.g., OrderID, OrderDate, TotalAmount), and "Product" (e.g., ProductID, ProductName, Price). It
would also specify relationships with primary and foreign keys.
Physical Data Model:
Purpose: Represents how the data is physically stored in a specific database system, including details like tables, columns,
data types, indexes, and constraints. It focuses on "where" and "how" the data is physically implemented.
Example: For the e-commerce system, a physical model would specify the exact SQL DDL statements to create tables,
define column data types (e.g., VARCHAR, INT, DECIMAL), and add indexes for performance optimization in a relational
database like MySQL or PostgreSQL.
Dimensional Data Model (for Data Warehousing):
Purpose: Designed for analytical processing and reporting in data warehouses. It typically uses a star schema or snowflake
schema, separating data into "fact" tables (containing measures) and "dimension" tables (containing descriptive attributes).
Example: In a sales data warehouse, a "Sales Fact" table might contain measures like "Quantity Sold" and "Revenue," linked
to dimension tables like "Time," "Product," and "Customer," allowing for efficient aggregation and analysis of sales trends.
Object-Oriented Data Model:
Purpose: Represents data as objects with properties and methods, similar to object-oriented programming paradigms. It
handles complex data types and relationships more naturally than traditional relational models.
Example: In a CAD application, an object-oriented model might represent "Design Elements" as objects
with attributes like "color" and "material," and methods for "rendering" or "modifying."
Graph Data Model:
Purpose: Focuses on relationships between data entities, representing data as nodes (entities) and edges
(relationships) with properties. It is well-suited for highly connected data.
Example: In a social network, a graph model would represent "Users" as nodes and "Friendships" or
"Follows" as edges, allowing for efficient traversal and analysis of network connections.
Generalization, Specialization and Aggregation in ER
Model
Using the ER model for bigger data creates a lot of complexity while designing a database model, So in order to
minimize the complexity Generalization, Specialization and Aggregation were introduced in the ER model. These
were used for data abstraction. In which an abstraction mechanism is used to hide details of a set of objects.
Data abstraction:
Data abstraction in a Database Management System (DBMS) is the process of hiding the complex details of data
storage and organization from the end-user, presenting only the necessary and relevant information. This simplifies
interaction with the database and enhances data security by concealing implementation specifics.
Generalization
Generalization is the process of extracting common properties from a set of entities and creating a generalized entity
from it. It is a bottom-up approach in which two or more entities can be generalized to a higher-level entity if they have
some attributes in common.
Example: STUDENT and FACULTY can be generalized to a higher-level entity called PERSON as shown in diagram
below. In this case, common attributes like P_NAME and P_ADD become part of a higher entity (PERSON) and
specialized attributes like S_FEE become part of a specialized entity (STUDENT).
Generalization is also called as 'Bottom-up approach'.
Specialization
In specialization, an entity is divided into sub-entities based on its characteristics. It is a top-down approach where the
higher-level entity is specialized into two or more lower-level entities.
Example: an EMPLOYEE entity in an Employee management system can be specialized into DEVELOPER, TESTER, etc.
as shown in figure below. In this case, common attributes like E_NAME, E_SAL, etc. become part of a higher entity
(EMPLOYEE) and specialized attributes like TES_TYPE become part of a specialized entity (TESTER).
Specialization is also called as "Top-Down approach".
Inheritance
It is an important feature of generalization and specialization. In specialization, a higher-level entity is divided into
lower-level sub-entities that inherit its attributes. In generalization, similar lower-level entities are combined into a
higher-level entity that holds common attributes. In both cases, inheritance allows sub-entities to reuse the properties of the
parent entity.
[Link] inheritance: It allows lower level entities to inherit the attributes of higher level entities and vice versa. In
diagram Car entity is an inheritance of Vehicle entity ,So Car can acquire attributes of Vehicle. Example: Car can acquire
Model attribute of Vehicle.
[Link] Inheritance: Sub-entities also inherit relationships of the parent entity.
[Link] Inheritance: Sub-entities can override or add their own attributes or behaviors different from the parent.
[Link] inheritance: Participation inheritance in ER modeling refers to the inheritance of participation constraints
from a higher-level entity (superclass) to a lower-level entity (subclass). It ensures that subclasses adhere to the same
participation rules in relationships, although attributes and relationships themselves are inherited differently.
Example: In diagram Vehicle entity has an relationship with Cycle entity, but it would not automatically acquire the
relationship itself with the Vehicle entity. Participation inheritance only refers to the inheritance of participation constraints,
not the actual relationships between entities.
Aggregation
An ER diagram is not capable of representing the relationship between an entity and a relationship which may be required in
some scenarios. In those cases, a relationship with its corresponding entities is aggregated into a higher-level entity.
Aggregation is an abstraction through which we can represent relationships as higher-level entity sets.
Example: an Employee working on a project may require some machinery. So, REQUIRE relationship is needed between the
relationship WORKS_FOR and entity MACHINERY. Using aggregation, WORKS_FOR relationship with its entities EMPLOYEE and
PROJECT is aggregated into a single entity and relationship REQUIRE is created between the aggregated entity and MACHINERY.
Aggregation is also called as "Higher-Order Relationship".
Representing Aggregation Via Schema
To represent aggregation in a relational schema, follow these steps:
1. Create Schema for the Aggregated Relationship
•This will be treated like an entity set.
•It includes the primary keys of the participating entities in the base relationship.
•It also includes any descriptive attributes of the base relationship.
2. Create Schema for the Higher-Level Relationship (Aggregation)
•This schema includes: The primary key of the aggregated relationship schema.
•The primary key of the associated entity it relates to.
•Any additional descriptive attributes of this higher-level relationship.