0% found this document useful (0 votes)
231 views87 pages

DBMS Handwritten Notes

Uploaded by

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

DBMS Handwritten Notes

Uploaded by

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

Plagiarism Checker X - Report

Originality Assessment

13%
Overall Similarity

Date: Jan 6, 2024 Remarks: Moderate similarity Verify Report:


Matches: 2109 / 15691 words detected, consider enhancing Scan this QR Code
Sources: 63 the document if necessary.

v 9.0.2 - WML 4
DBMS

Introduction

In the vast landscape of information technology, Database Management Systems (DBMS)

act as the foundational framework for efficient data organization and accessibility. This

comprehensive article aims to provide an in-depth understanding of the significance,

applications, components, and classifications of DBMS, offering readers a holistic

perspective on this crucial technology.

What are the 4 types of DBMS?

What is SQL full form?

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

and significance within database management.

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.

What are the three Layers of DBMS?


Layers of database management systems reveal a complete structured architecture

important for data handling. DBMS functions through three fundamental layers known as

three-tier architecture involving external, conceptual, and internal layers.

External Layer (User View)

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

database without needing to understand existing complexities in architecture.

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

different users without affecting the underlying data structure.

Conceptual Layer

This layer is also referred to as logical schema or conceptual schema of database

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

relationship, and all attributes.

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

while hiding complexities from higher levels.

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

data manipulation algorithms.

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

data is also not lost.

It also divides the large tables into smaller partitions for better performance.

It also includes security features so data is safe from unauthorised access.

By dividing DBMS into layers, it provides a completely structured approach to database

design and management. These layers are fundamental parts 11 of a database

management system and understanding these will help to know how data is stored,
processed, and retrieved in any application management system.

What are the 4 Properties of DBMS?

When it comes to managing data effectively with ease ensuring data accuracy and

reliability, the database management systems provide very important properties referred to

as 4 fundamental properties. In short, these properties are known as ACID properties of

DBMS and include 12 Atomicity, Consistency, Isolation, and Durability. These properties

work together to ensure data integrity and data consistency of your confidential and

important data to ensure it remains trustworthy.

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

be rejected completely. There is no place anywhere in between to draw or halfway through

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

state. So Atomicity maintains an all-or-nothing scenario of database state.


Consistency

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

your database state.

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

should be unique (student ID should be a unique number combination) so if anyone tries to

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

database from inconsistent or incomplete data insertion.

Isolation

23 Isolation property ensures that the simultaneous execution of multiple transactions

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

(multiple at a time). So Isolation property prevents the database from concurrency-related

issues like dirty reads, repeatable reads, etc.

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

available when you need it.

These ACID properties form the strong foundation of a reliable and robust database

system.

What are the 10 functions of a DBMS?

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

or incorrect values into a database.

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

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,

grouping, joining data from multiple tables etc.

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

validation rules that you define to prevent any inconsistencies in data.

Concurrency Control - DBMS manages simultaneous access to the database to prevent

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

change in the database to maintain the valid 23 state of the database.

Backup and Recovery - Accidents or mistakes happen everywhere so DBMS provides

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

different data objects.

What are the 5 different types of database structures?

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 database structure

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.

Network Database structure

A network database structure is an advanced form of hierarchical database by provides

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

relationships or one-to-many relationships. This database structure is also referred to as an

interconnected database structure.

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

spreadsheet or Excel sheet.

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

simple SQL commands.

28 Examples of relational database structures can be financial records, college students'

details sheets, inventory management systems, etc.

Object-oriented database structure

It is a type of structure where the data or information or anything 24 is represented in the

form of objects encapsulating both data and data methods (behaviour) in a single unit

which is similar to use in object-oriented programming. The Applications which require a

high set of functionality can use an object-oriented database structure because it stores

real-world entities as objects which is well structured to represent complex structures

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

fine to 7 store this type of dynamic data relationships.

Examples of this structure can be Computer-aided-design (CAD) systems, multimedia

databases, and scientific research data management.

Document-oriented database structure

These are also known as NoSQL databases that offer diverse models to handle massive,

unstructured, or constantly or simultaneously changing data. 4 This type of database

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

are MongoDB, Cassandra DB, etc.

An example of this database 27 structure can be any IOT or sensor data storage.

What is DBMS and explain the different databases available?

A database management system (DBMS) is a software application which is designed to

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

can be used by everyone accurately and simultaneously without getting anything

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

presented to various stakeholders of the company by connecting 10 the database to the

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.

Different Databases Available around us

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

PostgreSQL is another 1 relational database management system which was released in

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

execute the query to see the results of the query.

A lot of gaming apps, and automation tools use this database and due to its active

community and extensions make it adaptable to diverse needs. It provides features

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

versatile database solutions.

MongoDB (NoSQL Database)

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

as a separate document inside a single collection.

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

connector with different language applications like pymongo for Python.

SQLite

SQLite functions as an embedded 1 relational database management system that comes

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

Neo4j represents a strong graph database that focuses on managing relationships

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

volume of interconnected data, especially in mainframe environments. Its hierarchical

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

hierarchical flow of data that represents one-to-many relationships.

Redis

Redis was introduced by one Italian developer while facing issues in scalability with

traditional database management systems. Redis is created 25 as a distributed in-memory

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

range queries, and geospatial indexes with radius queries.

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

which is good for real-time use cases.

Choosing the Right data structure and database

There are many more databases to explore of different structures and the choice depends

on your application structure, your application-specific needs, and your performance

characteristics. Below are some factors 25 that can be considered while choosing the

database for your application

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

data storage is your application requirements.

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

will your application grow?

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

should be frequently rendered?


What is a DBMS explain?

Why Do We Need DBMS?

Data Organization and Storage:

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

data 27 is stored in a manner that facilitates easy retrieval and modification.

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

precise retrieval when needed.

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

errors in transaction records, leading to incorrect balances and potential financial

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

concern. DBMS addresses this by incorporating robust security measures such as

