DBMS Handwritten Notes
DBMS Handwritten Notes
Originality Assessment
13%
Overall Similarity
v 9.0.2 - WML 4
DBMS
Introduction
act as the foundational framework for efficient data organization and accessibility. This
SQL stands for “Structured Query Language”. It is a widely used language to communicate
with databases. When you read the full form of SQL, it is important to read about its origins
Originally SQL was developed in the 1970s by IBM which became the primary language for
industries to interact with relational databases. Its primary purpose is to provide a way to
perform CRUD 45 (create, read, update, and delete) operations on data in databases. SQL
functions as a declarative language that enables users to specify what they want to
achieve.
SQL is not tied to any database management system. It is a language not software which
can be used across different platforms and RDBMS like MySQL, PostgreSQL, Oracle, SQL
server, etc.
important for data handling. DBMS functions through three fundamental layers known as
The external Layer is also known as a view or user interface layer where direct interaction
occurs between the user and the database. It represents different view perspectives of the
database to different users or groups of users. This layer allows one to interact with the
At this layer, user can define their own customized view of data with the help of schemas
that describe how data is organised. Database schema supports abstraction that hides
internal details of database structure that help users retrieve and manipulate data related
to their task.
Moreover, this layer supports data independence separating the way data is stored from
the way it is perceived by users. For example, a marketing team might have a different
view of customer data than a finance team which is an example of modifying a schema for
Conceptual Layer
architecture which acts as an intermediary between the Internal Layer and the External
layer. At this level, you will find a 11 complete logical structure of the entire database of
your organization. For example, if you have an Employee database at this level it will show
you all the tables and attributes related to the employee database like entity, type of
The Conceptual layer defines the logical structure of dataBASE using data models like the
Entity-Relationship model (ER model). It represents entities, their relationship, and the
constraints that govern the data. The layer focuses on data integrity, ensuring that the data
stored is accurate, consistent, and follows all the defined rules and relationships.
Internal Layer
The Internal layer is also called the physical layer or storage level. It represents how data
is physically stored, processed and retrieved by our computer system. The physical layer
manages the actual data storage structure and access paths to optimize performance
The layer involves translating the logical representation from the conceptual layer into
actual storage like indexes, files, and data blocks on the storage devices. These layers
deal with storage techniques like data indexing, data compression, and data retrieval or
It creates indexes to the data so data can be searched and retrieved easily and quickly.
It compresses the 39 data in such a way that it consumes less space and the quality of
It also divides the large tables into smaller partitions for better performance.
management system and understanding these will help to know how data is stored,
processed, and retrieved in any application management system.
When it comes to managing data effectively with ease ensuring data accuracy and
reliability, the database management systems provide very important properties referred to
DBMS and include 12 Atomicity, Consistency, Isolation, and Durability. These properties
work together to ensure data integrity and data consistency of your confidential and
Atomicity
Atomicity states that in a single transaction, there are 2 and only 2 scenarios that can take
place which is either the transaction will get completed successfully or the transaction will
the process to stop. In more simple words, consider a scenario of transferring money
between two bank accounts as sender and receiver. Now 10 atomicity property ensures
that this action happens completely (the sender sends the money and the receiver receives
the money) or the action does not take place at all (the sender does not send and the
receiver also does not receive). There is no halfway means there is no scenario that can
take place where the sender sends the money but the receiver does not receive it.
Hence, Each step of the transaction, from deducting 10 from one account to crediting to
another account is treated as a single operation or indivisible unit. If any error occurs in
between this process then the entire transaction is reverted to reach the original state. This
prevents any partial updates and ensures data is not left in an inconsistent or incomplete
Consistency property ensures that your data remains in a valid state before and after the
execution of the transaction while following all the defined rules, constraints, and
relationships. Every successful transaction must bring 12 the database from one valid
state to another valid state. You can understand it as maintaining the logical balance of
The rules can involve different things like maintaining correct relationships between
different data points (for example, customer name always having a corresponding
customer ID) data values should be in a defined range (age cannot be negative), or data
break this rule and try to insert the data against the rule then consistency rejects such a
entry t be inserted in a database. This maintains the data integrity by preventing the
Isolation
doesn’t interfere with each other because each transaction occurs independently like all
the transactions are executed in a sequential order rather than occurring simultaneously
Consider a scenario where two users 31 at the same time update the same record in a
database, at this moment the Isolation property will ensure that until one update from one
user does not get completed and updated the second user will not be able to make any
change on the same record. This prevents data update conflicts and maintains data
consistency.
Durability
Durability ensures that once the transaction is completed successfully, then its effects are
permanently stored in the database and are protected from any further potential harm.
Imagine writing a very important and confidential report on recent data updates and 12 if
there is a power outage or sudden system crash then the durability property of DBMS
ensures that the updated data still exists and is accessible. This helps you to keep your
data safe, and secure, protect against data loss, avoid data leakage, and ensure it is
These ACID properties form the strong foundation of a reliable and robust database
system.
The database is a very important factor in the emerging digital world because it is only the
central place on which we rely. In the end, the data is stored in the databases. But have
you ever imagined what these database systems do other than storage? So DBMS offers a
multiple set of functions that help data managing efficiently and error-free. Below are the
10 most important DBMS functions that make data a top priority of DBMS.
Data Definition and Modelling - DBMS allows you to define the structure of data to be
stored in the database including all the tables, data types (number, boolean, text, string,
etc), setting data constraints, and relationships between different entities and different
tables. This helps to maintain consistency and prevents errors like entering any misleading
Data Manipulation (CRUD operations) - DBMS provides you with the power to interact with
your data and perform CRUD operations that involve creating, reading, updating, and
deleting data. It involves performing operations like adding any new record, retrieving any
existing ones from the database, modifying any existing record, and removing irrelevant
Data Retrieval and Reporting - Users can retrieve the data from the database using the
standard database query language like SQL. 9 These queries allow users to fetch
specific information from data tables based on requirements, conditions, filters, sorting,
Data Security and Integrity - DBMS ensures data security by implementing techniques like
data encryption, access controls, authentication, and audit trails to protect the data from
any unauthorized source, accidental data deletion or modification, and any kind of
unexpected attacks. Data integrity is ensured with the help of data constraints and
data from any conflicts. This is covered in 31 the isolation property of DBMS which
prevents the data updation from only one user at a time so that the one update is reflected
to all the concurrent users and then one by one in a sequential order users can make the
strong data backup and recovery functions. Regular backups 54 create a copy of your data
at specific intervals which act as a precaution from sudden failures like system crashes,
power outages, or even human errors. The recovery option allows you to bounce back or
jump to the previous valid 23 state of the database minimize the downtime and avoid any
data loss.
Data Optimization and Performance - As the data grows with time, your need for storage,
speed, and efficiency grows. DBMS provides various optimization techniques like data
indexing, data partitioning, and caching to minimize the response time and ensure smooth
data operations. This helps to maintain the time data consumes in the database to buffer
and minimizes the user waiting time.
Transaction management - DBMS ensures that the ACID properties for transactions are up
and running every time. It manages each transaction to ensure anything interacting with
the database is not creating any harm and using it under all defined rules and constraints.
Data sharing and Collaboration - DBMS facilitates collaboration by allowing the sharing of
information by granting different access levels to different users and interacting with the
data from your system. It allows teamwork and makes data-driven decisions fast.
User Interface - DNMS provides a user-friendly interface for interacting with the database
for daily data needs. It includes GUI (Graphical user interface), and CLI (command line
interface) that allows you to interact with the database by executing queries and managing
Imagine your school or college's library, and now you have to arrange all the books on
every subject. How would you arrange them to make information easy to find and manage?
Database structures serve a similar purpose in the digital world where they provide a
framework and different structures to organize data efficiently. Below are the 5 major types
of database structures, each with unique characteristics and ideal use cases.
Hierarchical structure is a tree-like format where data is organized. You can picture it
similar to the family tree where each child has a single parent and a parent can have
multiple children. Hierarchical databases mirror the same family tree-like structure to
represent and organize the data. The structure denotes the top-down approach but follows
a specific path where data flows hierarchically. The data in this structure has one-to-many
relationships where data is organized in a tree similar to a folder structure in your computer
system.
In simpler words consider a scenario of any organization. Now how data or information is
passed from management to all the company employees. First comes as CEO, then
different department heads, then different teams, and then passed to employees. So this
complete structure creates a very deep level of hierarchy because there can be multiple
teams, multiple employees, and different leads on different levels. So retrieving the data
from this type of structure needs navigation starting from the top to visiting specific
branches.
The example of this structure can be corporate charts, File systems, etc.
more complex relationships. It is a graph-like structure where each element can have
multiple parents as well as multiple children. The data elements can implement one-to-one
Visualize any social media handle where one can connect with multiple friends and friends
can in turn have their connections so the person can also be connected to friends of
friends. This structure provides flexibility from the strict hierarchy of other models.
Examples of this 27 structure can be any social network, airline reservation system, or
telecommunication network.
Relational database structure
The relational database management system (RDBMS) organizes the data into tabular
form containing rows and columns. The rows are referred to as records and the columns
are referred to as attributes. This is the most popular used database across industries
which uses standard language like SQL to retrieve the data. It has a similar structure to a
The table establishes the relationship using keys like primary keys, foreign keys, composite
keys, etc. There is a single key field in every table that uniquely identifies a record which is
known as the primary key. A key which helps to link a table with ano another table with
common information is referred to 3 as a foreign key. This key type management allows
easy and simple retrieval of 1 data from the database and efficient data manipulation with
form of objects encapsulating both data and data methods (behaviour) in a single unit
high set of functionality can use an object-oriented database structure because it stores
easily.
Consider any e-commerce platform where any product 24 is represented in the form of an
object that contains multiple attributes like name, price, description, different feature
attributes, and reviews which are dynamic to store and an object-oriented structure works
These are also known as NoSQL databases that offer diverse models to handle massive,
stores the data in the form of documents that are stored using the key and value pairs
which typically look similar to JSON or XML files. It allows flexibility in data representation.
Consider a library where each book is stored as a document that contains various
attributes like author, title, total pages, and genre represented in structured, semi-
structured, and unstructured formats. The database which supports this type of structure
An example of this database 27 structure can be any IOT or sensor data storage.
help organizations with efficient data management activities like data storage, easy
retrieval, simple data manipulation, data cleaning, etc. At the top knowledge, the DBMS
serves as a middleman between users and databases, enabling seamless interaction while
ensuring data authentication, security, integrity and reliability. DBMS ensures 4 that the
data stored in the database is safe from unauthorised access and with correct access it
overlapped.
In practical terms, DBMS acts as a librarian or a gardener taking care of your complete
library or garden, preserving it from any inconsistencies and providing functions and
methods to easy to access each thing. DBMS is not just about storing the data, it also
helps in analyzing the data and helping businesses make the data-driven decisions that
drive business success. It is also used to create amazing interactive data reports that are
legal and authorised third-party power BI tools like Tableau or Power BI and accessing the
database tables and data directly 24 in the form of different graphs and charts.
In the vast amount of data available around up, different databases come into play that
provide you with some unique features to manage and act on your data efficiently and
effectively.
MySQL
MySQL is a relational database management system that was launched in 1995 by two
software engineers. The most common use case which drives the popularity of MySQL
was for web applications because it was so easy to get the data submitted from UI to save
into 9 the database, and retrieve the data from MySQL based on conditions and easily
render the data in JSON format to display on UI. MySQL is easy to connect with multiple
applications built in different languages including Java, Python, Scala, PHP, etc.
MySQL is an ideal choice for multiple businesses because of its structure and data
indexing capabilities to handle complex data and write queries easily based on different
filters. MySQL is available with two licensing models that include a free community server
and a proprietary enterprise edition. It comprises all ACID properties that help maintain
data consistency. It allows horizontal partitioning which means if your application is using
MySQL then you will get high throughput with low latency.
PostgreSQL
1996. The complete database is written in C and is mostly used by companies that deal
with large volumes of structured data. It 4 is an open-source database that offers object-
oriented capabilities, advanced data types, and built-in analytical functionalities. Postgre
also offers a UI from where you can directly write your queries in the SQL console and
A lot of gaming apps, and automation tools use this database and due to its active
including advanced data indexing like partial index and bloom filters which 7 allow you to
create a non-blocking index. It also provides various plugins and supports geospatial data
hence the database is also preferred for geospatial applications, and businesses requiring
15 When it comes to using the NoSQL database for any application MongoDB is the go-to
and first choice of any enterprise. It is quite difficult to load and access the data into
RDBMS using an object-oriented approach when you have data coming from 1 a diverse
set of factors and need to store data in different forms or refer to it as a document because
in that case, you need to do the additional application-level mapping of data. MongoDB
comes into the picture to resolve the issue, especially in handling document data. You 7
do not need to deal with tabular structure anymore because you can store the data object
MongoDB is written in C, C++, and javascript which was launched in back 2009. The
database 28 can be used for mobile, web, and even for real-time analysis. MongoDB
comprises features like high performance, great availability, and easy scalability. It even
supports graph-based search or geo search, map-based queries, and text-based queries
to search documents. You can also optimize your MongoDB queries for the output and
now MongoDB is used with multiple applications because it is easy to find the Mongo client
SQLite
pre-configured with multiple applications and does not require any separate server
process. It means that for each database you use in your application, you need to first start
the database server locally and then your application server to use the database and run
the application error but this is not the condition in SQLite because by running your
application server it ensures that SQLite is configured and running along with your
application.
SQLite is lightweight, and it provides high reliability, zero configurations, and cross-platform
usage. It is useful in 1 mobile applications, and desktop software with great simplicity.
Neo4j
between complex data entities. It serves as a visualizing map that will help you understand
or illustrate the complete database or application architecture. These properties make this
database an ideal choice for e-commerce platforms, social media networks, and
recommendation engines.
Its main ability is to easily 55 visualize the entire network where it explains and implements
the data flow in a large network-based architectural application. It uses the property graph
model and provides query optimization techniques for easy traversing for data retrieval
which makes it simple to grab relationships where connection between data entities is
important.
IBM IMS
IBM's 40 information management system is a hierarchical database that follows the top-
down approach representing an organization tree. It stands out by representing the high
models organize the data hierarchically which is useful in applications like the finance
sector where data follows a strict hierarchical order. It is better to use 10 if you have a
Redis
Redis was introduced by one Italian developer while facing issues in scalability with
key-value store. Currently redis is popularly used as a distributed cache and message
broker with very good durability. It supports 55 a wide variety of data structures and data
types including string, boolean, hashes, lists, sets, bitmaps, hyperlogs, ordered sets with
Redis supports automatic failover means when your primary server fails to start then it
automatically switches to another server ensuring the application does not experience any
downtime and is consistently up and running. It also supports sharding using Redis cluster
There are many more databases to explore of different structures and the choice depends
characteristics. Below are some factors 25 that can be considered while choosing the
Data Complexity - Decide what type of data your application deals with. 3 types of data are
ingested which include structured data (table-based), semi-structured (table and other data
types), and unstructured (document types). And decide how much your data is structured
to know if is there any strict relationship in data that needs to be followed and what level of
Query Patterns - How you and your users will able to access 1 data from the database.
What types of queries are common, easy, and you are familiar with?
Scalability - How much data do you expect to store in the next 10 years and how quickly
Performance - What is the response time expected to get the data from the database?
Flexibility - Do 9 you want to make regular changes to your database schema or changes
DBMS goes beyond mere data storage; it provides a systematic and structured approach
to organizing vast amounts of information. Unlike traditional file systems, DBMS ensures
Expanding on this, consider the analogy of a digital library. In a conventional file system,
books might be scattered across various shelves, making it challenging to find a specific
one. DBMS, however, acts like a librarian, meticulously organizing books based on genres,
authors, and other criteria. This ensures not only efficient storage but also quick and
Data Integrity:
Maintaining the accuracy and consistency of data is paramount for reliable information.
DBMS achieves this through the implementation of constraints and rules that 23 ensure
data remains consistent throughout its lifecycle, preventing discrepancies and errors.
Let's illustrate this with a real-world scenario. In a banking system, where financial
transactions are recorded, data integrity is critical. Without DBMS, there's a higher risk of
discrepancies. DBMS enforces rules that mitigate these risks, providing a reliable
foundation for financial data management.
Data Security:
In the digital age, where cyber threats are prevalent, ensuring 4 data security is a primary
security measures, unauthorized access to patient records could lead to privacy breaches
and legal ramifications. DBMS steps in with encryption techniques, access controls limiting
data access to authorized personnel, and audit trails that track every interaction with the
Concurrency Control:
Data Independence:
The ability to make changes to the database structure without affecting the applications
using it is known as data independence. DBMS provides this layer of abstraction, allowing
with DBMS, 30 the addition of new fields can be seamlessly incorporated, ensuring
Consider a retail business that relies on DBMS to track inventory levels, manage customer
information, and analyze sales trends. The ability to efficiently organize and retrieve data
2. Healthcare:
The healthcare industry relies on DBMS 7 for storing and managing patient records,
medical history, and other critical data. It enables healthcare professionals to access
doctor needs to retrieve a patient's medical history during a consultation, DBMS ensures
quick access to relevant information. This not only enhances the efficiency of healthcare
3. Education:
Educational institutions leverage DBMS for managing student records, grades, and course
information. This aids in administrative tasks such as enrollment, grading, and generating
academic reports.
streamlines the management of student records, making it easier for administrators to track
enrollment, assign grades, and generate reports on academic performance. The efficiency
4. E-commerce:
The dynamic nature of e-commerce demands efficient data management. DBMS supports
seamless operations.
In the e-commerce sector, where thousands of transactions occur daily, DBMS ensures the
experiences. 15 The ability to handle large volumes of data efficiently is a key factor in the
5. Telecommunications:
data, call records, and network configurations. It ensures the smooth functioning of
communication networks.
utilised 15 to store and manage subscriber information, track call records, and optimize
network performance. The reliability and scalability of DBMS contribute to the seamless
primary key 3 serves as a unique identifier for each record in a table, ensuring data
A primary key uniquely identifies each record, preventing duplicate entries and serving as a
reference point for establishing relationships between tables. It ensures the uniqueness
as the primary key. This unique identifier distinguishes each customer, preventing the
inclusion of duplicate entries and forming the basis for establishing relationships with other
Natural Keys: Use existing, naturally occurring attributes (e.g., social security number).
Surrogate Keys: Introduce a new attribute solely to serve as the primary key.
Consider the scenario of a customer database. A natural key could be the customer's
phone number, which is an existing and unique attribute. 3 On the other hand, a
surrogate key could be a system-generated customer ID, introduced solely to serve as the
primary key. The choice between natural and surrogate keys 5 depends on factors such
1. Data Storage:
Databases act as a centralised repository for storing 33 structured and unstructured data.
Consider an online library database that stores information about books, authors, and
borrowers. The database efficiently organizes and stores this information, making it easily
2. Data Retrieval:
Databases enable quick and efficient retrieval of specific information through queries and
search operations. In a customer database, for example, authorized users can utilize 15
Structured Query Language (SQL) to formulate queries that extract relevant information.
This process of data retrieval is a fundamental aspect of database functionality and plays a
3. Data Analysis:
complex queries and data processing. Consider a scenario where a business analyzes
sales data to identify trends and patterns that inform marketing strategies. The database
becomes a valuable tool for extracting actionable insights from large datasets.
4. Data Modification:
Databases allow easy updates, insertions, and data deletions, ensuring information is
always current. For example, an e-commerce platform can modify inventory levels in real-
time as products are purchased, ensuring accurate stock information and preventing
overselling.
5. Data Sharing:
shared efficiently.
45 Structured Query Language (SQL) acts as the universal language for communicating
with relational databases. It serves as a standardized method 48 for users to interact with
SQL simplifies the process of managing and extracting information from 1 databases,
making it an essential tool for anyone involved in working with relational database
for database interactions, regardless of the specific RDBMS being used, fostering
Components of SQL:
FirstName VARCHAR(50),
LastName VARCHAR(50),
DepartmentID INT,
);
We can use DML to retrieve employee names from the Employee table:
specific user:
SAVEPOINT: Sets a point within a transaction to which you can later roll back.
-- Start a transaction
BEGIN;
COMMIT;
Let's delve into the distinctions between 7 Database Management System (DBMS) and
1. DBMS:
Functionality:
A DBMS, or Database Management System, serves as a software suite that enables the
encompasses various types of systems, including those that don't strictly adhere to the
relational model.
In a DBMS scenario, the management of data does not necessarily involve enforcing
relationships between tables. Unlike the rigid structure of relational databases, a DBMS
may allow for more flexibility in how data is organized. It might involve storing data in a
hierarchical or network model, and relationships between entities may not be explicitly
defined.
DBMS systems, in general, lack robust support for enforcing data integrity through
constraints like 18 primary and foreign keys. Constraints are rules applied to columns in a
table to ensure the accuracy and consistency of data. Without these constraints, there is a
higher risk of data redundancy and inconsistencies, as there are no mechanisms in place
Scenario Illustration:
Consider a scenario where a simple file system is used as a form of DBMS. In this setup,
data is stored without a predefined structure or relationships between entities. Files may be
organized in a manner that suits the immediate needs of users, but there is no inherent
2. RDBMS:
Functionality:
where data is organized into tables, and relationships between these tables are explicitly
defined.
Emphasis on Relationships:
relationships between tables. Tables are linked through keys—primary keys uniquely
identify records within a table, and foreign keys 18 establish relationships between tables.
One of the defining features of an RDBMS is its robust support for data integrity through
constraints. Constraints, such as primary keys, foreign keys, unique constraints, and check
constraints, ensure that data adheres to specified rules. This guarantees the accuracy and
RDBMS systems are well-suited for complex scenarios where multiple users 4 interact
with the database simultaneously. The relational model, with its structured and normalized
approach to data, provides a framework that facilitates efficient data retrieval, and
Scenario Illustration:
needs to manage customer information, product details, and sales transactions. In this
relational model, tables such as Customers, Products, and Orders are created, and
relationships between them are established through keys. Constraints ensure that each
customer 6 has a unique identifier (primary key) and that orders are correctly associated
19 In summary, while both DBMS and RDBMS are systems for managing databases, the
key distinction lies in their adherence to the relational model and the robust support for
enforcing relationships and constraints in RDBMS. The choice between them depends 3
on the specific needs of the application, with RDBMS being preferred for scenarios where
data integrity, relationships, and a structured approach to data organization are paramount.
Types of Databases
Databases come in various types, each designed to address 17 specific data storage and
retrieval needs.
1. Relational Databases:
organized into tables, each with a specific purpose. SQL queries are then employed to
retrieve, update, or insert data into these tables, providing a standardized and efficient way
2. NoSQL Databases:
Expanding on this, consider the flexibility of NoSQL databases like MongoDB. They can
handle diverse data types, making them suitable for scenarios where data structures
evolve rapidly. The scalability of NoSQL databases allows them to efficiently manage large
3. Object-Oriented 7 Databases:
objects with attributes and methods. This aligns with the principles of object-oriented
programming, making it easier to model real-world entities and their interactions within the
database.
4. Graph Databases:
Expanding on this, consider a graph database like Neo4j. In scenarios where relationships
between entities are as crucial as the entities themselves, graph databases provide an
5. 7 Document Databases:
Expanding on this, consider a document database like MongoDB. Here, data is stored as
documents, allowing for flexible and schema-less data structures. This 1 is particularly
1. Online Courses:
There are various online platforms which offer great online courses with interactive
instructor-led training and query solving sessions which you can follow from the comfort of
your home and learn great skills. One such platform which offers you a great course along
with the guidance of industry experts is Brainlyst. Following these platforms, you can read
multiple blogs for free on any technical topic, and enrol in various courses where you get
self-paced learning as well as live instructor-led learning at your comfort.
Other platforms provide free as well as paid certification courses but these courses are
pre-recorded and you do not get live doubt-solving or instructor-led training. But this has a
huge community and discussion forums where people around the world participate to
discuss and solve each other queries. It includes platforms like Coursera, Udemy, and edX
Courses cover various aspects, from basic concepts to advanced topics like database
Consider enrolling in an online course that provides a structured learning path. Topics may
2. Books:
Books provide detailed insights into database theory and practical implementation.
Consider reading books that not only cover theoretical aspects of DBMS but also provide
practical examples and case studies. Textbooks like "Fundamentals of Database Systems"
by Ramez Elmasri and Shamkant B. Navathe offer a balance of theoretical concepts and
3. Practice:
database, design schemas, and implement queries to solve specific problems. Platforms
like LeetCode and HackerRank provide 1 a diverse set of challenges to enhance your
problem-solving skills.
Explore online tutorials and database documentation to grasp specific concepts and tools.
Official documentation for database systems like MySQL and PostgreSQL is rich in
resources.
Leverage online tutorials to dive deeper into specific topics. Database documentation,
Structure of DBMS
management.
Data Definition Language (DDL) is a subset of SQL used for defining and managing the
structure of a database. It includes commands for creating, altering, and deleting database
ProductName VARCHAR(100),
Price DECIMAL(10, 2),
CategoryID INT,
);
8 ProductID INT PRIMARY KEY: Declares a column named "ProductID" with the data
type Integer (INT) and designates it as the primary key for uniquely identifying each
product.
Price DECIMAL(10, 2): Specifies a column named "Price" with the data type Decimal,
representing a monetary value with 10 digits in total, 2 of which are decimal places.
CategoryID INT: Introduces a column named "CategoryID" of type Integer, which can store
foreign key relationship, linking the "CategoryID" column to the "CategoryID" column in
Importance of DDL:
DDL is crucial for database administrators and developers as it enables the definition of the
database's logical and physical structure. Properly designed tables, relationships, and
constraints lay the foundation for efficient 1 data storage and retrieval.
Data Manipulation Language (DML) comprises SQL commands responsible for interacting
with data stored in the database. It includes operations such as inserting, updating, and
deleting records.
Inserting Data:
INSERT INTO Product: Initiates the insertion operation into the "Product" table.
(ProductID, ProductName, Price, CategoryID): Specifies the columns to which values will
be inserted.
VALUES (1, 'Laptop', 1200.00, 2): Provides the actual 16 values to be inserted into the
CategoryID: 2.
INSERT INTO Product: Initiates the insertion operation and specifies the target table,
which is "Product" in this case. This statement indicates that new data is being added to
will be inserted. This part is essential 58 to ensure that the values provided in the VALUES
In this example, the columns are "ProductID," "ProductName," "Price," and "CategoryID."
VALUES (1, 'Laptop', 1200.00, 2): Specifies the actual 16 values to be inserted into the
ProductID: 1
ProductName: 'Laptop'
Price: 1200.00
CategoryID: 2
These values represent a new record 6 in the "Product" table, indicating that a product
with an ID of 1, named 'Laptop,' priced at 1200.00, and belonging to the category with ID 2,
Importance of DML:
DML operations are fundamental for managing the content of a database. Whether adding
new records, updating existing ones, or deleting unnecessary data, DML 12 ensures that
the database remains dynamic and reflects the evolving state of the application or
business.
3. Query Processor:
The Query Processor is a vital component responsible for interpreting and executing SQL
queries submitted by users or applications. Its primary tasks include query optimization,
Query Optimization:
1 SELECT ProductName, Price FROM Product WHERE Price BETWEEN 1000.00 AND
1500.00;
SELECT ProductName, Price: Specifies the columns that you want to retrieve from the
"Product" table. In this case, it's requesting the "ProductName" and "Price" columns.
FROM Product: Indicates the source table from which the data is to be retrieved, which is
WHERE Price BETWEEN 1000.00 AND 1500.00: Applies a condition to filter the results.
Only rows where the "Price" column falls within the specified range (between 1000.00 and
1500.00) will be included in the result set.
BETWEEN 1000.00 AND 1500.00: This is a range condition that ensures the "Price"
Execution Plan:
The generated execution 20 plan outlines the steps the database engine will take to fulfil
the query. It includes details on how tables will be accessed, which indexes will be utilized,
systems. Generating well-optimized execution plans ensures that queries are processed
It analyzes the query and determines 49 the most efficient way to execute it. This 42
involves considering factors such as available indexes, statistics on the data distribution,
4. Storage Manager:
The job of the storage manager is to ensure efficient Data Storage and Retrieval. The
Storage Manager is responsible for the physical 40 organization and retrieval of data on
disk. It ensures that data is stored efficiently to minimize disk space usage and facilitates
ON Product (Price): Specifies the table ("Product") and the column ("Price") on which 6
Indexing Benefits:
speed. The index serves as a data structure that allows the database engine to locate
Efficient storage and retrieval mechanisms 12 are crucial for maintaining optimal database
performance. The Storage Manager's role in managing indexes, organizing data on disk,
and optimizing storage structures contributes to the overall responsiveness of the database
system.
Language (DML), Query Processor, and Storage Manager work cohesively to define,
manipulate, process queries, and manage the physical storage of data in a Database
Management System (DBMS). Each component plays a critical role in ensuring the
Classification in DBMS
table represents an entity, and relationships between tables are established through keys.
The relational model ensures data integrity, flexibility, and efficient querying through the
stored in one table, course details in another, and the relationship between them
maintained through unique identifiers. 19 The use of SQL allows for seamless retrieval of
as objects, each encapsulating attributes and behaviours. This model aligns closely with
real-world entities and their interactions, 5 making it suitable for applications with complex
data structures.
could be represented as an object with attributes like title, author, and publication date,
along with methods to perform actions such as checking out or returning the book. This
object-oriented approach simplifies the modelling of entities and their relationships in the
library system.
NoSQL DBMS: NoSQL (Not Only SQL) 4 Database Management Systems are designed
for scenarios where traditional relational databases may not be the best fit. NoSQL
comments, and media files, needs to be stored. NoSQL databases, like MongoDB, provide
a schema-less structure that accommodates the dynamic nature of social media data.
Each post or comment 62 can be stored as a document with varying attributes, allowing for
individual users or small-scale applications where a single user interacts with the database
at any given time. These systems are lightweight and suitable for scenarios with minimal
Consider a personal finance application where a single user tracks expenses, income, and
budgeting. A single-user DBMS, like Microsoft Access, provides a simple and effective
solution for managing the financial data of an individual user without the complexities
multiple users need 17 simultaneous access to the database. These systems are essential
for large-scale applications and enterprises where data is accessed and modified by
can browse products, place orders, and update their profiles simultaneously without
encountering data conflicts. Platforms like MySQL or Oracle provide the robustness
single central location. This model is suitable for scenarios where all users and data are
Consider a small local business using a centralized DBMS to manage its inventory and
sales. The simplicity of a centralized system ensures that all transactions and data
processing occur in one location, minimizing complexities associated with data distribution.
27 In the context of a global enterprise with offices in different regions, a distributed DBMS
ensures that data is stored closer to the users who need it. This reduces latency in data
dispersed locations.
tree-like structure, where each record has a parent-child relationship. This model is
Imagine a manufacturing process where products are categorized into different levels of
hierarchy based on their attributes. A hierarchical DBMS can efficiently represent this
structure, ensuring that each product is linked to its corresponding category and
subcategory. This 4 makes it easier to navigate and analyze the relationships within the
manufacturing process.
represent data relationships. Unlike the hierarchical model, the network model allows
structure.
transportation hubs, routes, and shipments. Each transportation hub may be linked to
multiple routes, and each route may serve multiple shipments. The network model
network.
use tables to organize data with predefined relationships between them. This model strikes
a balance between simplicity and complexity, making it widely adopted for various
applications.
DBMS can efficiently manage customer information, orders, and interactions. Each table,
such as Customers, Orders, and Products, is linked through keys, enabling seamless
retrieval and analysis of data. The relational model's clarity and standardization simplify the
of modern applications. They make it easy to store, find, and process data effectively.
Working behind the scenes, there's a special language known 17 as SQL (Structured
Query Language) that acts as the key to unlocking the full potential of these databases.
This exploration takes you on a technical tour, covering 20 the fundamental aspects of
databases, SQL, and related topics. It's designed to provide a deep dive for those who
In a database, we start with the structure, and Data Definition Language (DDL) is like the
toolbox for setting it up. With commands like 10 CREATE, ALTER, and DROP, DDL helps
create tables, set up indexes, and define how different parts of the database connect.
Example:
FirstName VARCHAR(50),
LastName VARCHAR(50),
);
In this example, the DDL command CREATE TABLE is used to define a table named
"Customers" with columns for CustomerID, FirstName, LastName, and Email. 6 The
PRIMARY KEY constraint ensures the uniqueness of the CustomerID, and the UNIQUE
Once the structure is ready, Data Manipulation Language (DML) takes over. DML is like
the control panel for managing the actual data in the database. It helps add new data with
INSERT, make changes with UPDATE, and remove data with DELETE. This is where we
Example:
In this example, the DML INSERT INTO command adds a new record to the Customers
table that contains the specified values for CustomerID, FirstName, LastName, and Email.
Now, think of Data Query Language (DQL) as the language we use to ask questions and
get answers from the database. The main command here is SELECT, which helps us
retrieve specific information. DQL lets us explore the data, ask complex questions, and get
Example:
-- Retrieving customer names with a specific email domain
'%@example.com%';
In this DQL example, the SELECT statement retrieves the FirstName and LastName of
customers from the "Customers" table whose email addresses contain the domain
"@example.com".
Then there's Data Control Language (DCL), which handles who can access the data and
what they can do with it. With commands like GRANT and REVOKE, DCL manages
permissions and keeps sensitive information secure. It's like setting rules for who can enter
Example:
In this DCL example, the GRANT command assigns the SELECT privilege on the
"Customers" table to a user named "User123," allowing them to retrieve data from that
table.
Structured Data:
format. It is typically stored in tables with predefined columns and data types. The
structured nature allows for efficient querying, indexing, and analysis, making it suitable for
Example:
FirstName VARCHAR(50),
LastName VARCHAR(50),
);
In this example, the "Customers" table is structured with columns like CustomerID,
FirstName, LastName, and Email. 8 The PRIMARY KEY constraint ensures each
customer has a unique identifier, and the UNIQUE constraint on the Email column enforces
uniqueness.
Unstructured Data:
Unstructured data lacks a fixed, predefined structure. It consists of a variety of file types 57
such as text documents, images, videos, and more. While providing flexibility, unstructured
data poses challenges for traditional databases due to its diverse formats. 33 Advanced
techniques, like natural language processing or machine learning, are often required for
effective analysis.
Example:
documents, PDFs, and images. This collection represents unstructured data, as there is no
Numeric:
Numeric data types handle numerical values and 57 come in different forms. INT is used
for integers, while DECIMAL is suitable for fixed-point numbers, providing precision and
2 Example:
ProductName VARCHAR(100),
Price DECIMAL(8,2),
QuantityInStock INT
);
Here, the Price column is of the DECIMAL data type, allowing for an accurate
Character:
Character data types store strings of characters. VARCHAR is for variable-length strings,
while CHAR is for fixed-length strings.
2 Example:
FirstName VARCHAR(50),
LastName VARCHAR(50),
JobTitle CHAR(30)
);
In this case, the JobTitle is a fixed-length string using the CHAR data type.
Date/Time:
Date/Time data types manage temporal data, allowing storage and manipulation of dates
2 Example:
OrderDate DATE,
DeliveryTime TIMESTAMP
);
Here, OrderDate represents the date, and DeliveryTime captures both date and time.
Boolean:
BOOLEAN data types represent true or false values, which help in logical operations and
decision-making.
Example:
TaskName VARCHAR(100),
IsCompleted BOOLEAN
);
In this scenario, the IsCompleted column is of BOOLEAN type, indicating whether a task is
completed or not.
Binary:
Binary 1 data types, such as BINARY and VARBINARY, are designed to store binary
data. This is useful for handling images, multimedia files, or any data in binary format.
Example:
DocumentName VARCHAR(100),
DocumentContent VARBINARY(MAX)
);
Here, DocumentContent is of type VARBINARY, suitable for storing binary content like
documents or images.
What is 1 SQL (Structured Query Language) used for?
It provides a standardized way to interact with databases, offering a set of commands for
tasks such as data retrieval, insertion, updating, and deletion. In database management, it
plays an important role in efficiently interacting and working with relational databases.
Universal Standard:
SQL serves as a universal standard for interacting with relational databases. Regardless of
the specific 23 database management system (DBMS) being used (e.g., MySQL,
PostgreSQL, SQL Server, Oracle), SQL provides a consistent and standardized syntax for
database operations.
SQL supports both 1 Data Definition Language (DDL) and Data Manipulation Language
(DML) operations. DDL is used for defining and managing the structure of the database,
including creating and modifying tables, while DML is employed for manipulating data
within the database, encompassing tasks such as inserting, updating, and deleting records.
7 Query Language:
SQL is primarily known as a query language due to its robust capabilities in retrieving data
from databases. The 1 Data Query Language (DQL) component of SQL, specifically the
SELECT statement, allows users to formulate queries to extract specific information from
the database.
Transaction Control:
SQL provides commands for transaction control, ensuring 22 the integrity and consistency
of data. Transactions are units of work that are executed within 11 a database
management system, and SQL commands such as BEGIN TRANSACTION, COMMIT,
Data Security:
SQL includes commands for managing data security through 1 Data Control Language
(DCL). Commands like GRANT and REVOKE are used to assign and revoke permissions,
SQL allows the implementation of various constraints to maintain data integrity. These
SQL
SQL supports the creation of indexes, which are important for optimizing query
performance. Indexes increase data retrieval speed by providing quick access to specific
rows in a table.
SQL allows the creation of stored procedures and views, contributing to data abstraction
and simplifying complex operations. Stored procedures are precompiled SQL statements,
@Salary DECIMAL(10,2)
AS
BEGIN
END;
->Example of View:
FROM Employees
standardized and simple language for defining, querying, and maintaining databases. Its
adaptability and wide range of commands make 1 it an essential tool for developers,
database administrators, and data analysts to efficiently handle and derive insights from
data.
Data Integrity:
Data integrity ensures that the data stored in a database is accurate, consistent, and free
from errors. Various integrity constraints, such as primary key constraints, unique
constraints, and foreign key relationships, contribute to maintaining the 8 integrity of the
data.
Example:
Consider a "Students" table with a primary key constraint on the "StudentID" column. This
FirstName VARCHAR(50),
LastName VARCHAR(50),
Age INT
);
Data Security:
Data security involves protecting the database from unauthorized access. Access controls
and authentication mechanisms restrict user access based on roles and permissions,
Example:
Implementing user roles and granting specific privileges 20 ensures that only authorized
30 Data Independence:
Data independence allows changes to the database schema without affecting the
applications built on top of it. This is achieved through mechanisms like views and stored
procedures, providing a layer of abstraction.
1 Example:
Creating a view that combines data from multiple tables allows applications to query the
Courses.CourseName
FROM Students
Data Recovery:
Example:
Regularly backing up the database and using tools like point-in-time recovery ensures that
Concurrency control mechanisms allow 19 multiple users to access and modify data
simultaneously without conflicting with each other. Techniques like locking and transaction
Example:
Implementing transactions with appropriate isolation levels prevents conflicts when multiple
-- Beginning a transaction
BEGIN TRANSACTION;
COMMIT;
Normalization techniques minimize data redundancy by breaking down large tables into
smaller, related tables. 20 This not only saves storage space but also reduces the
likelihood of inconsistencies.
Example:
CustomerName VARCHAR(100),
OrderDate DATE
);
CustomerName VARCHAR(100)
);
Query Capability:
SQL's powerful query language enables users to retrieve specific sets of data from large
performance.
Example:
Scalability:
Databases can scale vertically by adding more resources to a single server or horizontally
by distributing data across multiple servers. This scalability ensures databases can handle
-- Server 1
CustomerID INT,
OrderDate DATE
);
-- Server 2
CustomerID INT,
OrderDate DATE
);
Data Normalization:
dependency. It involves decomposing complex tables into simpler ones to improve data
Example:
FirstName VARCHAR(50),
LastName VARCHAR(50),
Department VARCHAR(50)
);
DepartmentName VARCHAR(50)
);
Improved Performance:
Example:
17 SQL Server:
Developed by Microsoft, SQL Server is known for its robust features, integration with other
MySQL:
An 51 open-source relational database management system, MySQL is widely used for its
PostgreSQL:
Known for its extensibility and support for complex queries, PostgreSQL is an open-source
Oracle Database:
Oracle is a powerful, enterprise-level 1 database system known for its scalability, security
The world of programming and query languages is incredibly diverse, with each language
C++: A powerful language often used in system programming, game development, and
performance-critical applications.
1 SQL (Structured Query Language): Primarily used for managing and querying relational
databases.
HTML (Hypertext Markup Language): Essential for creating the structure of web pages.
CSS (Cascading Style Sheets): Used for styling and formatting web pages.
(RDBMS).
Example:
-- Creating a 1 table
FirstName VARCHAR(50),
LastName VARCHAR(50),
Salary DECIMAL(10,2)
);
-- Querying data
FROM Employees
SQL used for procedural programming in Oracle Database. It enables the creation of
p_EmployeeID INT,
p_Salary DECIMAL
) AS
BEGIN
1 UPDATE Employees
COMMIT;
END;
T-SQL (Transact-SQL): T-SQL is the procedural language used in Microsoft SQL Server. It
Example:
@EmployeeID INT,
@Salary DECIMAL
AS
BEGIN
1 UPDATE Employees
END;
Example:
emp_id INT
) RETURNS DECIMAL AS $$
DECLARE
bonus DECIMAL;
BEGIN
FROM Employees
RETURN bonus;
END;
$$ LANGUAGE plpgsql;
NoSQL Query Languages: NoSQL databases, which are non-relational, often use specific
query languages tailored to their data models. Examples include 15 MongoDB Query
Language (MQL) for MongoDB and Couchbase Query Language (N1QL) for Couchbase.
Example (MongoDB):
//MongoDB Query
db.employees.find({ salary: { $gt: 50000 } });
XQuery: XQuery is a query language designed for querying XML data. It 7 is commonly
Example:
(: XQuery Example :)
return $employee
Example:
// Datalog Example
Each of these languages serves a specific niche within the broader landscape of database
procedural programming and beyond. The choice of language often depends on the
specific requirements of 25 the database system in use and the nature of the data being
managed.
Data Definition Language (DDL) is a subset of SQL that deals with the structure and
define and manage the schema, including creating, altering, and deleting database objects
Example:
FirstName VARCHAR(50),
LastName VARCHAR(50),
Salary DECIMAL(10,2)
);
In this DDL example, the CREATE TABLE statement defines a new table named
Data Manipulation Language (DML) is a subset of SQL that deals with the manipulation
and processing of data stored in the database. It includes operations like inserting,
updating, and deleting data within the tables, as well as querying data for retrieval.
Example:
-- Inserting a new employee record
Here, the INSERT INTO statement adds a new record to the "Employees" table with
specified values.
Data Query Language (DQL) is a subset of SQL focused on retrieving and querying data
from the database. The primary command in DQL is the SELECT statement, which allows
users to specify the 9 data they want to retrieve and the conditions for retrieval.
Example:
The SELECT statement retrieves the first and last names of employees whose salary
Data Control Language (DCL) is a subset of SQL that deals with the permissions and
access control of data stored in the database. It includes commands for granting or
Example:
In this example, the GRANT command gives the user "User123" the privilege to retrieve
Basics of Database:
Entities:
Entities are the fundamental building blocks of a relational database, representing objects
or concepts in the real world. Each entity is characterized by a set of attributes that
38 Example:
FirstName VARCHAR(50),
LastName VARCHAR(50),
);
Customers Entity- This represents a group of entities related to customers. Each row
Attributes-
CustomerID: This is the unique identifier for each customer and is designated as the
FirstName and LastName: These attributes store 1 the first and last names of the
customers, respectively.
Email: This attribute stores the email addresses of the customers, and the UNIQUE
Attributes:
Attributes are 52 the characteristics or properties that define an entity. In the context of a
FirstName VARCHAR(50),
LastName VARCHAR(50),
Salary DECIMAL(10,2)
);
EmployeeID: This is the primary key and serves as a unique identifier for each employee.
FirstName and LastName: These attributes store 1 the first and last names of the
employees.
Salary: This attribute represents the salary of each employee and is of the DECIMAL data
Relationships:
Relationships define connections between entities, describing how they 47 interact with
each other.
CustomerID INT,
OrderDate DATE,
);
Customer-Order Relationship:
CustomerID: This attribute 32 in the "Orders" table is a foreign key, establishing a link to
The relationship ensures that each order is associated with a valid customer. 26 The
foreign key constraint enforces referential integrity, preventing orders from referencing non-
existent customers.
One-to-one (1:1) Relationship - A relationship where one entity is associated with exactly
13 can have only one HOD and one HOD can only be the head of one department.
One-to-Many (1:N) Relationship - A relationship where one entity can be associated with
where multiple instances of one entity are associated with a single instance of another
entity is known as a Many-to-one relationship. For example, multiple students belong to the
same class.
students can enrol in different courses, and a course can have different students.
Tables:
Tables are the fundamental structures for 29 storing data in a relational database. Each
FirstName VARCHAR(50),
LastName VARCHAR(50),
);
Customers Table:
Each row represents a unique customer, and each column represents an attribute of the
The PRIMARY KEY constraint on CustomerID ensures that each customer has a unique
identifier.
The UNIQUE constraint on Email ensures that each email address is unique across all
customer records.
Keys:
21 In the context of a relational database, keys play a crucial role in organizing and linking
data across tables. There are primarily two types of keys: Primary 3 Key and Foreign
Key.
Primary Key: A Primary Key is a unique identifier for each record (row) in a table. It serves
Uniqueness: Every value 2 in the primary key column must be unique within the table. No
Non-null: The primary key column cannot contain null values. Each record must have a
Immutable: Ideally, 18 the values in the primary key column should not change over time.
2 Example:
FirstName VARCHAR(50),
LastName VARCHAR(50),
BirthDate DATE
);
In this example, StudentID is the primary key, uniquely identifying each student in the
"Students" table.
13 Foreign Key: A Foreign Key is a column or a set of columns in a table that refers to the
primary key of another table. It establishes a relationship between two tables, enforcing
referential integrity.
References Primary Key: The foreign key column in one table refers to the primary key
column in another table. This linkage ensures that values in 6 the foreign key column
May Allow Nulls: Unlike a primary key, a foreign key can contain null values. This indicates
that a particular record in one table does not necessarily have 43 a corresponding record
Ensures Referential Integrity: The presence of a foreign key ensures that relationships
between tables are maintained. It 2 prevents the creation of "orphaned" records, where a
Example:
CustomerID INT,
OrderDate DATE,
);
In this example, CustomerID in the "Orders" table is a foreign key that references the
Both 18 primary and foreign keys are essential for establishing relationships between
tables, ensuring data consistency, and enabling efficient querying in relational databases.
They form a cornerstone of database design and contribute to the relational 22 integrity of
This exploration of the basics provides a foundation for understanding the architecture,
Composite Key - 29 It is a type of primary key but other than one primary key then can be
multiple columns that uniquely identify the record is referred to as composite key. For
example, a student table in school has a roll number and government ID which uniquely
identifies each student. So each table has 3 only one primary key but can have multiple
composite keys.
28 A relational database is a type of database that manages and organizes the data in
structured or tabular format which is based on a relational model. Relational means the
database contains different entities and these entities exhibit some relationships among 4
different relationships which you have studied in the previous section. It 19 ensures data
integrity and consistency of data and allows users to retrieve data efficiently using SQL
Attributes - employee ID, employee name, date of birth, address, mobile number, salary,
Relationships defined
Now in this database 3 what are the different relationships that can exist among these
Each department can have multiple employees but an employee can be part of a single
department.
Each department 60 can have multiple projects but one project can belong to only one
department.
One project can have multiple employees working on it and a single employee in a
Primary Key - In the respective table like 3 in the employee table employee ID will be a
primary key, in the department table department ID will be the primary key and in the
Foreign key - In a relationship between the employee and a department, in the employee
table department ID will act as a foreign key and in the employee and project the project ID
This is 9 a simple example of how RDBMS is structured and used in the organization.
There can be multiple entities and multiple relationships so DBMS makes it easy to
maintain and retrieve the data easily 1 from multiple tables using SQL queries which
provide you with the concept of joins, groups, sorting, nested queries, etc.
Imagine a database as a neat and clean pantry in your kitchen, each shelf in it can be
referred to table, and each item on the shelf can be said as a record. But what makes each
item to be placed in a record? That’s where the field comes into the picture.
A field refers to a small unit of data representation within a table. You can consider it as a
small ingredient on your shelf. For example, a can of soft drink has multiple ingredients like
salt, sugar, water, flavour, species, fruits, etc. Similarly, 8 a record in a database has
different fields like name, age, date of birth, mobile number, address, etc.
Fields represent an individual property of an entity and are organized in columns within a
table where each column has a unique name and different data type.
Properties of Fields
Data type - Each field in a table has one data type which defines 9 the type of data it can
store. For example, the age field is represented with a data type integer, the name has a
data type as string, salary or price has a data type as float, and presence can be reflected
with a boolean data type. This defining data type of each field helps in easy data
manipulation in a table.
Size or Length - The field has a predefined length under which it can hold the values. 11
For example, if you define the name field which can have a minimum length of 6 and a
maximum length of 20 then the field will not accept a value less than 6 characters or more
than 20 characters.
Constraints - You can apply different constraints on the field which will be checked before
saving 8 a record in a database. 11 For example, you can define a constraint as unique
to have the unique values in each field, you can define a null or not null constraint to
ensure the field cannot be empty. Similarly, there are multiple constraints to apply to fields.
Importance of Fields
Fields are a very important factor in defining the structure of a database by organizing data
into meaningful categories. They ensure data accuracy, data integrity, and data
consistency in the database. Effective field is very important to perform better data
manipulation, data retrieval, and data analysis within a database. In short fields as a basic
building block 11 for a database table that defines table characteristics, and their
Imagine your closet of clothes is overflowing with clothes and you are unable to find what
you need to wear. So you will follow some smart ways to arrange your closet again in such
a way that you can find things easily that you need. Hence 53 database normalization is a
data is structured to enhance data integrity avoid any inconsistencies in data and maintain
data accuracy.
Objective of Normalization
You know why it is important to always keep your database organized but by keeping your
database organized what are the objectives and phenomena that are addressed and can
repetitions of the same data that consume more space and increase the response time 21
of the database and also confuses the search algorithm so normalization maintains the
Avoid Data Anomalies - Avoid some misspelt, incorrect data coming into a database while
Improve data integrity - You can achieve 54 a high level of data accuracy by defining some
Enhance Performance - You can reduce the database response time by increasing the
speed of queries and reducing data volume by keeping the database data accurate and
It involves creating some set of rules 6 to create a table which meets the specific
requirement and criteria referred to as normal form. The below form follows the top to down
approach like each form is built upon the previous form which helps to reduce data
duplicacy.
The 1NF states and ensures that each column in a table contains atomic values (single
piece of information). For example, you should have separate columns for each value or
each piece of information rather than combining all values 21 in a single column. 49 Think
of it as splitting a book list with multiple authors to have each author's name in a different
It says that you should create unique primary keys means you should assign a separate
It builds on top of the first normal form which states that avoid partial dependency by
ensuring that non-key attributes are fully dependent on the primary key. In simple words,
the column which 13 is not a primary key should completely depend on the primary key of
a table.
It inherits the principle of the second normal form and states that there should not be any
key dependency no column should depend on any other column to retrieve the values.
It is a very strict version of the third normal form which ensures that every determinant (a
field that can determine another field) in a table is referred to as the candidate key. It
Consider a scenario of a sales table with columns such as Order ID, Product name,
To achieve 1NF 4 you need to ensure that each cell means in each column each value
should be only considered as a single value, there should not be multiple values in a single
cell.
To achieve 2NF verify that non-key attributes like product name should only be dependent
For 3NF, ensure that no non-key attributes should be interdependent. For example,
BCNF will ensure that every determinant in a table 3 is a candidate key like product ID.
structure which has zero anomalies, no data duplicacy, and maintains data accurately and
consistently.
16 How to create a database?
Designing a database is like constructing a well-designed home for your data which
requires correct planning and execution while ensuring security, efficiency, and adaptability
that fits according to your needs effectively. Below 9 are some of the steps to follow while
Define your data storage needs - First, decide what type of data you want to store and how
you want to use your stored data. Identify the relationships that will exist in your data and
also consider the growth 42 of your data in the coming few years.
Choose a DBMS - Choose a DBMS based on your requirements and the factors you have
studied in the previous section. The most popular choices of databases across industries
Design your database structure - Plan the table structure in which write all the necessary
tables needed 4 to store the data, define all attributes, and fields in the table, define
relationships between tables, and decide constraints in data. This is all you can do easily
your ER diagram which represents the complete logical (visual) view of your database
schema.
16 Create a new database - Now you have a clear mindset with the database, and also
select the right database and install it. Now it’s time to run a simple SQL query to create a
Create Tables - You have all the entities (table) you need and attributes designed in the
ER diagram. Just you need to run SQL queries to define 47 the database schema in the
computer.
1 CREATE TABLE employees (
name VARCHAR(50),
Department VARCHAR(50),
salary DECIMAL(10,2)
);
Insert the data - When the table is created with all relationships and constraints it means
you have printed the complete ER diagram practically in your computer system database.
Now you need to feed the data and check the data storage and retrieval part.
INSERT INTO employees (name, department, salary) VALUES ('John Doe', 'IT', 60000);
9 Query and Manipulate data - Now play with the SQL queries like Select, update, delete
Imagine how books are well arranged on a library shelf which is like a record in a database
table. Each page in a book holds some specific information which is similar to a column in
tables. Now how database stores the data, so these things happen with a combination of
Tables - Your company gets or receives data in huge chunks and needs 4 to store the
data in a database which is not at first very clean or separated. So data gets separated into
specific relevant topics like customer-related information will go to the customer table,
product-related information to the product table, and feedback and reviews to a specific
table. This acts like labelling the chapters in your library.
better organize it, it again gets segregated into well-defined rows and columns. Row acts
as an individual entry, and the column defines the metadata means what the value is about
Data Types - Each column holds 2 a specific data type that tells about what kind of
values it stores.
Keys - Just like arrays have indexing to retrieve elements, tables have keys to identify the
Relationships - Tables are not isolated, they are cross-linked with information 10 and can
be used with multiple other tables to find which product is ordered by how many customers
While your data seems neatly stored on shelves, it's saved in bits and bytes on physical
storage devices like disks. The magic of the DBMS 21 lies in its ability to translate these
bits and bytes back into meaningful information when you need it.
Conclusion
deep-dived into the world of organizing, managing, and retrieving data efficiently. From
understanding the very basic concepts of DBMS to exploring some advanced concepts like
data normalization, data storage, and designing database architecture. This guide aims to
equip you 1 with a solid understanding of DBMS and build a good fundamental base over
Following the insights from guide you get the theoretical as well as practical idea of 15
interacting with a database and leveraging this power of structuring a database logically,
optimizing storage, and ensuring data integrity. Remember, every master was once a
learner. Keep exploring, keep questioning, and keep building. This guide is just the