SlideShare a Scribd company logo
1 of 23
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

Sql queries presentation
Sql queries presentationSql queries presentation
Sql queries presentationNITISH KUMAR
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database DesignArchit Saxena
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands1keydata
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functionsfarwa waqar
 
PostgreSQL Tutorial For Beginners | Edureka
PostgreSQL Tutorial For Beginners | EdurekaPostgreSQL Tutorial For Beginners | Edureka
PostgreSQL Tutorial For Beginners | EdurekaEdureka!
 
Oracle backup and recovery
Oracle backup and recoveryOracle backup and recovery
Oracle backup and recoveryYogiji Creations
 
Query optimization
Query optimizationQuery optimization
Query optimizationPooja Dixit
 
SQL Queries
SQL QueriesSQL Queries
SQL QueriesNilt1234
 
Oracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creationsOracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creationsYogiji Creations
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQLRam Kedem
 
PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts Bharat Kalia
 
Transaction management and concurrency control
Transaction management and concurrency controlTransaction management and concurrency control
Transaction management and concurrency controlDhani Ahmad
 
Bootcamp sql fundamental
Bootcamp sql fundamentalBootcamp sql fundamental
Bootcamp sql fundamentalvarunbhatt23
 

What's hot (20)

Sql queries presentation
Sql queries presentationSql queries presentation
Sql queries presentation
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database Design
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
Advanced sql
Advanced sqlAdvanced sql
Advanced sql
 
PostgreSQL Tutorial For Beginners | Edureka
PostgreSQL Tutorial For Beginners | EdurekaPostgreSQL Tutorial For Beginners | Edureka
PostgreSQL Tutorial For Beginners | Edureka
 
Data independence
Data independenceData independence
Data independence
 
Oracle backup and recovery
Oracle backup and recoveryOracle backup and recovery
Oracle backup and recovery
 
SQL Functions
SQL FunctionsSQL Functions
SQL Functions
 
Query optimization
Query optimizationQuery optimization
Query optimization
 
SQL Queries
SQL QueriesSQL Queries
SQL Queries
 
Sql commands
Sql commandsSql commands
Sql commands
 
MS-SQL SERVER ARCHITECTURE
MS-SQL SERVER ARCHITECTUREMS-SQL SERVER ARCHITECTURE
MS-SQL SERVER ARCHITECTURE
 
Oracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creationsOracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creations
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
Transaction management and concurrency control
Transaction management and concurrency controlTransaction management and concurrency control
Transaction management and concurrency control
 
Oracle
OracleOracle
Oracle
 
Bootcamp sql fundamental
Bootcamp sql fundamentalBootcamp sql fundamental
Bootcamp sql fundamental
 

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 .pdfNiravPanchal50
 
SQL EXCLUSIVE NOTES .pdf
SQL EXCLUSIVE NOTES .pdfSQL EXCLUSIVE NOTES .pdf
SQL EXCLUSIVE NOTES .pdfNiravPanchal50
 
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 6kaashiv1
 
Sql interview-question-part-6
Sql interview-question-part-6Sql interview-question-part-6
Sql interview-question-part-6kaashiv1
 
Sql interview-question-part-6
Sql interview-question-part-6Sql interview-question-part-6
Sql interview-question-part-6kaashiv1
 
Kaashiv SQL Server Interview Questions Presentation
Kaashiv SQL Server Interview Questions PresentationKaashiv SQL Server Interview Questions Presentation
Kaashiv SQL Server Interview Questions Presentationkaashiv1
 
Dbms important questions and answers
Dbms important questions and answersDbms important questions and answers
Dbms important questions and answersLakshmiSarvani6
 
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
 
Sql interview question part 12
Sql interview question part 12Sql interview question part 12
Sql interview question part 12kaashiv1
 
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 nodesUlf Wendel
 
SQL vs MongoDB
SQL vs MongoDBSQL vs MongoDB
SQL vs MongoDBcalltutors
 
Sql server-dba
Sql server-dbaSql server-dba
Sql server-dbaNaviSoft
 

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
 
Sql interview-question-part-6
Sql interview-question-part-6Sql interview-question-part-6
Sql interview-question-part-6
 
Ebook6
Ebook6Ebook6
Ebook6
 
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
CybersecuritySabiha M
 
Top-Down Estimation Approach
Top-Down Estimation ApproachTop-Down Estimation Approach
Top-Down Estimation ApproachSabiha M
 
Kernel Computing
Kernel ComputingKernel Computing
Kernel ComputingSabiha M
 
Goal-Setting Theory of Motivation
Goal-Setting Theory of MotivationGoal-Setting Theory of Motivation
Goal-Setting Theory of MotivationSabiha M
 
Decomposition
DecompositionDecomposition
DecompositionSabiha M
 
Job Sequencing with Deadlines
Job Sequencing with DeadlinesJob Sequencing with Deadlines
Job Sequencing with DeadlinesSabiha M
 
LAN, WAN, MAN
LAN, WAN, MANLAN, WAN, MAN
LAN, WAN, MANSabiha M
 
Next Generation Internet
Next Generation InternetNext Generation Internet
Next Generation InternetSabiha M
 
Near Field Communication
Near Field CommunicationNear Field Communication
Near Field CommunicationSabiha M
 
Green Cloud Computing
Green Cloud ComputingGreen Cloud Computing
Green Cloud ComputingSabiha M
 
Remote Method Invocation
Remote Method InvocationRemote Method Invocation
Remote Method InvocationSabiha M
 
Apache web server
Apache web serverApache web server
Apache web serverSabiha M
 
Types of parsers
Types of parsersTypes of parsers
Types of parsersSabiha 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

ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 

Recently uploaded (20)

TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 

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.