encryption, access controls, and audit trails.

Consider a healthcare database storing sensitive patient information. Without proper

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

database, bolstering the overall security posture.

Concurrency Control:

In scenarios where multiple users access the database simultaneously, concurrency

control is essential. DBMS manages transactions in a controlled and concurrent manner,

preventing data conflicts and ensuring the consistency of the database.

Imagine an e-commerce platform processing numerous orders simultaneously. Without

effective concurrency control, issues such as overselling products or inaccurate inventory

updates may arise. DBMS implements mechanisms to handle concurrent transactions

seamlessly, ensuring a smooth and reliable shopping experience for users.

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

modifications to the database schema without disrupting the functioning of associated


applications.

Consider a scenario where a new attribute needs to be added to a customer database,

such as recording the preferred communication channel. In a system without data

independence, this modification could potentially break existing functionalities. However,

with DBMS, 30 the addition of new fields can be seamlessly incorporated, ensuring

flexibility and adaptability without causing disruptions.

Where DBMS Can Be Used

DBMS finds applications across diverse domains, contributing to streamlined data

management and efficient operations.

1. Business and Finance:

In the business realm, DBMS is instrumental in managing financial transactions, customer

data, and business analytics. It facilitates quick decision-making by providing insights

derived from well-organized data.

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

enables the business to make informed decisions on product restocking, marketing

strategies, and overall business growth.

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

accurate information promptly.


In a hospital setting, DBMS plays a pivotal role in maintaining patient records. When a

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

delivery but also contributes to patient safety.

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.

Imagine a university with thousands of students enrolled in various courses. DBMS

streamlines the management of student records, making it easier for administrators to track

enrollment, assign grades, and generate reports on academic performance. The efficiency

gained through DBMS contributes to the overall effectiveness of educational institutions.

4. E-commerce:

The dynamic nature of e-commerce demands efficient data management. DBMS supports

online transactions, inventory management, 5 and customer relationship management for

seamless operations.

In the e-commerce sector, where thousands of transactions occur daily, DBMS ensures the

smooth processing of orders, accurate inventory updates, and personalized customer

experiences. 15 The ability to handle large volumes of data efficiently is a key factor in the

success of e-commerce platforms.

5. Telecommunications:

In the telecommunications sector, 5 DBMS plays a crucial role in managing subscriber

data, call records, and network configurations. It ensures the smooth functioning of
communication networks.

Consider a telecommunications company that serves millions of subscribers. DBMS is

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

operation of telecommunications services.

Primary Key in DBMS

In the realm of relational databases, the concept of a primary key is fundamental. A

primary key 3 serves as a unique identifier for each record in a table, ensuring data

integrity and forming the basis for relationships between tables.

Importance of Primary Key:

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

and integrity of data within a table.

Consider a customer database where each customer is assigned a unique customer 3 ID

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

tables, such as orders or transactions.

Types of Primary Keys:

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

as data stability and efficiency.

What are the Uses of Databases?

Databases serve a multitude of purposes, extending beyond mere data storage.

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

accessible for library staff and patrons.

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

pivotal role in various applications across different industries.

3. Data Analysis:

Databases empower businesses and researchers to derive meaningful insights through

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:

Databases facilitate collaboration by allowing seamless 46 sharing of information among

authorized users. An organization's database enables different departments to access

relevant data, promoting cross-functional collaboration and ensuring that information is

shared efficiently.

What Is SQL in DBMS?

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

databases, offering a set of commands to define, manipulate, and query data.

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

management systems (RDBMS). This standardized language ensures a common ground

for database interactions, regardless of the specific RDBMS being used, fostering

consistency and ease of use across various database platforms.

Components of SQL:

1. 1 Data Definition Language (DDL):

CREATE: Defines the structure of a database, including tables and relationships.

ALTER: Modifies the structure of an existing database.

DROP: Deletes database objects such as tables.


Expanding on this, consider the creation of a new table for employee information with

specified attributes using DDL:

CREATE TABLE Employee (

EmployeeID INT PRIMARY KEY,

FirstName VARCHAR(50),

LastName VARCHAR(50),

DepartmentID INT,

FOREIGN KEY (DepartmentID) REFERENCES Department(DepartmentID)

);

2. Data Manipulation Language (DML):

SELECT: Retrieves data from one or more tables.

We can use DML to retrieve employee names from the Employee table:

SELECT FirstName, LastName FROM Employee;

3. Data Control Language (DCL):

GRANT: Provides specific user permissions on database objects.

REVOKE: Removes previously granted permissions.

Expanding on this, consider granting SELECT permission on the Employee table to a

specific user:

GRANT SELECT ON Employee TO username;


4. Transaction Control Language (TCL):

COMMIT: Saves all changes made during the current transaction.

1 ROLLBACK: Undoes changes made during the current transaction.

SAVEPOINT: Sets a point within a transaction to which you can later roll back.

Expanding on this, consider starting a transaction, executing SQL statements, and

committing the transaction:

-- Start a transaction

BEGIN;

-- Execute SQL statements

UPDATE Employee SET Salary = Salary * 1.1 WHERE DepartmentID = 2;

-- Commit the transaction

COMMIT;

Difference Between DBMS and RDBMS

Let's delve into the distinctions between 7 Database Management System (DBMS) and

Relational Database Management System (RDBMS) in greater detail.

1. DBMS:

Functionality:

A DBMS, or Database Management System, serves as a software suite that enables the

creation, management, and manipulation of databases. It is a broad term that

encompasses various types of systems, including those that don't strictly adhere to the
relational model.

Data Management Without Relationships:

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.

Lack of Constraint Support:

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

to prevent duplicate entries or ensure referential integrity.

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

mechanism to ensure data consistency or to prevent redundant information.

2. RDBMS:

Functionality:

An RDBMS, or Relational Database Management System, is a specific type of DBMS that

adheres to the principles of the relational model. It is designed to manage databases

where data is organized into tables, and relationships between these tables are explicitly
defined.

