SlideShare a Scribd company logo
ADVANCED SQL
Contents
 Embedded SQL
 Dynamic SQL
 Functional Dependency
 Decomposition using Functional Dependencies
∪
EMBEDDED SQL
What is Embedded SQL?
1. When we talk about industry-level applications we need properly connected systems which
could draw data from the database and present to the user. In such cases, the Embedded SQL
comes to our rescue.
2. We embed SQL queries into high-level languages such that they can easily perform the logic
part of our analysis.
3. Some of the prominent examples of languages with which we embed SQL are: C++, Java,
Python, etc.
4. Embedded SQL gives us the freedom to use databases as and when required.
5. Once the application we develop goes into the production mode several things need to be
taken care of.
6. With the help of the embedding of queries, we can easily use the database without creating
any bulky code.
7. With the embedded SQL, we can also create API’s which can easily fetch and feed data
whenever required.
How to Embed SQL in High-Level
Languages?
1. For using embedded SQL, we need some tools in each high-level
language.
2. In some cases, we have inbuilt libraries which provide us with the
basic building block.
3. While in some cases we need to import or use some packages to
perform the desired tasks.
4. For example:
Class.forName( “com.mysql.jdbc.Driver“ );
Connection connection = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/DataFlair","user","root“ );
Statement statement = connection.createStatement();
ADVANTAGES OF EMBEDDED SQL
1. Helps to access databases from anywhere.
2. Allows integrating authentication service for large scale
applications.
3. Provides extra security to database transactions.
4. Avoids logical errors while performing transactions on our
database.
5. Makes it easy to integrate the frontend and the backend of our
application.
DYNAMIC SQL
What is Dynamic SQL?
1. Dynamic SQL is the process for programming SQL queries that are built dynamically with the
application operations.
2. Manage big industrial applications and manage the transactions without overhead.
3. We are free to create flexible SQL queries and the names of the variables or any other parameters
are passed when the application runs.
4. We can use stored procedures to create dynamic queries which can run when we desire.
5. We use the exec keyword.
6. When we use static SQL it is not altered from one execution to others, but in the case of dynamic
SQL, we can alter the query in each execution.
7. We should always prefer using static SQL over dynamic SQL for the following benefits of the static
SQL:
• If a query compiles successfully it implies that the syntax is correct.
• If a query compiles successfully it verifies that all the permissions and validations are correct.
• As all the data is pre-known in static SQL the overhead charges are reduced considerably.
When to Use Dynamic SQL?
1. When static SQL does not support.
2. When exact SQL statements are not known.
3. When we want to execute
• DDL: CREATE, DROP, GRANT, REVOKE
• DML: INSERT, UPDATE, DELETE
• SCL: ALTER SESSION and SET ROLE
FUNCTIONAL
DEPENDENCY
What is Functional Dependency?
1. A functional dependency is a constraint that specifies the
relationship between two sets of attributes where one set can
accurately determine the value of other sets.
2. It is denoted as X → Y, where X is a set of attributes that is
capable of determining the value of Y.
3. X is called Determinant, and Y is called the Dependent.
4. Used to mathematically express relations among database
entities.
Example
• roll_no → { name, dept_name, dept_building }
• roll_no → dept_name
• dept_name → dept_building
Armstrong’s axioms/properties of Functional
Dependencies
• Reflexivity: If Y is a subset of X, then X→Y
For example, {roll_no, name} → name is valid.
• Augmentation: If X → Y is a valid dependency, then XZ → YZ
For example, If {roll_no, name} → dept_building is valid, then
{roll_no, name, dept_name} → {dept_building, dept_name} is
also valid.
• Transitivity: If X → Y and Y → Z are both valid dependencies,
then X→Z.
For example, roll_no → dept_name & dept_name →
dept_building, then roll_no → dept_building is also valid.
Types of Functional dependencies in DBMS
• Trivial functional dependency
• Non-Trivial functional dependency
• Multivalued functional dependency
• Transitive functional dependency
• A dependent is always a subset of the determinant.
i.e. If X → Y and Y is the subset of X
Trivial functional dependency
Non-trivial functional dependency
• A dependent is strictly not a subset of the determinant.
i.e. If X → Y and Y is not a subset of X
• Entities of the dependent set are not dependent on each other.
i.e. If a → {b, c} and there exists no functional
dependency between b and c.
• For example,
Multivalued functional dependency
Here, roll_no → {name, age} is a Multivalued
functional dependency, since the dependents
name & age are not dependent on each other
(i.e. name → age or age → name doesn’t exist)
• A dependent is indirectly dependent on determinant,
i.e. If a → b & b → c, then according to axiom of transitivity, a
→ c
• For example,
Transitive functional dependency
Here, enrol_no → dept and dept →
building_no.
Hence, according to the axiom of
transitivity, enrol_no → building_no is a
valid functional dependency. This is an
indirect functional dependency, hence
called Transitive functional dependency.
DECOMPOSITION USING
FUNCTIONAL
DEPENDENCIES
What is Decomposition?
1. When a relation is not in appropriate normal form then the
decomposition of a relation is required.
2. It breaks the table into multiple tables.
3. If the relation has no proper decomposition, then it may
lead to loss of information.
4. Eliminate some of the problems like anomalies,
inconsistencies, and redundancy.
Types of Decomposition
1. Dependency Preserving Decomposition
2. Lossless Decomposition
Dependency Preserving Decomposition
1. At least one decomposed table must satisfy every
dependency.
2. If a relation R is decomposed into relation R1 and R2, then
the dependencies of R must be a part of R1 or R2 or must
be derivable from the combination of functional
dependencies of R1 and R2.
3. That means, F1∪F2 ≡ F
Lossless Decomposition
1. If the information is not lost from the relation that is
decomposed, then the decomposition will be lossless.
2. The lossless decomposition guarantees that the join of
relations will result in the same relation as it was
decomposed.
3. The relation is said to be lossless decomposition if natural
joins of all the decomposition give the original relation.
THANK YOU

