Unit-I DBMS
Unit-I DBMS
Unit-I DBMS
What is Database
The database is a collection of inter-related data which is used to retrieve, insert and delete the data
efficiently. It is also used to organize the data in the form of a table, schema, views, and reports, etc.
For example: The college Database organizes the data about the admin, staff, students and faculty etc.
Using the database, you can easily retrieve, insert, and delete the information.
o Database management system is a software which is used to manage the database. For
example: MySQL, Oracle, etc are a very popular commercial database which is used in different
applications.
o DBMS provides an interface to perform various operations like database creation, storing data
in it, updating data, creating a table in the database and a lot more.
o It provides protection and security to the database. In the case of multiple users, it also
maintains data consistency.
o Data Definition: It is used for creation, modification, and removal of definition that defines the
organization of data in the database.
o Data Updation: It is used for the insertion, modification, and deletion of the actual data in the
database.
o Data Retrieval: It is used to retrieve the data from the database which can be used by
applications for various purposes.
o User Administration: It is used for registering and monitoring users, maintain data integrity,
enforcing data security, dealing with concurrency control, monitoring performance and
recovering information corrupted by unexpected failure.
Characteristics of DBMS
o It uses a digital repository established on a server to store and manage the information.
o It can provide a clear and logical view of the process that manipulates data.
o DBMS contains automatic backup and recovery procedures.
o It contains ACID properties which maintain data in a healthy state in case of failure.
o It can reduce the complex relationship between data.
o It is used to support manipulation and processing of data.
o It is used to provide security of data.
o It can view the database from different viewpoints according to the requirements of the user.
Advantages of DBMS
o Controls database redundancy: It can control data redundancy because it stores all the data in
one single database file and that recorded data is placed in the database.
o Data sharing: In DBMS, the authorized users of an organization can share the data among
multiple users.
o Easily Maintenance: It can be easily maintainable due to the centralized nature of the database
system.
o Reduce time: It reduces development time and maintenance need.
o Backup: It provides backup and recovery subsystems which create automatic backup of data
from hardware and software failures and restores the data if required.
o multiple user interface: It provides different types of user interfaces like graphical user
interfaces, application program interfaces
Disadvantages of DBMS
o Cost of Hardware and Software: It requires a high speed of data processor and large memory
size to run DBMS software.
o Size: It occupies a large space of disks and large memory to run them efficiently.
o Complexity: Database system creates additional complexity and requirements.
o Higher impact of failure: Failure is highly impacted the database because in most of the
organization, all the data stored in a single database and if the database is damaged due to
electric failure or database corruption then the data may be lost forever.
Network Database: When the details of multiple members can be linked to the files of
multiple owners and vice versa, it is called a network database.
Hierarchical Database: When the data stored in the form of records and is connected
to each other through links is called hierarchical database. Each record comprises fields
and each field comprises only one value.
Relational Database: When the data is organized as a set of tables comprising rows
and columns with a pre-defined relationship with one another, it is called a relational
database.
Object-oriented Database – the information is represented as objects, with different
types of relationships possible between two or more objects. Such databases use an
object-oriented programming language for development.
Data: The main component is the data. The entire database is set based on the data and
the information processed based on it. This data acts as a bridge between the software
and hardware components of DBMS. This can further be divided into three varieties:
User Data – The actual data based on which the work is done
Metadata – This is the data of the data, i.e., managing the data required to enter
the information
Application Meta Data – This is the structure and format of the queries
To simplify it, in a table, the information given in each table is the User Data, the number of
tables, rows and columns is the Meta Data the structure we choose is the Application Meta
Data.
Hardware: These are the general hardware devices which help us save and enter the
data like hard disks, magnetic tapes, etc.
Software: The software acts as a medium of communication between the user and the
database. Based on the user’s requirement, the database can be modified and updated.
To perform operations on the data, query languages like SQL are used.
Benefits of Using Database Management System
Major Organizations and Banking firms choose to work using the Database Management
System. It is because this system program helps the user and the administrator easily manages
the data and information on the database.
Securing the data is easy. The administrator can restrict the usage of the database to a
few people only. Thus, access to the database is restricted only to the administering
team of an Organization or Business which can keep the data safe
A single file can manage the entire database which is why duplicity and redundancy
cannot happen. This makes the data more consistent and easy to update
Since tables can be created in DBMS, interrelating the data and elements with each other
is convenient
The backup and recovery of data is managed by the software, which ensures that the
database is secure at all times
It allows multi-users to operate the database at a single time, making it more efficient
Users: No function can be performed without the Users. Thus, they form the fourth
most important component of DBMS. The information entered into a database is used by
the User or the administrator to perform their business operations and responsibilities.
Depending on your requirement and project, it is important to choose the right data
structure for your project. For example, if you want to store data sequentially in the
memory, then you can go for the Array data structure.
A linked list
Non-linear data structures are further divided into graph and tree based data structures.
The data items are arranged in sequential order, The data items are arranged in non-sequential
one after the other. order (hierarchical manner).
All the items are present on the single layer. The data items are present at different layers.
It can be traversed on a single run. That is, if we It requires multiple runs. That is, if we start
start from the first element, we can traverse all from the first element it might not be possible to
the elements sequentially in a single pass. traverse all the elements in a single pass.
The time complexity increase with the data size. Time complexity remains the same.
Knowledge about data structures help you understand the working of each data structure.
And, based on that you can select the right data structures for your project.
SQL is by far the most popular and commonly used query language for relational databases. It
is known as a declarative language, meaning it describes what needs to be accomplished
rather than how to accomplish it, but it also includes traditionally procedural elements.
Although there are many DQL and SQL variants, and the terms can overlap, SQL sub-languages
are commonly divided into five main categories:
Data Query Language (DQL)
Data Definition Language (DDL)
Data Control Language (DCL)
Data Manipulation Language (DML)
Transaction Control Language (TCL)
From database administration to narrower use cases like business intelligence and software
development, query languages are instrumental in enabling data-driven decisions. Through
data mining and analytics, query languages are used to identify patterns and trends that can
help everyone from customer service staff to CEOs gain valuable insights.
For large data-dependent companies all the way down to the smallest ecommerce merchants,
the ability to leverage user information and act upon it is now a core pillar of many business
models.
To name just a few practical applications across industries:
In healthcare, DQLs can be used to analyze large data sets of information about patient
behavior and medical conditions.
Financial institutions from banks to payment processors use data query languages to do
everything from detecting fraud to delivering personalized customer experiences.
Social media platforms use DQLs to store, sort, and update information about user profiles,
views, purchase history, new posts, likes and shares, and so much more.
Marketers use DQLs and SQLs to identify target audiences, track sales attribution and
campaign performance across channels, and analyze consumer behavior patterns.
Database administrators use DQLs to update, maintain, and secure their environments,
keeping confidential information about users, employees, students, or patients safe.
Data analysts and data scientists in business and research use DQL to streamline the
process of sorting through massive data sets to discover trends and insights.
SQL Commands
o SQL commands are instructions. It is used to communicate with the database. It is also used to
perform specific tasks, functions, and queries of data.
o SQL can perform various tasks like create a table, add data to tables, drop the table, modify the
table, set permission for users.
Example:
1. CREATE TABLE EMPLOYEE(Name VARCHAR2(20), Email VARCHAR2(100), DOB DATE);
b. DROP: It is used to delete both the structure and record stored in the table.
Syntax
1. DROP TABLE table_name;
Example
1. DROP TABLE EMPLOYEE;
c. ALTER: It is used to alter the structure of the database. This change could be either to modify the
characteristics of an existing attribute or probably to add a new attribute.
Syntax:
To add a new column in the table
1. ALTER TABLE table_name ADD column_name COLUMN-definition;
To modify existing column in the table:
a. INSERT: The INSERT statement is a SQL query. It is used to insert data into the row of a table.
Syntax:
For example:
Syntax:
1. UPDATE table_name SET [column_name1= value1,...column_nameN = valueN] [WHERE CONDITION]
For example:
1. UPDATE students
2. SET User_Name = 'Sonoo'
3. WHERE Student_Id = '3'
Syntax:
For example:
Example
Example
These operations are automatically committed in the database that's why they cannot be used while
creating tables or dropping them.
Syntax:
1. COMMIT;
Example:
1. DELETE FROM CUSTOMERS
2. WHERE AGE = 25;
3. COMMIT;
b. Rollback: Rollback command is used to undo transactions that have not already been saved to the
database.
Syntax:
1. ROLLBACK;
Example:
1. DELETE FROM CUSTOMERS
2. WHERE AGE = 25;
3. ROLLBACK;
c. SAVEPOINT: It is used to roll the transaction back to a certain point without rolling back the entire
transaction.
Syntax:
1. SAVEPOINT SAVEPOINT_NAME;
a. SELECT: This is the same as the projection operation of relational algebra. It is used to select the
attribute based on the condition described by WHERE clause.
Syntax:
1. SELECT expressions
2. FROM TABLES
3. WHERE conditions;
For example:
1. SELECT emp_name
2. FROM employee
3. WHERE age > 20;
Views in DBMS
A view in SQL is a virtual table that is based upon the result-set of an SQL statement
A view will also have rows and columns just like a real table in a database
Simply a view is nothing but a stored SQL Query
A view can contain all the rows of a table or specific rows based on some condition
SQL functions conditions and join statements to a view and present the data just like the
data is produced from a single table
Creating a view
A view is created by selecting fields from one or more tables present in a database
Syntax
Note:
Whenever a user creates a view, database engine recreates the data using the views SQL
statement i.e. view always shows upto date data
1 Harini Kolkata
2 Preity Hyderabad
3 Divya Chennai
4 Kushi Mumbai
5 Amitha Bangalore
StudentMarks
1 Harini 96 20
2 Manisha 90 19
3 Divya 94 21
4 Kushi 92 19
5 Amitha 95 21
In this example, we will create a view named as DetailsView from a single table
StudentDetails
The data present in a view can be seen just like a normal table select query
Output:
NAME ADDRESS
Harini Kolkata
Preity Hyderabad
Divya Chennai
Kushi Mumbai
In this example will create a view named MarksView by taking data from both the
table’s student details and student marks
To create a View from multiple tables just simply include multiple tables in the SELECT
statement.
Output:
Harini 96 Kolkata
Divya 94 Chennai
Kushi 92 Mumbai
Amitha 95 Bangalore
Syntax:
Views are updated only if certain conditions are met otherwise if any one of the conditions
are not met views will not be updated
The select statement used in the create view statement should not include group by
clause or order by clause
The select statement must not contain distinct keyword
A view should not be created from nested or Complex queries
A view should be created from a single table but if the view is created from more
than one table then it is not allowed for updating
Create or replace view statement is used to add or remove fields from existing views
Syntax:
Update the view MarksView and add the field AGE to this View from StudentMarks Table,
Output
NAME ADDRESS MARKS AGE
HARINI Kolkata 96 20
Divya Chennai 94 21
Kushi Mumbai 92 19
Amitha Bangalore 95 21
We can use insert into statement of SQL to insert a row in a view just like inserting a row in
an ordinary table
Syntax:
Example
Output
NAME ADDRESS
Harini Kolkotta
Divya Chennai
Kushi Mumbai
Amitha Bangalore
Preity Hyderabad
Deleting a row from a view
A row in a view can be deleted just like simply deleting rows from a Table using
delete statement
But remember a row in a view can be deleted only if the row is actually deleted in the
original table from which it is created
Syntax:
Example
Output:
NAME ADDRESS
Harini Kolkotta
Divya Chennai
Kushi Mumbai
Amitha Bangalore
Preity Hyderabad
Advantages
Modifications: Not all views support INSERT, UPDATE, or DELETE operations. Complex
multi-table views are generally read-only.
Performance: Hugely complex job for the database engine. That is because each time a
view is referenced, the query used to define it, is rerun.
Objectives Of DBMS
DBMS has many objectives to increase the efficiency and organized handling of data
in an organization. The main objectives of DBMS are –
Data Availability:
DBMS ensures that the format of data should be meaningful and at a reasonable cost
so that a wide range of users can access it.
DBMS structures and efficiently organize the data to eliminate data complexity and
provide a framework for relationships between different data entities.
To maintain the authority of data and protect it from unauthorized access, DBMS
validates the user and gives permissions to only authorized users to view, modify,
and delete.
Data Independence:
My SQL : It is the world's most popular open source database. According to DB-Engines, MySQL
ranks as the second-most-popular database, behind Oracle Database. MySQL powers many of the
most accessed applications, including Facebook, Twitter, Netflix, Uber, Airbnb, Shopify, and
Booking.com.
Oracle Database: is designed as a multiuser database. The database must ensure that multiple
users can work concurrently without corrupting one another's data. A transaction is a logical, atomic
unit of work that contains one or more SQL statements.
IBM® Db2®: is a cloud-native database built on decades of expertise in bringing data governance
and security, low-latency transactions and continuous availability to your mission critical data,
analytics and AI-driven applications.
Microsoft SQL Server: is a relational database management system (RDBMS) that Supports a
wide variety of transaction processing, business intelligence (BI) and data analytics applications in
corporate IT environments.
Microsoft Access: is a popular information management tool that helps you store all kinds of
information for reporting, analysis and reference. With Microsoft Access, you can manage data more
efficiently and analyze large amounts of information.
UNIT-2
Introduction to AI Applications in Pharmacy
Introduction
Artificial Intelligence (AI) is a domain of computer science which deals with the development of
intelligent computer systems, which are capable to perceive, analyze, and react accordingly to the
inputs It is well-known fact that humans are considered as the most intelligent and smart species on
earth. The features which have helped them to bag this title include the ability to think, apply logic,
do reasoning, understand the complexity, and make decisions on their own
There are many areas which contribute to artificial intelligence which includes mathematics (used for
developing algorithms), biology, philosophy, psychology, neuroscience (for studying human mind
and its behavior), statistics (for handling huge data), and last but not the least, computer science (to
run the algorithm for implementing the concepts).
The various types of artificial intelligence based on the capabilities can be classified as
--Weak or narrow AI
– General AI
– Strong AI.
Weak or narrow AI: it is a type of AI which can perform a predefined narrow set of instructions
without exhibiting any thinking capability. It is the most widely used type of AI in this world. Some
famous examples are Apples’s Siri, Alexa, Alpha Go, IBM’s Watson supercomputer, Sophia (the
humanoid) all belong to the weak AI type.
General AI: it is the type of AI which can perform the tasks like what human can do. Till now it is
not achieved, there are no such machines which works like human or can think as perfectly as
human, but it may happen in near future.
Strong AI: it is the type of AI in which it is expected that the machine will surpass the capacity of
human. It will perform better than humans, though it is tough, but it is not impossible. It may be the
situation when it can be said that the machines will be the master and overtake humans.
Based on the functionality, artificial intelligence can be classified as per the following types:
(iv) Self-awareness
Reactive machines: These are the machines which works on the data available in the form of
predefined dataset. It does not have the facility of data storage for storing the past and future data. It
completely depends on the present data. IBM’s chess program which defeated famous champion
Garry Kasparov and the deep blue system, Google’s AlphaGo are some of the examples for reactive
machines.
Limited memory: these are the machines which can store the past experience or store the memory
for limited period of time. An example for limited memory AI is the self-driving cars (it can store the
information like speed, distance, speed limit required for the navigation of the car).
Theory of mind: these are types of machines, which are expected to understand the psychological
and emotional aspects of human mind and work accordingly. So far such machines are a dream but
scientists are working to develop such machines in near future.
Self-awareness: these machines belong to a hypothetical concept that will be considered as super-
intelligent machines, which can think, act, and will be self-aware as they will have consciousness and
sentiments like humans. Research is carried out to develop such machines and considered as future
AI.
Domains of AI
The major domains of AI (Fig. 1) are neural network, robotics, expert systems, fuzzy logic systems,
natural language processing (NLP).
Neural networks: these can be described as the representation of human neural system, i.e., neurons
and dendrites in the form of layers and nodes representing data. It comprises algorithms that
understand the relationships between the data while mimicking the human brain. These are widely
used in AI in the form of machine learning and deep learning. Some of the typical examples are
pattern recognition of face and image recognition in medical diagnosis.
Robotics: it is the domain of AI which is mostly associated with the development of intelligent
machines in the form of robot which obeys human instructions. The use of robots or humanoids is a
new trend and is being appreciated and adopted worldwide. Robots used in industry, medical
surgery, restaurants, etc., are classified under this category.
Expert system: these are systems which make decisions with the help of data present in the
knowledge base and getting guidance by an expert. These are basically computer applications
developed to solve complex problems with intelligence and expertise.
Fuzzy logic system: this domain is considered as resembling the human thinking method and
decision-making. It is quite similar to the way humans decide between 0 and 1, but it also deals with
all the possibilities between 0 and 1. Examples of fuzzy logic systems used are in consumer
electronics, automobiles, comparison of data, etc.
Artificial intelligence has emerged as a boon for the society for the furtherance of advanced
techniques to deal with the real-life problems. The major two subsets of AI are Machine Learning
(ML) and Deep Learning (DL). ML is considered as the subset of AI and DL is considered as the
subset of ML.
Machine Learning:
As humans can think, improve by self-improvement cycle, and learn from the past
experiences, AI machines can also learn from the past experiences with the help of the concept
known as Machine Learning (ML). The machine learning deals with the development of algorithms
that enables the computer to learn from its data and past experiences on their own.
Classification of Machine Learning Based on the nature of the learning signal or response that the
machine gets; machine learning can be classified into following categories:
Supervised learning:
according to the literal meaning, this method correlates with the method of learning of student under
the supervision of a teacher. As a teacher illustrates the student with many good examples to help in
grasping the concept perfectly, the machine is provided with many labeled data to help in obtaining
the perfect output from the given input.
Unsupervised learning:
in this method the machine has to train itself without any supervisor, i.e., the data provided at the
input are not labeled or classified. The algorithm has to train itself by searching the degree of
similarities among the given data and figure out the appropriate output for the given problem.
Reinforcement learning: this method is typically a feedback-based learning method. In this method
the machine is given a reward for every right action taken by it and a penalty for any wrong action,
so it is a self-learning method done by analyzing its past performances.
1.The basic challenge and limitation for ML are that it requires huge amount of data. Without quality
data, ML algorithm cannot provide accurate results for further analysis. The prediction can be
considered best if the analysis is done over a large amount of data.
2.Another point is that the data need to be heterogeneous as well. With wide range of inputs or
datasets, the efficiency of the algorithm will be enhanced with appropriate output.
Deep Learning
Deep Learning (DL) is considered as the sub domain of ML and thereby the subset of AI. Deep
learning can be denoted as the next level of machine learning where the system is similar to human
nervous system and mimic the working of the neurons. As the number of layers increases, it is called
as deep learning or Deep Neural Network (DNN) . The initial layer is denoted as the input layer, the
last layer is called the output layer and the intermediate layers are termed as the hidden layer, where
all the layers are inter connected .
It helps in enhanced feature extraction, pattern recognition of complex dataset and high-level
data extraction. The main advantage is that it can learn without any predefined data and does not
require explicit programming by the programmers.
Problem Solving Techniques in AI
The process of problem-solving is frequently used to achieve objectives or resolve particular
situations. In computer science, the term "problem-solving" refers to artificial intelligence methods,
which may include formulating ensuring appropriate, using algorithms, and conducting root-cause
analyses that identify reasonable solutions. Artificial intelligence (AI) problem-solving often involves
investigating potential solutions to problems through reasoning techniques, making use of
polynomial and differential equations, and carrying them out and use modelling frameworks. A
same issue has a number of solutions, that are all accomplished using an unique algorithm.
Additionally, certain issues have original remedies. Everything depends on how the particular
situation is framed.
o Chess
o N-Queen problem
o Tower of Hanoi Problem
o Travelling Salesman Problem
o Water-Jug Problem
This mapping of states and actions is made easier through these agencies. These agents frequently
make mistakes when moving onto the subsequent phase of a complicated issue; hence, problem-
solving standardized criteria such cases. Those agents employ artificial intelligence can tackle issues
utilising methods like B-tree and heuristic algorithms.
Heuristics
The heuristic approach focuses solely upon experimentation as well as test procedures to
comprehend a problem and create a solution. These heuristics don't always offer better ideal answer
to something like a particular issue, though. Such, however, unquestionably provide effective means
of achieving short-term objectives. Consequently, if conventional techniques are unable to solve the
issue effectively, developers turn to them. Heuristics are employed in conjunction with optimization
algorithms to increase the efficiency because they merely offer moment alternatives while
compromising precision.
Searching Algorithms
Several of the fundamental ways that AI solves every challenge is through searching. These
searching algorithms are used by rational agents or problem-solving agents for select the most
appropriate answers. Intelligent entities use molecular representations and seem to be frequently
main objective when finding solutions. Depending upon that calibre of the solutions they produce,
most searching algorithms also have attributes of completeness, optimality, time complexity, and
high computational.
Computing Evolutionary
This approach to issue makes use of the well-established evolutionary idea. The idea of "survival of
the fittest underlies the evolutionary theory. According to this, when a creature successfully
reproduces in a tough or changing environment, these coping mechanisms are eventually passed
down to the later generations, leading to something like a variety of new young species. By
combining several traits that go along with that severe environment, these mutated animals aren't
just clones of something like the old ones. The much more notable example as to how development
is changed and expanded is humanity, which have done so as a consequence of the accumulation of
advantageous mutations over countless generations.
Genetic Algorithms
Genetic algorithms have been proposed upon that evolutionary theory. These programs employ a
technique called direct random search. In order to combine the two healthiest possibilities and
produce a desirable offspring, the developers calculate the fit factor. Overall health of each
individual is determined by first gathering demographic information and afterwards assessing each
individual. According on how well each member matches that intended need, a calculation is made.
Next, its creators employ a variety of methodologies to retain their finest participants.
1. Rank Selection
2. Tournament Selection
3. Steady Selection
4. Roulette Wheel Selection (Fitness Proportionate Selection)
5. Elitism
o Knowledge representation and reasoning (KR, KRR) is the part of Artificial intelligence which
concerned with AI agents thinking and how thinking contributes to intelligent behavior of
agents.
o It is responsible for representing information about the real world so that a computer can
understand and can utilize this knowledge to solve the complex real world problems such as
diagnosis a medical condition or communicating with humans in natural language.
o It is also a way which describes how we can represent knowledge in artificial intelligence.
Knowledge representation is not just storing data into some database, but it also enables an
intelligent machine to learn from that knowledge and experiences so that it can behave
intelligently like a human.
What to Represent:
Following are the kind of knowledge which needs to be represented in AI systems:
o Object: All the facts about objects in our world domain. E.g., Guitars contains strings,
trumpets are brass instruments.
o Events: Events are the actions which occur in our world.
o Performance: It describe behavior which involves knowledge about how to do things.
o Meta-knowledge: It is knowledge about what we know.
o Facts: Facts are the truths about the real world and what we represent.
o Knowledge-Base: The central component of the knowledge-based agents is the knowledge
base. It is represented as KB. The Knowledgebase is a group of the Sentences (Here,
sentences are used as a technical term and not identical with the English language).
Knowledge: Knowledge is awareness or familiarity gained by experiences of facts, data, and
situations. Following are the types of knowledge in artificial intelligence:
Types of knowledge
Following are the various types of knowledge:
1. Declarative Knowledge:
2. Procedural Knowledge
3. Meta-knowledge:
o Knowledge about the other types of knowledge is called Meta-knowledge.
4. Heuristic knowledge:
5. Structural knowledge:
AI knowledge cycle:
An Artificial intelligence system has the following components for displaying intelligent
behavior:
o Perception
o Learning
o Planning
o Execution
The above diagram is showing how an AI system can interact with the real world and what
components help it to show intelligence. AI system has Perception component by which it retrieves
information from its environment. It can be visual, audio or another form of sensory input. The
learning component is responsible for learning from data captured by Perception comportment. In the
complete cycle, the main components are knowledge representation and Reasoning. These two
components are involved in showing the intelligence in machine-like humans. These two
components are independent with each other but also coupled together. The planning and execution
depend on analysis of Knowledge representation and reasoning.