Emphasis on Relationships:

24 In contrast to a generic DBMS, an RDBMS places a strong emphasis on enforcing

relationships between tables. Tables are linked through keys—primary keys uniquely

identify records within a table, and foreign keys 18 establish relationships between tables.

Data Integrity Through Constraints:

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

consistency of data across the database.

Ideal for Complex, Multi-User Scenarios:

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

modification, and ensures data integrity even 22 in a multi-user environment.

Scenario Illustration:

Consider an RDBMS like MySQL or PostgreSQL used in a scenario where a business

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

with customers (foreign key).

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:

Organize data in tables with predefined relationships.

Use SQL for querying and managing data.

Expanding on this, consider the 33 structure of a relational database where data is

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

5 to interact with the database.

2. NoSQL Databases:

Designed for unstructured or semi-structured data.

Offer flexibility and scalability.

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

volumes of data across distributed systems.

3. Object-Oriented 7 Databases:

Store data as objects, incorporating principles of object-oriented programming.


Expanding on this, consider an object-oriented database 24 where data is represented as

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:

Designed for data with complex relationships, represented as a graph.

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

efficient way to model and query these intricate relationships.

5. 7 Document Databases:

Store data in document format (e.g., JSON or XML).

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

useful in scenarios where data formats may vary and evolve.

How to Learn DBMS

Acquiring proficiency in DBMS involves a strategic approach that combines theoretical

understanding with practical application.

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

offer comprehensive courses on DBMS.

Courses cover various aspects, from basic concepts to advanced topics like database

design and optimization.

Consider enrolling in an online course that provides a structured learning path. Topics may

include fundamentals of database design, normalization techniques, and practical

exercises using popular DBMS platforms.

2. Books:

Refer to textbooks such as "Database System Concepts" by Abraham Silberschatz, Henry

F. Korth, and S. Sudarshan for in-depth understanding.

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

real-world applications, enhancing your understanding of DBMS.

3. Practice:

Apply theoretical knowledge by working on practical projects and exercises.

Platforms like LeetCode, HackerRank, and GitHub repositories offer a plethora of

database-related problems to solve.

Consider engaging in hands-on projects to reinforce your learning. Create a sample

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.

4. Tutorials and Documentation:

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,

provided by vendors like MySQL or PostgreSQL, offers comprehensive guides on

installation, configuration, and advanced features. Practical examples in documentation

can enhance your understanding of real-world usage.

Structure of DBMS

A DBMS comprises several components working together 5 to ensure efficient data

management.

1. 1 Data Definition Language (DDL):

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

objects such as tables, indexes, and constraints.

Creating Tables and Relationships:

In the provided SQL example:

CREATE TABLE Product (

ProductID INT PRIMARY KEY,

ProductName VARCHAR(100),
Price DECIMAL(10, 2),

CategoryID INT,

FOREIGN KEY (CategoryID) REFERENCES Category(CategoryID)

);

CREATE TABLE: Initiates the creation of a new table named "Product."

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.

ProductName VARCHAR(100): Defines a column named "ProductName" with the data

type Variable Character (VARCHAR) that can store up to 100 characters.

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

the category identifier for each product.

FOREIGN KEY (CategoryID) REFERENCES Category(CategoryID): Establishes 26 a

foreign key relationship, linking the "CategoryID" column to the "CategoryID" column in

another table named "Category."

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.

2. Data Manipulation Language (DML):

Facilitating Data Operations:

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:

In the given example:

INSERT INTO Product (ProductID, ProductName, Price, CategoryID)

VALUES (1, 'Laptop', 1200.00, 2);

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

corresponding columns—ProductID: 1, ProductName: 'Laptop', Price: 1200.00,

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

the "Product" table.

(ProductID, ProductName, Price, CategoryID): Enumerates the columns to which values

will be inserted. This part is essential 58 to ensure that the values provided in the VALUES

section align with the correct columns in the table.

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

corresponding columns mentioned earlier.

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,

is being added to the database.

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:

Translating User Queries:

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,

execution plan generation, and facilitating data retrieval.

Query Optimization:

When a user submits a query like:

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

the "Product" table in this scenario.

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"

values selected are within the specified range.

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,

and how data will be filtered and sorted.

Importance of Query Processor:

An efficient Query Processor 37 is crucial for maintaining optimal performance in database

systems. Generating well-optimized execution plans ensures that queries are processed

swiftly, leading to faster response times for users and applications.

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,

and potential joint strategies.

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

rapid retrieval when requested.

Indexing for Faster Retrieval:

In the provided example:

CREATE INDEX idx_Price ON Product (Price);


CREATE INDEX: Initiates 20 the creation of an index.

idx_Price: Assigns a name to the index, in this case, "idx_Price."

ON Product (Price): Specifies the table ("Product") and the column ("Price") on which 6

the index is created.

Indexing Benefits:

26 Creating an index on frequently queried columns, such as "Price," improves retrieval

speed. The index serves as a data structure that allows the database engine to locate

specific values more quickly, akin to an efficient reference system.

Importance of Storage Manager:

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.

In summary, the components of 1 Data Definition Language (DDL), Data Manipulation

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

integrity, efficiency, and responsiveness of the database, contributing to its overall

effectiveness in supporting various applications and business processes.

Classification in DBMS

Classification Based on Data Model:

Relational DBMS: 12 Relational Database Management Systems (RDBMS) form the


cornerstone of structured data storage. They organize data into 16 tables, where each

table represents an entity, and relationships between tables are established through keys.

The relational model ensures data integrity, flexibility, and efficient querying through the

standardized 46 language, SQL (Structured Query Language).

In a typical RDBMS scenario, imagine a university database where student information is

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

information, such as finding all courses enrolled by a specific student or identifying

students enrolled in a particular course.

Object-Oriented DBMS: Object-Oriented Database Management Systems (OODBMS) take

inspiration from object-oriented programming principles. In OODBMS, data is represented

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.