More Related Content

What's hot

Types Of Keys in DBMS
Types Of Keys in DBMSTypes Of Keys in DBMS
Types Of Keys in DBMS
PadamNepal1
 
Ms sql-server
Ms sql-serverMs sql-server
Ms sql-server
Md.Mojibul Hoque
 
PL/SQL Fundamentals I
PL/SQL Fundamentals IPL/SQL Fundamentals I
PL/SQL Fundamentals I
Nick Buytaert
 
Sql basics and DDL statements
Sql basics and DDL statementsSql basics and DDL statements
Sql basics and DDL statements
Mohd Tousif
 
Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)
Syed Hassan Ali
 
MS SQL Server
MS SQL ServerMS SQL Server
MS SQL Server
Md. Mahedee Hasan
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
Dashani Rajapaksha
 
Basic SQL and History
 Basic SQL and History Basic SQL and History
Basic SQL and History
SomeshwarMoholkar
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database Model
Shishir Aryal
 
Database Triggers
Database TriggersDatabase Triggers
Database Triggers
Aliya Saldanha
 
Transaction management DBMS
Transaction  management DBMSTransaction  management DBMS
Transaction management DBMS
Megha Patel
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
Stewart Rogers
 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
BG Java EE Course
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
farwa waqar
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
Shrija Madhu
 

What's hot (20)

Types Of Keys in DBMS
Types Of Keys in DBMSTypes Of Keys in DBMS
Types Of Keys in DBMS
 
Ms sql-server
Ms sql-serverMs sql-server
Ms sql-server
 
PL/SQL Fundamentals I
PL/SQL Fundamentals IPL/SQL Fundamentals I
PL/SQL Fundamentals I
 
Sql basics and DDL statements
Sql basics and DDL statementsSql basics and DDL statements
Sql basics and DDL statements
 
Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)
 
MS SQL Server
MS SQL ServerMS SQL Server
MS SQL Server
 
Stored procedure
Stored procedureStored procedure
Stored procedure
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
 
advanced sql(database)
advanced sql(database)advanced sql(database)
advanced sql(database)
 
Basic SQL and History
 Basic SQL and History Basic SQL and History
Basic SQL and History
 
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
 
Mysql
MysqlMysql
Mysql
 
The Relational Database Model
The Relational Database ModelThe Relational Database Model
The Relational Database Model
 
Database Triggers
Database TriggersDatabase Triggers
Database Triggers
 
Transaction management DBMS
Transaction  management DBMSTransaction  management DBMS
Transaction management DBMS
 
Sql select
Sql select Sql select
Sql select
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 

Similar to Advanced SQL

SQL and DBMS INTERVIEW QUESTIONS .pdf
SQL and DBMS INTERVIEW QUESTIONS .pdfSQL and DBMS INTERVIEW QUESTIONS .pdf
SQL and DBMS INTERVIEW QUESTIONS .pdf
NiravPanchal50
 
