SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
SQL’99 and some techniques
      of data mining


       Kiselyov Alexey
Plan
● Place of data mining methods in MVC model
● Data mining alternatives
   ○ Benefits and restrictions
● Focus on SQL
   ○ Some "innovations" SQL99
   ○ examples
MVC




passive                       active




          Trygve Reenskaug (1979)
Methods to obtaining data
 ● DB native API & native SQL
 ● SQL
    ○ SQL92
    ○ SQL99
    ○ SQL2003
    ○ SQL2008
 ● Object-relational mapping (ORM)
DB native API & native SQL

        Benefits                      Losses
● Quick                   ● Specificity
● Fine request tuning     ● difficulty or inability to
● Compact data transfer     transfer to another DB
ORM layer

          Benefits                       Losses
● Simple work with entities   ● Misunderstanding data
● Misunderstanding data         extracting processes
  extracting processes        ● Can't be used for
● Portability between any       recursive data
  DB (RDBMS and noSQL           connections
  DBMS)
SQL

           Benefits                       Losses
● Portability between other      ● No portability to noSQL
  RDBMS                            DBMS
● Data extracting processes
  is a clear
● All thirteen from twelve
  Codd's rules are rules!!! :)
"Innovations" in examples
  from simple to complex
    and again to simple
just "SELECT" them!!!
      ...but not only!
Client (C): Please, give me all products from my storage where
price greater then $100...
Programmer (P): it's easy!!!
> SELECT title, price FROM products WHERE price > 100




                      All are happy!!!