Consider an application for managing a library's inventory. In an OODBMS, each book

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

databases offer flexibility in 5 handling unstructured or semi-structured data and are

particularly well-suited for applications with rapidly evolving data requirements.


Imagine 50 a social media platform where user-generated content, such as posts,

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

efficient and scalable data storage.

Classification Based on Number of Users:

Single-user DBMS: Single-user 4 Database Management Systems are designed 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

concurrent access requirements.

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

associated with multi-user environments.

Multi-user DBMS: Multi-user Database Management Systems cater to scenarios where

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

numerous users concurrently.

58 In the context of an e-commerce platform, a multi-user DBMS ensures that customers

can browse products, place orders, and update their profiles simultaneously without

encountering data conflicts. Platforms like MySQL or Oracle provide the robustness

required to handle concurrent access, 37 ensuring data consistency and reliability.


Classification Based on Distribution of Data:

Centralized DBMS: Centralized Database Management Systems store all 29 data in a

single central location. This model is suitable for scenarios where all users and data are

concentrated in one physical or logical location.

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.

Distributed DBMS: 22 Distributed Database Management Systems distribute data across

multiple locations or servers. This architecture enhances performance, provides fault

tolerance, and allows for scalability in handling large volumes of data.

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

access and improves overall system responsiveness. Distributed systems, such as

Cassandra or Amazon DynamoDB, excel in managing data across geographically

dispersed locations.

Classification Based on Structure:

Hierarchical DBMS: Hierarchical Database Management Systems 6 organize data in a

tree-like structure, where each record has a parent-child relationship. This model is

suitable for representing hierarchical relationships between entities.

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.

Network DBMS: 44 Network Database Management Systems utilize a network model to

represent data relationships. Unlike the hierarchical model, the network model allows

records to have multiple parent-child relationships, creating a more interconnected

structure.

In a logistics scenario, consider a network DBMS representing the relationships between

transportation hubs, routes, and shipments. Each transportation hub may be linked to

multiple routes, and each route may serve multiple shipments. The network model

facilitates a more flexible representation of complex relationships within the logistics

network.

Relational DBMS: 12 Relational Database Management Systems, as discussed earlier,

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.

27 In the context of a customer relationship management (CRM) system, a relational

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

management of diverse datasets within the CRM system.

What 44 are the 4 types of Data languages?


In the vast field of dealing with information, databases play a crucial role as the foundation

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

want to fully grasp the intricacies that power data-centric systems.

The Four Pillars of Data Language

1 Data Definition Language (DDL)

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:

-- Creating a table named Customers