SQL EXCLUSIVE NOTES .pdf
SQL EXCLUSIVE NOTES .pdfSQL EXCLUSIVE NOTES .pdf
SQL EXCLUSIVE NOTES .pdf
NiravPanchal50
 
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
Karen Thompson
 
Sql interview-question-part-6
Sql interview-question-part-6Sql interview-question-part-6
Sql interview-question-part-6
kaashiv1
 
Sql interview question part 6
Sql interview question part 6Sql interview question part 6
Sql interview question part 6
kaashiv1
 
Ebook6
Ebook6Ebook6
Ebook6
kaashiv1
 
Sql interview-question-part-6
Sql interview-question-part-6Sql interview-question-part-6
Sql interview-question-part-6
kaashiv1
 
Kaashiv SQL Server Interview Questions Presentation
Kaashiv SQL Server Interview Questions PresentationKaashiv SQL Server Interview Questions Presentation
Kaashiv SQL Server Interview Questions Presentation
kaashiv1
 
Dbms important questions and answers
Dbms important questions and answersDbms important questions and answers
Dbms important questions and answers
LakshmiSarvani6
 
Data massage! databases scaled from one to one million nodes (ulf wendel)
Data massage! databases scaled from one to one million nodes (ulf wendel)Data massage! databases scaled from one to one million nodes (ulf wendel)
Data massage! databases scaled from one to one million nodes (ulf wendel)Zhang Bo
 
DBMS.pdf
DBMS.pdfDBMS.pdf
Sql interview question part 12
Sql interview question part 12Sql interview question part 12
Sql interview question part 12
kaashiv1
 
Sql interview question part 12
Sql interview question part 12Sql interview question part 12
Sql interview question part 12kaashiv1
 
Data massage: How databases have been scaled from one to one million nodes
Data massage: How databases have been scaled from one to one million nodesData massage: How databases have been scaled from one to one million nodes
Data massage: How databases have been scaled from one to one million nodes
Ulf Wendel
 
Sql vs no sql
Sql vs no sqlSql vs no sql
Sql vs no sql
Bhuwan Paneru
 
SQL vs MongoDB
SQL vs MongoDBSQL vs MongoDB
SQL vs MongoDB
calltutors
 
Sql server-dba
Sql server-dbaSql server-dba
Sql server-dba
NaviSoft
 

Similar to Advanced SQL (20)

SQL and DBMS INTERVIEW QUESTIONS .pdf
SQL and DBMS INTERVIEW QUESTIONS .pdfSQL and DBMS INTERVIEW QUESTIONS .pdf
SQL and DBMS INTERVIEW QUESTIONS .pdf
 
SQL EXCLUSIVE NOTES .pdf
SQL EXCLUSIVE NOTES .pdfSQL EXCLUSIVE NOTES .pdf
SQL EXCLUSIVE NOTES .pdf
 
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
Cis 555 Week 4 Assignment 2 Automated Teller Machine (Atm)...
 
Sql server
Sql serverSql server
Sql server
 
Sql interview-question-part-6
Sql interview-question-part-6Sql interview-question-part-6
Sql interview-question-part-6
 
Ebook6
Ebook6Ebook6
Ebook6
 
Sql interview question part 6
Sql interview question part 6Sql interview question part 6
Sql interview question part 6
 
Ebook6
Ebook6Ebook6
Ebook6
 
Sql interview-question-part-6
Sql interview-question-part-6Sql interview-question-part-6
Sql interview-question-part-6
 
Kaashiv SQL Server Interview Questions Presentation
Kaashiv SQL Server Interview Questions PresentationKaashiv SQL Server Interview Questions Presentation
Kaashiv SQL Server Interview Questions Presentation
 
Dbms important questions and answers
Dbms important questions and answersDbms important questions and answers
Dbms important questions and answers
 
Data massage! databases scaled from one to one million nodes (ulf wendel)
Data massage! databases scaled from one to one million nodes (ulf wendel)Data massage! databases scaled from one to one million nodes (ulf wendel)
Data massage! databases scaled from one to one million nodes (ulf wendel)
 
DBMS.pdf
DBMS.pdfDBMS.pdf
DBMS.pdf
 
Sql interview question part 12
Sql interview question part 12Sql interview question part 12
Sql interview question part 12
 
Ebook12
Ebook12Ebook12
Ebook12
 
Sql interview question part 12
Sql interview question part 12Sql interview question part 12
Sql interview question part 12
 
Data massage: How databases have been scaled from one to one million nodes
Data massage: How databases have been scaled from one to one million nodesData massage: How databases have been scaled from one to one million nodes
Data massage: How databases have been scaled from one to one million nodes
 