C: Please, give me all products from my storage where price
greater then $100 and corresponds to "tools" category
P: (ha! it's easy too!!!)
> SELECT p.title, p.price
FROM products p INNER JOIN category c ON p.categoryId = c.id
WHERE price > 100 and c.title = 'tool'




                      All are happy!!!
C: Great! And now, please, give me all products from my
storage where price greater then $100 and corresponds to
"tools" category and I want to get all product with price greater
then $100 that delivered from China!
P: it's easy too... (but)
> SELECT p.title, p.price
FROM products p INNER JOIN category c ON p.categoryId = c.id
WHERE price > 100 and c.title = 'tool'
UNION ALL
SELECT p.title, p.price
FROM products p INNER JOIN countries cs ON p.deliveryId = cs.id
WHERE price > 100 and cs.title = 'China'




               ĐĄustomer is happy... maybe
C: Please, give me all products from my storage where price
greater then $100 and corresponds to "tools" category, and I
want to get all product with price greater then $100 that
delivered from China! And I want to exclude from previous
collection products with price greater than $150 from China
produced before 01.01.2000.
P: mmmm.... mama... :-(
> SELECT x.title, x.price FROM
(
  SELECT p.title, p.price, p.produceDate, cs.title
  FROM
   products p INNER JOIN category c ON p.categoryId = c.id
     LEFT JOIN countries cs ON p.deliveryId = cs.id
  WHERE price > 100 and c.title = 'tool'
UNION DISTINCT
  SELECT p.title, p.price, p.produceDate, cs.title
  FROM products p INNER JOIN countries cs ON p.deliveryId = cs.id
  WHERE price > 100 and cs.title = 'China') x
) AS x
WHERE !(x.price > 150 and x.produceDate > '01.01.2000' and x.title = 'China')
WITH
p100 as (
 SELECT deliveryId, title, price, produceDate FROM products p WHERE price
> 100)
SELECT
 title, price
FROM p100 INNER JOIN category c ON p100.categoryId = c.id
WHERE c.title = 'tool'
UNION DISTINCT
SELECT
 title, price
FROM p100 INNER JOIN countries cs ON p100.deliveryId = cs.id
WHERE
 cs.title = 'China'
 and (p100.price > 150 and p100.produceDate > '01.01.2000')
What more?

RECURSIVE QUERY
Simple hierarchy
                   ID                  PARENT_ID                    CONTENT
                   1                         R                         State
                   2                         1                         City 1
                   3                         1                         City 2
                   4                         2                     ĐĄity block 41
                   5                         4                      Street 541
                   6                         4                      Street 641
             ...        ...                                  ...


  CREATE TABLE T2 (id VARCHAR(50), parent_id VARCHAR(20), content VARCHAR(20));

  INSERT INTO T2 VALUES ('1', 'R', 'State');
  INSERT INTO T2 VALUES ('2', '1', 'City 1');
  INSERT INTO T2 VALUES ('3', '1', 'City 2');
  INSERT INTO T2 VALUES ('4', '2', 'ĐĄity block 41');
  INSERT INTO T2 VALUES ('5', '4', 'Street 541');
  INSERT INTO T2 VALUES ('6', '4', 'Street 641');
DB2, MS SQL

WITH TEMP(ID, PARENT_ID) AS
(
  SELECT ID, PARENT_ID FROM T2 WHERE ID = '6'
  UNION ALL
  SELECT T2.ID, T2.PARENT_ID FROM TEMP, T2
  WHERE TEMP.PARENT_ID = T2.ID
)
SELECT * FROM TEMP
Oracle

SELECT child FROM T2 WHERE id = '6'
START WITH id = 'R' CONNECT BY PRIOR parent_id = id;


Display the full tree (indenting child items)

SELECT child FROM T2
START WITH id = 'R' CONNECT BY PRIOR parent_id = id;
MySQL
Infinitive loop
DB2

WITH list(k, leaf, path) AS
(
 SELECT DISTINCT 1, id, parent_id||', '||id FROM T2 WHERE parent_id = 'R'
 UNION ALL
 SELECT k + 1, id, path || ', ' || id FROM list AS tt, T2 AS subroot
 WHERE
  k < 5 AND tt.leaf = subroot.parent_id AND LOCATE(subroot.id, tt.path) = 0
)
SELECT path FROM list;

R, 1
R, 1, 2
R, 1, 3
R, 1, 2, 4
R, 1, 2, 4, 5
R, 1, 2, 4, 6
Oracle

1. How to exclude cycle
SELECT child FROM T2 START WITH id IS NULL CONNECT
BY NOCYCLE PRIOR parent_id = id;



2. How to restrict amount of hierarchy level

SELECT child FROM T2 START WITH id IS NULL CONNECT
BY PRIOR parent_id = id AND LEVEL < 5;
Useful recursive SQL

WITH ALL_DAYS(DT) AS
 (
   VALUES (DATE('2011-10-01'))
    UNION ALL
   SELECT DT + 1 DAY FROM ALL_DAYS
   WHERE DT < '2012-01-01'
 )
SELECT DT FROM ALL_DAYS;
I think it enough

Thank you for attention!!!

Weitere Àhnliche Inhalte

Andere mochten auch

Scalable Realtime Analytics with declarative SQL like Complex Event Processin...
Scalable Realtime Analytics with declarative SQL like Complex Event Processin...Scalable Realtime Analytics with declarative SQL like Complex Event Processin...
Scalable Realtime Analytics with declarative SQL like Complex Event Processin...Srinath Perera
 
Oracle SQL Developer Tips & Tricks
Oracle SQL Developer Tips & TricksOracle SQL Developer Tips & Tricks
Oracle SQL Developer Tips & TricksJeff Smith
 
Best sql plsql material
Best sql plsql materialBest sql plsql material
Best sql plsql materialpitchaiah yechuri
 
A must Sql notes for beginners
A must Sql notes for beginnersA must Sql notes for beginners
A must Sql notes for beginnersRam Sagar Mourya
 
Ten query tuning techniques every SQL Server programmer should know
Ten query tuning techniques every SQL Server programmer should knowTen query tuning techniques every SQL Server programmer should know
Ten query tuning techniques every SQL Server programmer should knowKevin Kline
 
Sql queries with answers
Sql queries with answersSql queries with answers
Sql queries with answersvijaybusu
 

Andere mochten auch (8)

Scalable Realtime Analytics with declarative SQL like Complex Event Processin...
Scalable Realtime Analytics with declarative SQL like Complex Event Processin...Scalable Realtime Analytics with declarative SQL like Complex Event Processin...
Scalable Realtime Analytics with declarative SQL like Complex Event Processin...
 
Plsql programs(encrypted)
Plsql programs(encrypted)Plsql programs(encrypted)
Plsql programs(encrypted)
 
Oracle SQL Developer Tips & Tricks
Oracle SQL Developer Tips & TricksOracle SQL Developer Tips & Tricks
Oracle SQL Developer Tips & Tricks
 
Sql queires
Sql queiresSql queires
Sql queires
 
Best sql plsql material
Best sql plsql materialBest sql plsql material
Best sql plsql material
 
A must Sql notes for beginners
A must Sql notes for beginnersA must Sql notes for beginners
A must Sql notes for beginners
 
Ten query tuning techniques every SQL Server programmer should know
Ten query tuning techniques every SQL Server programmer should knowTen query tuning techniques every SQL Server programmer should know
Ten query tuning techniques every SQL Server programmer should know
 
Sql queries with answers
Sql queries with answersSql queries with answers
Sql queries with answers
 

Ähnlich wie Sql 99 and_some_techniques

[Www.pkbulk.blogspot.com]dbms05
[Www.pkbulk.blogspot.com]dbms05[Www.pkbulk.blogspot.com]dbms05
[Www.pkbulk.blogspot.com]dbms05AnusAhmad
 
CS 542 Database Index Structures
CS 542 Database Index StructuresCS 542 Database Index Structures
CS 542 Database Index StructuresJ Singh
 
PDBC
PDBCPDBC
PDBCSunil OS
 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries InformationNishant Munjal
 
Data Wars: The Bloody Enterprise strikes back
Data Wars: The Bloody Enterprise strikes backData Wars: The Bloody Enterprise strikes back
Data Wars: The Bloody Enterprise strikes backVictor_Cr
 
c#(loops,arrays)
c#(loops,arrays)c#(loops,arrays)
c#(loops,arrays)sdrhr
 
UKOUG Tech14 - Getting Started With JSON in the Database
UKOUG Tech14 - Getting Started With JSON in the DatabaseUKOUG Tech14 - Getting Started With JSON in the Database
UKOUG Tech14 - Getting Started With JSON in the DatabaseMarco Gralike
 
OakTable World 2015 - Using XMLType content with the Oracle In-Memory Column...
OakTable World 2015  - Using XMLType content with the Oracle In-Memory Column...OakTable World 2015  - Using XMLType content with the Oracle In-Memory Column...
OakTable World 2015 - Using XMLType content with the Oracle In-Memory Column...Marco Gralike
 
TDC2016SP - Trilha Frameworks JavaScript
TDC2016SP - Trilha Frameworks JavaScriptTDC2016SP - Trilha Frameworks JavaScript
TDC2016SP - Trilha Frameworks JavaScripttdc-globalcode
 
Mysql rab2-student
Mysql rab2-studentMysql rab2-student
Mysql rab2-studentsantosh mishra
 
Mysql rab2-student
Mysql rab2-studentMysql rab2-student
Mysql rab2-studentsantosh mishra
 
Agile Database Development with JSON
Agile Database Development with JSONAgile Database Development with JSON
Agile Database Development with JSONChris Saxon
 
ABAP Programming Overview
ABAP Programming OverviewABAP Programming Overview
ABAP Programming Overviewsapdocs. info
 
Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02wingsrai
 
Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01tabish
 
chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01tabish
 

Ähnlich wie Sql 99 and_some_techniques (20)

[Www.pkbulk.blogspot.com]dbms05
[Www.pkbulk.blogspot.com]dbms05[Www.pkbulk.blogspot.com]dbms05
[Www.pkbulk.blogspot.com]dbms05
 
CS 542 Database Index Structures
CS 542 Database Index StructuresCS 542 Database Index Structures
CS 542 Database Index Structures
 
PDBC
PDBCPDBC
PDBC
 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries Information
 
Data Wars: The Bloody Enterprise strikes back
Data Wars: The Bloody Enterprise strikes backData Wars: The Bloody Enterprise strikes back
Data Wars: The Bloody Enterprise strikes back
 
c#(loops,arrays)
c#(loops,arrays)c#(loops,arrays)
c#(loops,arrays)
 
UKOUG Tech14 - Getting Started With JSON in the Database
UKOUG Tech14 - Getting Started With JSON in the DatabaseUKOUG Tech14 - Getting Started With JSON in the Database
UKOUG Tech14 - Getting Started With JSON in the Database
 
OakTable World 2015 - Using XMLType content with the Oracle In-Memory Column...
OakTable World 2015  - Using XMLType content with the Oracle In-Memory Column...OakTable World 2015  - Using XMLType content with the Oracle In-Memory Column...
OakTable World 2015 - Using XMLType content with the Oracle In-Memory Column...
 
TDC2016SP - Trilha Frameworks JavaScript
TDC2016SP - Trilha Frameworks JavaScriptTDC2016SP - Trilha Frameworks JavaScript
TDC2016SP - Trilha Frameworks JavaScript
 
React for Beginners
React for BeginnersReact for Beginners
React for Beginners
 
Rdbms day3
Rdbms day3Rdbms day3
Rdbms day3
 
Mysql rab2-student
Mysql rab2-studentMysql rab2-student
Mysql rab2-student
 
Mysql rab2-student
Mysql rab2-studentMysql rab2-student
Mysql rab2-student
 
SQL
SQLSQL
SQL
 
SQL Windowing
SQL WindowingSQL Windowing
SQL Windowing
 
Agile Database Development with JSON
Agile Database Development with JSONAgile Database Development with JSON
Agile Database Development with JSON
 
ABAP Programming Overview
ABAP Programming OverviewABAP Programming Overview
ABAP Programming Overview
 
Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02
 
Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01
 
chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01
 

KĂŒrzlich hochgeladen

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍾 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍾 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍾 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍾 8923113531 🎰 Avail...gurkirankumar98700
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 

KĂŒrzlich hochgeladen (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍾 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍾 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍾 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍾 8923113531 🎰 Avail...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

Sql 99 and_some_techniques

  • 1. SQL’99 and some techniques of data mining Kiselyov Alexey
  • 2. Plan ● Place of data mining methods in MVC model ● Data mining alternatives ○ Benefits and restrictions ● Focus on SQL ○ Some "innovations" SQL99 ○ examples
  • 3. MVC passive active Trygve Reenskaug (1979)
  • 4. Methods to obtaining data ● DB native API & native SQL ● SQL ○ SQL92 ○ SQL99 ○ SQL2003 ○ SQL2008 ● Object-relational mapping (ORM)
  • 5. DB native API & native SQL Benefits Losses ● Quick ● Specificity ● Fine request tuning ● difficulty or inability to ● Compact data transfer transfer to another DB
  • 6. ORM layer Benefits Losses ● Simple work with entities ● Misunderstanding data ● Misunderstanding data extracting processes extracting processes ● Can't be used for ● Portability between any recursive data DB (RDBMS and noSQL connections DBMS)
  • 7. SQL Benefits Losses ● Portability between other ● No portability to noSQL RDBMS DBMS ● Data extracting processes is a clear ● All thirteen from twelve Codd's rules are rules!!! :)
  • 8. "Innovations" in examples from simple to complex and again to simple
  • 9. just "SELECT" them!!! ...but not only!
  • 10. Client (C): Please, give me all products from my storage where price greater then $100... Programmer (P): it's easy!!! > SELECT title, price FROM products WHERE price > 100 All are happy!!!
  • 11. C: Please, give me all products from my storage where price greater then $100 and corresponds to "tools" category P: (ha! it's easy too!!!) > SELECT p.title, p.price FROM products p INNER JOIN category c ON p.categoryId = c.id WHERE price > 100 and c.title = 'tool' All are happy!!!
  • 12. C: Great! And now, please, give me all products from my storage where price greater then $100 and corresponds to "tools" category and I want to get all product with price greater then $100 that delivered from China! P: it's easy too... (but) > SELECT p.title, p.price FROM products p INNER JOIN category c ON p.categoryId = c.id WHERE price > 100 and c.title = 'tool' UNION ALL SELECT p.title, p.price FROM products p INNER JOIN countries cs ON p.deliveryId = cs.id WHERE price > 100 and cs.title = 'China' ĐĄustomer is happy... maybe
  • 13. C: Please, give me all products from my storage where price greater then $100 and corresponds to "tools" category, and I want to get all product with price greater then $100 that delivered from China! And I want to exclude from previous collection products with price greater than $150 from China produced before 01.01.2000. P: mmmm.... mama... :-( > SELECT x.title, x.price FROM ( SELECT p.title, p.price, p.produceDate, cs.title FROM products p INNER JOIN category c ON p.categoryId = c.id LEFT JOIN countries cs ON p.deliveryId = cs.id WHERE price > 100 and c.title = 'tool' UNION DISTINCT SELECT p.title, p.price, p.produceDate, cs.title FROM products p INNER JOIN countries cs ON p.deliveryId = cs.id WHERE price > 100 and cs.title = 'China') x ) AS x WHERE !(x.price > 150 and x.produceDate > '01.01.2000' and x.title = 'China')
  • 14. WITH p100 as ( SELECT deliveryId, title, price, produceDate FROM products p WHERE price > 100) SELECT title, price FROM p100 INNER JOIN category c ON p100.categoryId = c.id WHERE c.title = 'tool' UNION DISTINCT SELECT title, price FROM p100 INNER JOIN countries cs ON p100.deliveryId = cs.id WHERE cs.title = 'China' and (p100.price > 150 and p100.produceDate > '01.01.2000')
  • 16. Simple hierarchy ID PARENT_ID CONTENT 1 R State 2 1 City 1 3 1 City 2 4 2 ĐĄity block 41 5 4 Street 541 6 4 Street 641 ... ... ... CREATE TABLE T2 (id VARCHAR(50), parent_id VARCHAR(20), content VARCHAR(20)); INSERT INTO T2 VALUES ('1', 'R', 'State'); INSERT INTO T2 VALUES ('2', '1', 'City 1'); INSERT INTO T2 VALUES ('3', '1', 'City 2'); INSERT INTO T2 VALUES ('4', '2', 'ĐĄity block 41'); INSERT INTO T2 VALUES ('5', '4', 'Street 541'); INSERT INTO T2 VALUES ('6', '4', 'Street 641');
  • 17. DB2, MS SQL WITH TEMP(ID, PARENT_ID) AS ( SELECT ID, PARENT_ID FROM T2 WHERE ID = '6' UNION ALL SELECT T2.ID, T2.PARENT_ID FROM TEMP, T2 WHERE TEMP.PARENT_ID = T2.ID ) SELECT * FROM TEMP
  • 18. Oracle SELECT child FROM T2 WHERE id = '6' START WITH id = 'R' CONNECT BY PRIOR parent_id = id; Display the full tree (indenting child items) SELECT child FROM T2 START WITH id = 'R' CONNECT BY PRIOR parent_id = id;
  • 19. MySQL
  • 21. DB2 WITH list(k, leaf, path) AS ( SELECT DISTINCT 1, id, parent_id||', '||id FROM T2 WHERE parent_id = 'R' UNION ALL SELECT k + 1, id, path || ', ' || id FROM list AS tt, T2 AS subroot WHERE k < 5 AND tt.leaf = subroot.parent_id AND LOCATE(subroot.id, tt.path) = 0 ) SELECT path FROM list; R, 1 R, 1, 2 R, 1, 3 R, 1, 2, 4 R, 1, 2, 4, 5 R, 1, 2, 4, 6
  • 22. Oracle 1. How to exclude cycle SELECT child FROM T2 START WITH id IS NULL CONNECT BY NOCYCLE PRIOR parent_id = id; 2. How to restrict amount of hierarchy level SELECT child FROM T2 START WITH id IS NULL CONNECT BY PRIOR parent_id = id AND LEVEL < 5;
  • 23. Useful recursive SQL WITH ALL_DAYS(DT) AS ( VALUES (DATE('2011-10-01')) UNION ALL SELECT DT + 1 DAY FROM ALL_DAYS WHERE DT < '2012-01-01' ) SELECT DT FROM ALL_DAYS;
  • 24. I think it enough Thank you for attention!!!