CREATE TABLE Customers (

CustomerID 1 INT PRIMARY KEY,

FirstName VARCHAR(50),

LastName VARCHAR(50),

Email VARCHAR(100) UNIQUE

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

constraint ensures the uniqueness of the Email.

1 Data Manipulation Language (DML)

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

interact with the important information 4 stored in the database.

Example:

-- Inserting a new customer record

INSERT INTO Customers 6 (CustomerID, FirstName, LastName, Email)

VALUES (1, 'John', 'Doe', '[email protected]');

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.

1 Data Query Language (DQL)

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

the insights we need.

Example:
-- Retrieving customer names with a specific email domain

1 SELECT FirstName, LastName FROM Customers WHERE Email LIKE

'%@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".

Data Control Language (DCL)

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

15 and interact with the data in the database.

Example:

-- Granting SELECT privilege to a specific user

GRANT SELECT ON Customers TO User123;

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.

What are the 22 two main types of Data?


The two main types of data are structured data and unstructured data.

Structured Data:

Structured data is the backbone of relational databases, which is a highly organized

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

applications where data relationships are well-defined.

Example:

CREATE TABLE Customers (

CustomerID INT PRIMARY KEY,

FirstName VARCHAR(50),

LastName VARCHAR(50),

Email VARCHAR(100) UNIQUE

);

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:

Consider a folder containing various documents in different formats, including Word

documents, PDFs, and images. This collection represents unstructured data, as there is no

predefined schema governing the organization of these files.

What are the five Data Types?

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

control over numerical data.

2 Example:

CREATE TABLE Products (

ProductID INT PRIMARY KEY,

ProductName VARCHAR(100),

Price DECIMAL(8,2),

QuantityInStock INT

);

Here, the Price column is of the DECIMAL data type, allowing for an accurate

representation of prices with two decimal places.

Character:

Character data types store strings of characters. VARCHAR is for variable-length strings,
while CHAR is for fixed-length strings.

2 Example:

CREATE TABLE Employees (

EmployeeID INT PRIMARY KEY,

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

and times. Common types include DATE and TIMESTAMP.

2 Example:

CREATE TABLE Orders (

OrderID INT PRIMARY KEY,

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:

CREATE TABLE Tasks (

TaskID INT PRIMARY KEY,

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:

CREATE TABLE Documents (

DocumentID INT PRIMARY KEY,

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?

SQL is a specialized programming language designed for managing relational databases.

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.

Data Definition and Manipulation:

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,

and ROLLBACK help manage these transactions.

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,

ensuring that only authorized users have access to specific data.

Data Integrity Constraints:

SQL allows the implementation of various constraints to maintain data integrity. These

constraints include PRIMARY KEY (ensuring uniqueness), FOREIGN KEY (enforcing

referential integrity), and CHECK constraints.

SQL

Indexing and Optimization:

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.

Stored Procedures and Views:

SQL allows the creation of stored procedures and views, contributing to data abstraction

and simplifying complex operations. Stored procedures are precompiled SQL statements,

and 1 views are virtual tables generated from queries.

-> Example of Stored Procedure:

--Creating a procedure to update employee salary

CREATE PROCEDURE UpdateSalary


@EmployeeID INT,

@Salary DECIMAL(10,2)

AS

BEGIN

UPDATE Employees SET Salary = @Salary WHERE EmployeeID = @EmployeeID;

END;

->Example of View:

--Creating a view to retrieve high-salary employees

CREATE VIEW HighSalaryEmployees AS

SELECT EmployeeID, FirstName, LastName, Salary

FROM Employees

WHERE Salary > 80000;

In summary, SQL is the cornerstone of relational database management, offering a

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.

What are the advantages of Databases?

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

ensures that each student is uniquely identified, preventing duplicate records.

2 CREATE TABLE Students (

StudentID INT PRIMARY KEY,

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,

preserving the confidentiality and integrity of sensitive information.

Example:

Implementing user roles and granting specific privileges 20 ensures that only authorized

users can access certain parts of the database.

-- Creating a user with limited privileges -

CREATE USER LimitedUser;

GRANT SELECT ON Students TO LimitedUser;

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

view without being affected by underlying changes in the table structure.

-- Creating a view that combines student and course information

CREATE VIEW StudentCourseInfo AS

SELECT Students.StudentID, Students.FirstName, Students.LastName,

Courses.CourseName

FROM Students

JOIN Enrollments ON Students.StudentID = Enrollments.StudentID

JOIN Courses ON Enrollments.CourseID = Courses.CourseID;

Data Recovery:

Data recovery involves the implementation of 5 backup and recovery mechanisms to

restore data to a consistent state after a system failure.

Example:

Regularly backing up the database and using tools like point-in-time recovery ensures that

data can be restored to a specific moment in case of failure.

-- Creating a full database backup

BACKUP DATABASE YourDatabase TO Disk = 'C:\YourBackupPath\FullBackup.bak';


Concurrent Access:

Concurrency control mechanisms allow 19 multiple users to access and modify data

simultaneously without conflicting with each other. Techniques like locking and transaction

isolation ensure data consistency.

Example:

Implementing transactions with appropriate isolation levels prevents conflicts when multiple

users are updating 4 the same data concurrently.

-- Beginning a transaction

BEGIN TRANSACTION;

-- Updating student information

UPDATE Students SET Age = Age + 1 WHERE StudentID = 1;

-- Committing the transaction

COMMIT;

Data Redundancy Reduction:

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:

Consider a denormalized "Orders" table with redundant customer information. Normalizing

the data involves creating a separate "Customers" table.

-- Denormalized Orders table


CREATE TABLE Orders (

OrderID INT PRIMARY KEY,

CustomerName VARCHAR(100),

OrderDate DATE

);

-- Normalized Customer's table

CREATE TABLE Customers (

CustomerID INT PRIMARY KEY,

CustomerName VARCHAR(100)

);

Query Capability:

SQL's powerful query language enables users to retrieve specific sets of data from large

datasets efficiently. 37 Indexing and optimization techniques further enhance query

performance.

Example:

26 Creating an index on frequently queried columns accelerates data retrieval.

-- Creating 1 an index on the LastName column

CREATE INDEX idx_LastName ON Employees(LastName);

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

growing amounts of data and increased user demands.


Example:

Implementing sharding involves distributing 7 data across multiple servers based on a

predefined criterion, enhancing scalability.

-- Server 1

CREATE TABLE Orders_Server1 14 (

OrderID INT PRIMARY KEY,

CustomerID INT,

OrderDate DATE

);

-- Server 2

CREATE TABLE Orders_Server2 (

OrderID INT PRIMARY KEY,

CustomerID INT,

OrderDate DATE

);

Data Normalization:

Data normalization is a 56 process of organizing data to eliminate redundancy and

dependency. It involves decomposing complex tables into simpler ones to improve data

integrity and reduce anomalies.

Example:

Consider a denormalized "Employees" table with redundant department information.

Normalizing the data involves creating a separate "Departments" table.

-- Denormalized Employee's 1 table


CREATE TABLE Employees (

EmployeeID INT PRIMARY KEY,

FirstName VARCHAR(50),

LastName VARCHAR(50),

Department VARCHAR(50)

);

-- Normalized Departments table

CREATE TABLE Departments (

DepartmentID INT PRIMARY KEY,

DepartmentName VARCHAR(50)

);

Improved Performance:

Databases 63 utilize indexing, caching, and query optimization techniques to enhance

performance. These mechanisms speed up data retrieval and processing.

Example:

Optimizing a query by using appropriate indexes improves its performance.

-- Creating 1 an index on the ProductID column

CREATE INDEX idx_ProductID ON Products(ProductID);

Understanding and leveraging these advantages contribute to the effective design,

management, and utilization of relational databases in various applications.

What are In-Demand SQL Variants:


The choice of SQL variant depends on specific project 5 requirements, scalability needs,

and budget considerations.

17 SQL Server:

Developed by Microsoft, SQL Server is known for its robust features, integration with other

Microsoft products, and strong security features.

MySQL:

An 51 open-source relational database management system, MySQL is widely used for its

performance, reliability, and ease of use.

PostgreSQL:

Known for its extensibility and support for complex queries, PostgreSQL is an open-source

database system that excels in handling 9 large amounts of data.

Oracle Database:

Oracle is a powerful, enterprise-level 1 database system known for its scalability, security

features, and comprehensive management tools.

17 How many types of Languages?

The world of programming and query languages is incredibly diverse, with each language

designed to serve specific purposes and application domains.

Here's a deeper exploration:

General-Purpose Languages: General-purpose languages are versatile and widely

applicable across various domains. Examples include:


Python: Known for its readability and ease of use, Python is extensively 16 used in web

development, data science, artificial intelligence, and automation.

Java: Java is a robust, platform-independent language commonly used for building

enterprise-level applications and Android mobile apps.

C++: A powerful language often used in system programming, game development, and

performance-critical applications.

Domain-Specific Languages: Domain-specific languages are tailored to address specific

needs within a particular domain or industry. Examples include:

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.

Language Used in DBMS:

21 In the realm of Database Management Systems (DBMS), various languages serve

distinct purposes, each contributing to different aspects of database operations. Let's

explore some of the key languages used in DBMS:


SQL 7 (Structured Query Language): SQL is the cornerstone language for interacting

with relational databases. 59 It provides a standardized syntax for defining, manipulating,

querying, and controlling access to data in relational database management systems

(RDBMS).

Example:

-- Creating a 1 table

CREATE TABLE Employees (

EmployeeID INT PRIMARY KEY,

FirstName VARCHAR(50),

LastName VARCHAR(50),

Salary DECIMAL(10,2)

);

-- Inserting data into the table

INSERT INTO Employees (EmployeeID, FirstName, LastName, Salary)

VALUES (1, 'John', 'Doe', 50000.00);

-- Querying data

SELECT EmployeeID, FirstName, LastName, Salary

FROM Employees

WHERE Salary > 50000;

PL/SQL (Procedural Language/Structured Query Language): PL/SQL is an extension of

SQL used for procedural programming in Oracle Database. It enables the creation of

stored procedures, functions, triggers, and packages within the database.


Example:

-- Creating a PL/SQL procedure

CREATE OR REPLACE PROCEDURE UpdateSalary (

p_EmployeeID INT,

p_Salary DECIMAL

) AS

BEGIN

1 UPDATE Employees

SET Salary = p_Salary

WHERE EmployeeID = p_EmployeeID;

COMMIT;

END;

T-SQL (Transact-SQL): T-SQL is the procedural language used in Microsoft SQL Server. It

extends SQL with additional programming constructs and system functions.

Example:

-- Creating a T-SQL stored procedure

CREATE PROCEDURE UpdateSalary

@EmployeeID INT,

@Salary DECIMAL

AS

BEGIN

1 UPDATE Employees

SET Salary = @Salary

WHERE EmployeeID = @EmployeeID;


COMMIT;

END;

PL/pgSQL: PL/pgSQL is a procedural language used in the PostgreSQL database. It

supports stored procedures, triggers, and functions.

Example:

-- Creating a PL/pgSQL function

CREATE OR REPLACE FUNCTION CalculateBonus (

emp_id INT

) RETURNS DECIMAL AS $$

DECLARE

bonus DECIMAL;

BEGIN

SELECT Salary * 0.1 INTO bonus

FROM Employees

WHERE EmployeeID = emp_id;

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

used in XML database management systems.

Example:

(: XQuery Example :)

for $employee in /employees/employee

where $employee/salary > 50000

return $employee

Datalog: Datalog is a declarative query language used in some deductive database

management systems. It is particularly suited for expressing recursive queries.

Example:

// Datalog Example

high_salary_employee(X) :- employee(X, Y), Y > 50000.

Each of these languages serves a specific niche within the broader landscape of database

management, offering functionalities ranging from simple data querying to complex

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.

Languages used in SQL:

SQL is a multifaceted language that encompasses various sub-languages, 1 each


serving a distinct purpose within the database management realm:

- DDL (Data Definition Language):

Data Definition Language (DDL) is a subset of SQL that deals with the structure and

definition of the database objects. It allows database administrators and designers to

define and manage the schema, including creating, altering, and deleting database objects

like tables, indexes, and constraints.

Example:

-- Creating a new table

CREATE TABLE Employees (

EmployeeID INT PRIMARY KEY,

FirstName VARCHAR(50),

LastName VARCHAR(50),

Salary DECIMAL(10,2)

);

In this DDL example, the CREATE TABLE statement defines a new table named

"Employees" with specific columns and data types.

- DML (Data Manipulation Language):

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

INSERT INTO Employees (EmployeeID, FirstName, LastName, Salary)

VALUES (1, 'John', 'Doe', 50000.00);

Here, the INSERT INTO statement adds a new record to the "Employees" table with

specified values.

- DQL (Data Query Language):

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:

-- Retrieving employee names with a salary above a certain threshold

1 SELECT FirstName, LastName FROM Employees WHERE Salary > 60000.00;

The SELECT statement retrieves the first and last names of employees whose salary

exceeds a specified threshold.

- DCL (Data Control Language):

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

revoking permissions to users and roles, ensuring data security.

Example:

-- Granting SELECT privilege 35 to a user


GRANT SELECT ON Employees TO User123;

In this example, the GRANT command gives the user "User123" the privilege to retrieve

data from the "Employees" table.

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

describe its properties.

38 Example:

CREATE TABLE Customers (

CustomerID INT PRIMARY KEY,

FirstName VARCHAR(50),

LastName VARCHAR(50),

Email VARCHAR(100) UNIQUE

);

Customers Entity- This represents a group of entities related to customers. Each row

(record) 2 in the "Customers" table corresponds to a unique customer.

Attributes-

CustomerID: This is the unique identifier for each customer and is designated as the

primary key. It ensures that each customer record is uniquely identifiable.

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

constraint ensures that each email is distinct, preventing duplication.

Attributes:

Attributes are 52 the characteristics or properties that define an entity. In the context of a

database, attributes represent the columns of a table.

Taking the "Employees" entity as an example:

8 CREATE TABLE Employees (

EmployeeID INT PRIMARY KEY,

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

type, providing precision for financial data.

Relationships:

Relationships define connections between entities, describing how they 47 interact with

each other.

Consider the relationship between "Customers" and "Orders":


14 CREATE TABLE Orders (

OrderID INT PRIMARY KEY,

CustomerID INT,

OrderDate DATE,

FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID)

);

Customer-Order Relationship:

CustomerID: This attribute 32 in the "Orders" table is a foreign key, establishing a link to

the primary key (CustomerID) in the "Customers" table.

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.

Types of Relationships Used Between Entities

One-to-one (1:1) Relationship - A relationship where one entity is associated with exactly

only one instance is referred to as a one-to-one relationship. For example, a department

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

multiple instances of another entity is known as a one-to-many relationship. For example, a

department can have multiple employees.

Many-to-one (N:1) Relationship - This is the reverse 41 of a one-to-many relationship

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.

Many-to-Many (N: N) Relationship - A relationship where multiple instances of entity are


associated with multiple instances of another entity is a many-to-many relationship.

Consider it the same as interconnected network-like architecture. For example, multiple

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

table corresponds to an entity and is defined by its columns (attributes).

Using the "Customers" table as 1 an example:

CREATE TABLE Customers (

CustomerID INT PRIMARY KEY,

FirstName VARCHAR(50),

LastName VARCHAR(50),

Email VARCHAR(100) UNIQUE

);

Customers Table:

Each row represents a unique customer, and each column represents an attribute of the

customer (e.g., 6 CustomerID, FirstName, LastName, Email).

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

as a means of uniquely identifying each record in that table.

Key characteristics of a Primary Key include:

Uniqueness: Every value 2 in the primary key column must be unique within the table. No

two rows can have the same primary key value.

Non-null: The primary key column cannot contain null values. Each record must have a

valid and unique identifier.

Immutable: Ideally, 18 the values in the primary key column should not change over time.

This ensures stability in record identification.

2 Example:

CREATE TABLE Students (

StudentID INT PRIMARY KEY,

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.

Key characteristics 34 of a Foreign Key include:

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

exist in the referenced table's primary key.

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

in the referenced table.

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

record in one table refers to a non-existent record in another.

Example:

CREATE TABLE Orders (

OrderID INT PRIMARY KEY,

CustomerID INT,

OrderDate DATE,

FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID)

);

In this example, CustomerID in the "Orders" table is a foreign key that references the

primary key (CustomerID) in the "Customers" table.

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

the data model.

This exploration of the basics provides a foundation for understanding the architecture,

language, and fundamental components of relational databases.

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.

What is known as DBMS?

What is RDBMS for example?

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

(complex queries). Common examples of RDBMS are MySQL, Oracle, PostgreSQL,


Microsoft SQL server

Example - Consider an example of an Employee database which is managed by RDBMS.

Now how It can have different entities and relationships.

Entities and Attributes in Employee Database

Employee Table (Employee as Entity)

Attributes - employee ID, employee name, date of birth, address, mobile number, salary,

date of joining, experience, department, skills, etc.

Department Table (Department as another Entity)

Attributes - department ID, department name, location, employee ID, etc

Project (Project as another entity)

Attributes - Project name, employee id, department, deadline, etc.

Relationships defined

Now in this database 3 what are the different relationships that can exist among these

three entities in a database?

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

department can work on multiple projects.

Keys in the Database to identify and retrieve records

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

projects table project ID will act as a primary key.

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

will act as a foreign key.

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.

What is Field in DBMS?

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

behaviour, and helps to reflect complete database architecture.


Explain Database Normalization and what are normalization types.

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

technique to organize a database efficiently like transforming it from a collection of messy

information to a well-organized collection of clearly labelled indexes. It 29 ensures that

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

be addressed by following the normalization techniques listed below?

Reduce data redundancy - redundancy simply means duplicity of data or multiple

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

data repetition concept effectively.

Avoid Data Anomalies - Avoid some misspelt, incorrect data coming into a database while

performing insertion, updation, or deletion operations.

Improve data integrity - You can achieve 54 a high level of data accuracy by defining some

rules and constraints to structure the database logically.

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

removing all unnecessary details.


Different types of Normalization

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.

36 First Normal Form (1NF)

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

column rather than having all of them in one column.

It says that you should create unique primary keys means you should assign a separate

identifier for each record and avoid null values.

61 Second Normal Form (2NF)

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.

Third Normal Form (3NF)

It inherits the principle of the second normal form and states that there should not be any

transitive dependency 3 present in the database. In simple words, non-key attributes


should 31 not be dependent on other non-key attributes which means other than primary

key dependency no column should depend on any other column to retrieve the values.

Boyce-Codd Normal Form (BCNF)

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

focuses on removing all the redundancy by addressing where non-trivial dependency

exists between candidate keys.

Example of performing normalization in database

Consider a scenario of a sales table with columns such as Order ID, Product name,

product ID, product category, customer ID, and customer 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

on primary keys like order ID or product ID.

For 3NF, ensure that no non-key attributes should be interdependent. For example,

product name cannot be dependent on product category.

BCNF will ensure that every determinant in a table 3 is a candidate key like product ID.

53 Database normalization is a very important process to obtain a well-optimized database

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

creating a new and fresh database according to your needs.

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

include MySQL, MongoDB, PostgreSQL, and SQLite.

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

database with whatever name you want to create a database.

CREATE DATABASE my_database;

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 (

employee_id INT AUTO_INCREMENT PRIMARY KEY,

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

and other statements to play with the database.

How 2 Data is stored in DBMS?

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

multiple below factors.

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.

Rows and columns - As data is reached or segregated according to information, then to

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

that 10 is stored in the row in that particular column cell.

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

records and retrieve them from a database.

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

from a specific city.

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

1 In this comprehensive guide to database management systems (DBMS), we have

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

interacting with DBMS.

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

beginning; the real adventure starts now.


Sources
https://www.mygreatlearning.com/blog/sql-commands/
1 INTERNET
4%
https://www.almabetter.com/bytes/articles/integrity-constraints-in-dbms
2 INTERNET
1%
https://www.analyticsvidhya.com/blog/2020/07/difference-between-sql-keys-primary-key-
3 super-key-candidate-key-foreign-key/
INTERNET
1%
https://www.prisma.io/dataguide/intro/what-are-databases
4 INTERNET
<1%
https://www.theknowledgeacademy.com/blog/what-is-dbms/
5 INTERNET
<1%
https://learnsql.com/blog/why-use-primary-key-foreign-key/
6 INTERNET
<1%
https://www.ibm.com/topics/relational-databases
7 INTERNET
<1%
https://www.cojolt.io/blog/sql-server-constraints
8 INTERNET
<1%
https://www.actiondesk.io/blog/sql-for-beginners-how-to-access-data-from-a-sql-database
9 INTERNET
<1%
https://saifytech.com/blog_detail/understanding-atomic-data-transaction-in-sql
10 INTERNET
<1%
https://dbeaver.com/2022/06/30/two-ways-to-use-erd-in-dbeaver/
11 INTERNET
<1%
https://database.academy/database-tutorials/acid-properties-in-dbms/
12 INTERNET
<1%
https://www.geeksforgeeks.org/primary-key-in-dbms/
13 INTERNET
<1%
https://medium.com/@iammanolov98/sql-denormalization-coding-interview-question-
14 d66a65259b79
INTERNET
<1%
https://www.bmc.com/blogs/dbms-database-management-systems/
15 INTERNET
<1%
https://www.educative.io/blog/crud-operations
16 INTERNET
<1%
https://www.almabetter.com/bytes/articles/types-of-databases
17 INTERNET
<1%
https://databasecamp.de/en/data/primary-key
18 INTERNET
<1%
https://medium.com/@musarrif2000/10-differences-between-dbms-and-rdbms-dbms-
19 database-management-system-and-rdbms-relational-a9ec44a3f480
INTERNET
<1%
https://www.knack.com/blog/database-for-hospital/
20 INTERNET
<1%
https://www.golinuxcloud.com/sql-update-statement-examples/
21 INTERNET
<1%
https://datarundown.com/concurrency-control-dbms/
22 INTERNET
<1%
https://www.scaler.com/topics/dbms/acid-properties-in-dbms/
23 INTERNET
<1%
https://database.guide/what-is-an-oodbms/
24 INTERNET
<1%
https://en.wikipedia.org/wiki/Redis
25 INTERNET
<1%
https://learn.microsoft.com/en-us/sql/relational-databases/tables/primary-and-foreign-key-
26 constraints?view=sql-server-ver16
INTERNET
<1%
https://datacadamia.com/data/property/atomicity
27 INTERNET
<1%
https://www.coursera.org/articles/relational-database
28 INTERNET
<1%
https://www.simplilearn.com/tutorials/dbms-tutorial/dbms-vs-rdbms
29 INTERNET
<1%
https://database.academy/database-tutorials/data-independence-and-data-abstraction/
30 INTERNET
<1%
https://cs186berkeley.net/notes/note11/
31 INTERNET
<1%
https://www.programiz.com/sql/foreign-key
32 INTERNET
<1%
https://www.integrate.io/blog/structured-vs-unstructured-data-key-differences/
33 INTERNET
<1%
https://www.techopedia.com/definition/7272/foreign-key
34 INTERNET
<1%
https://database.academy/database-tutorials/sql-grant-command/
35 INTERNET
<1%
https://guides.visual-paradigm.com/a-comprehensive-guide-to-database-normalization-with-
36 examples/
INTERNET
<1%
https://www.atlassian.com/data/sql
37 INTERNET
<1%
https://medium.com/towards-data-engineering/most-asked-sql-interview-questions-in-data-
38 engineering-interviews-part-ii-d5a185d82d38
INTERNET
<1%
https://www.techopedia.com/definition/884/data-compression
39 INTERNET
<1%
https://www.techtarget.com/searchdatacenter/definition/IMS-Information-Management-
40 System
INTERNET
<1%
https://medium.com/@mondoa/entity-relationship-diagrams-er-diagrams-demystified-
41 f8495d7970b5
INTERNET
<1%
https://www.dell.com/en-us/blog/scaling-data-and-analytics-productization-key-strategies-for-
42 success/
INTERNET
<1%
https://en.wikipedia.org/wiki/Referential_integrity#:~:text=Definition: Referential integrity is a
43 database concept that,is a corresponding record in the linked table.
INTERNET
<1%
https://www.upskillcampus.com/blog/network-database-management-system
44 INTERNET
<1%
https://en.wikipedia.org/wiki/Create,_read,_update_and_delete
45 INTERNET
<1%
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC9875417/
46 INTERNET
<1%
https://database.academy/database-tutorials/network-data-model/
47 INTERNET
<1%
https://builtin.com/data-science/database-management-system
48 INTERNET
<1%
https://techcommunity.microsoft.com/t5/azure-database-support-blog/lesson-learned-414-
49 demystifying-execution-plans-and-query/ba-p/3894148
INTERNET
<1%
https://medium.com/@brechtcorbeel/building-a-social-media-platform-what-strategies-
50 should-be-used-for-efficiently-handling-and-f6812a69042d
INTERNET
<1%
https://www.oracle.com/mysql/what-is-mysql/
51 INTERNET
<1%
https://binaryterms.com/difference-between-entity-and-attribute-in-database.html
52 INTERNET
<1%
https://phoenixnap.com/kb/database-normalization
53 INTERNET
<1%
https://www.techtarget.com/searchdatabackup/feature/Full-incremental-or-differential-How-
54 to-choose-the-correct-backup-type
INTERNET
<1%
https://www.manageengine.com/network-monitoring/tech-topics/what-is-network-
55 visualization.html
INTERNET
<1%
https://www.geeksforgeeks.org/the-problem-of-redundancy-in-database/
56 INTERNET
<1%
https://www.altexsoft.com/blog/unstructured-data/
57 INTERNET
<1%
https://www.bmc.com/blogs/acid-atomic-consistent-isolated-durable/
58 INTERNET
<1%
https://aws.amazon.com/what-is/sql/
59 INTERNET
<1%
https://stackoverflow.com/questions/11656150/er-diagram-project-task-and-employee
60 INTERNET
<1%
https://betterdataengineer.com/docs/database-fundamentals/normalization/2nf/
61 INTERNET
<1%
https://www.examtopics.com/discussions/microsoft/view/30092-exam-dp-900-topic-1-
62 question-110-discussion/
INTERNET
<1%
https://blogs.oracle.com/ateam/post/leveraging-langchain-and-llm-for-seamless-oracle-
63 database-queries
INTERNET
<1%

EXCLUDE CUSTOM MATCHES ON

EXCLUDE QUOTES OFF

EXCLUDE BIBLIOGRAPHY OFF

You might also like