Sql vs no sql
Sql vs no sqlSql vs no sql
Sql vs no sql
 
SQL vs MongoDB
SQL vs MongoDBSQL vs MongoDB
SQL vs MongoDB
 
Sql server-dba
Sql server-dbaSql server-dba
Sql server-dba
 

More from Sabiha M

Cybersecurity
CybersecurityCybersecurity
Cybersecurity
Sabiha M
 
Top-Down Estimation Approach
Top-Down Estimation ApproachTop-Down Estimation Approach
Top-Down Estimation Approach
Sabiha M
 
Kernel Computing
Kernel ComputingKernel Computing
Kernel Computing
Sabiha M
 
Goal-Setting Theory of Motivation
Goal-Setting Theory of MotivationGoal-Setting Theory of Motivation
Goal-Setting Theory of Motivation
Sabiha M
 
Decomposition
DecompositionDecomposition
Decomposition
Sabiha M
 
Job Sequencing with Deadlines
Job Sequencing with DeadlinesJob Sequencing with Deadlines
Job Sequencing with Deadlines
Sabiha M
 
LAN, WAN, MAN
LAN, WAN, MANLAN, WAN, MAN
LAN, WAN, MAN
Sabiha M
 
Next Generation Internet
Next Generation InternetNext Generation Internet
Next Generation Internet
Sabiha M
 
Near Field Communication
Near Field CommunicationNear Field Communication
Near Field Communication
Sabiha M
 
Green Cloud Computing
Green Cloud ComputingGreen Cloud Computing
Green Cloud Computing
Sabiha M
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
Sabiha M
 
Apache web server
Apache web serverApache web server
Apache web server
Sabiha M
 
Types of parsers
Types of parsersTypes of parsers
Types of parsers
Sabiha M
 

More from Sabiha M (13)

Cybersecurity
CybersecurityCybersecurity
Cybersecurity
 
Top-Down Estimation Approach
Top-Down Estimation ApproachTop-Down Estimation Approach
Top-Down Estimation Approach
 
Kernel Computing
Kernel ComputingKernel Computing
Kernel Computing
 
Goal-Setting Theory of Motivation
Goal-Setting Theory of MotivationGoal-Setting Theory of Motivation
Goal-Setting Theory of Motivation
 
Decomposition
DecompositionDecomposition
Decomposition
 
Job Sequencing with Deadlines
Job Sequencing with DeadlinesJob Sequencing with Deadlines
Job Sequencing with Deadlines
 
LAN, WAN, MAN
LAN, WAN, MANLAN, WAN, MAN
LAN, WAN, MAN
 
Next Generation Internet
Next Generation InternetNext Generation Internet
Next Generation Internet
 
Near Field Communication
Near Field CommunicationNear Field Communication
Near Field Communication
 
Green Cloud Computing
Green Cloud ComputingGreen Cloud Computing
Green Cloud Computing
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method Invocation
 
Apache web server
Apache web serverApache web server
Apache web server
 
Types of parsers
Types of parsersTypes of parsers
Types of parsers
 

Recently uploaded

ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 

Recently uploaded (20)

ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 

Advanced SQL

  • 2. Contents  Embedded SQL  Dynamic SQL  Functional Dependency  Decomposition using Functional Dependencies ∪
  • 4. What is Embedded SQL? 1. When we talk about industry-level applications we need properly connected systems which could draw data from the database and present to the user. In such cases, the Embedded SQL comes to our rescue. 2. We embed SQL queries into high-level languages such that they can easily perform the logic part of our analysis. 3. Some of the prominent examples of languages with which we embed SQL are: C++, Java, Python, etc. 4. Embedded SQL gives us the freedom to use databases as and when required. 5. Once the application we develop goes into the production mode several things need to be taken care of. 6. With the help of the embedding of queries, we can easily use the database without creating any bulky code. 7. With the embedded SQL, we can also create API’s which can easily fetch and feed data whenever required.
  • 5. How to Embed SQL in High-Level Languages? 1. For using embedded SQL, we need some tools in each high-level language. 2. In some cases, we have inbuilt libraries which provide us with the basic building block. 3. While in some cases we need to import or use some packages to perform the desired tasks. 4. For example: Class.forName( “com.mysql.jdbc.Driver“ ); Connection connection = DriverManager.getConnection( "jdbc:mysql://localhost:3306/DataFlair","user","root“ ); Statement statement = connection.createStatement();
  • 6. ADVANTAGES OF EMBEDDED SQL 1. Helps to access databases from anywhere. 2. Allows integrating authentication service for large scale applications. 3. Provides extra security to database transactions. 4. Avoids logical errors while performing transactions on our database. 5. Makes it easy to integrate the frontend and the backend of our application.
  • 8. What is Dynamic SQL? 1. Dynamic SQL is the process for programming SQL queries that are built dynamically with the application operations. 2. Manage big industrial applications and manage the transactions without overhead. 3. We are free to create flexible SQL queries and the names of the variables or any other parameters are passed when the application runs. 4. We can use stored procedures to create dynamic queries which can run when we desire. 5. We use the exec keyword. 6. When we use static SQL it is not altered from one execution to others, but in the case of dynamic SQL, we can alter the query in each execution. 7. We should always prefer using static SQL over dynamic SQL for the following benefits of the static SQL: • If a query compiles successfully it implies that the syntax is correct. • If a query compiles successfully it verifies that all the permissions and validations are correct. • As all the data is pre-known in static SQL the overhead charges are reduced considerably.
  • 9. When to Use Dynamic SQL? 1. When static SQL does not support. 2. When exact SQL statements are not known. 3. When we want to execute • DDL: CREATE, DROP, GRANT, REVOKE • DML: INSERT, UPDATE, DELETE • SCL: ALTER SESSION and SET ROLE
  • 11. What is Functional Dependency? 1. A functional dependency is a constraint that specifies the relationship between two sets of attributes where one set can accurately determine the value of other sets. 2. It is denoted as X → Y, where X is a set of attributes that is capable of determining the value of Y. 3. X is called Determinant, and Y is called the Dependent. 4. Used to mathematically express relations among database entities.
  • 12. Example • roll_no → { name, dept_name, dept_building } • roll_no → dept_name • dept_name → dept_building
  • 13. Armstrong’s axioms/properties of Functional Dependencies • Reflexivity: If Y is a subset of X, then X→Y For example, {roll_no, name} → name is valid. • Augmentation: If X → Y is a valid dependency, then XZ → YZ For example, If {roll_no, name} → dept_building is valid, then {roll_no, name, dept_name} → {dept_building, dept_name} is also valid. • Transitivity: If X → Y and Y → Z are both valid dependencies, then X→Z. For example, roll_no → dept_name & dept_name → dept_building, then roll_no → dept_building is also valid.
  • 14. Types of Functional dependencies in DBMS • Trivial functional dependency • Non-Trivial functional dependency • Multivalued functional dependency • Transitive functional dependency
  • 15. • A dependent is always a subset of the determinant. i.e. If X → Y and Y is the subset of X Trivial functional dependency Non-trivial functional dependency • A dependent is strictly not a subset of the determinant. i.e. If X → Y and Y is not a subset of X
  • 16. • Entities of the dependent set are not dependent on each other. i.e. If a → {b, c} and there exists no functional dependency between b and c. • For example, Multivalued functional dependency Here, roll_no → {name, age} is a Multivalued functional dependency, since the dependents name & age are not dependent on each other (i.e. name → age or age → name doesn’t exist)
  • 17. • A dependent is indirectly dependent on determinant, i.e. If a → b & b → c, then according to axiom of transitivity, a → c • For example, Transitive functional dependency Here, enrol_no → dept and dept → building_no. Hence, according to the axiom of transitivity, enrol_no → building_no is a valid functional dependency. This is an indirect functional dependency, hence called Transitive functional dependency.
  • 19. What is Decomposition? 1. When a relation is not in appropriate normal form then the decomposition of a relation is required. 2. It breaks the table into multiple tables. 3. If the relation has no proper decomposition, then it may lead to loss of information. 4. Eliminate some of the problems like anomalies, inconsistencies, and redundancy.
  • 20. Types of Decomposition 1. Dependency Preserving Decomposition 2. Lossless Decomposition
  • 21. Dependency Preserving Decomposition 1. At least one decomposed table must satisfy every dependency. 2. If a relation R is decomposed into relation R1 and R2, then the dependencies of R must be a part of R1 or R2 or must be derivable from the combination of functional dependencies of R1 and R2. 3. That means, F1∪F2 ≡ F
  • 22. Lossless Decomposition 1. If the information is not lost from the relation that is decomposed, then the decomposition will be lossless. 2. The lossless decomposition guarantees that the join of relations will result in the same relation as it was decomposed. 3. The relation is said to be lossless decomposition if natural joins of all the decomposition give the original relation.