More Than a Query Language: SQL in the 21st Century
@MarkusWinand • @ModernSQL
http://www.almaden.ibm.com/cs/people/chamberlin/sequel-1974.pdf
More Than a Query Language: SQL in the 21 st Century @MarkusWinand - - PowerPoint PPT Presentation
More Than a Query Language: SQL in the 21 st Century @MarkusWinand @ModernSQL http://www.almaden.ibm.com/cs/people/chamberlin/sequel-1974.pdf 1974 1992 SQL-92 Tied to the Relational Idea SQL-92 Tied to the Relational Idea
http://www.almaden.ibm.com/cs/people/chamberlin/sequel-1974.pdf
Relational Data Model
Relational Data Model
Atom image: https://commons.wikimedia.org/wiki/File:Stylised_atom_with_three_Bohr_model_orbits_and_stylised_nucleus.png
Relational Data Model
A B C
Atom image: https://commons.wikimedia.org/wiki/File:Stylised_atom_with_three_Bohr_model_orbits_and_stylised_nucleus.png
Relational Data Model
A B C
Relational Data Model
processing purposes
A B C
Relational Data Model
processing purposes
A B C C D B E
Relational Data Model
processing purposes
Relational Operations
each particular processing purposes
A B C C D B E A B C D E
Relational Data Model
processing purposes
Relational Operations
each particular processing purposes
A B C C D B E
A B C D E
A B E
Relational Data Model
processing purposes
Relational Operations
each particular processing purposes
A B C C D B E
A B C D E A B E
C D E
Relational Data Model
processing purposes
Relational Operations
each particular processing purposes
A B C C D B E
A B C D E A B E C D E
https://www.wiscorp.com/DBMS_-_GreatNews-TheRelationalModelIsDead_-_paper_-_sam.pdf
To say that these SQL:1999 extensions are mere “extended interpretations” of the relational data model is like saying that an intercontinental ballistic missile is merely an “extended interpretation” of a spear.
https://www.wiscorp.com/DBMS_-_GreatNews-TheRelationalModelIsDead_-_paper_-_sam.pdf
To say that these SQL:1999 extensions are mere “extended interpretations” of the relational data model is like saying that an intercontinental ballistic missile is merely an “extended interpretation” of a spear. With SQL/99 you can get the best of both worlds and
It’s up to the database practitioners to do the right thing.
https://www.wiscorp.com/DBMS_-_GreatNews-TheRelationalModelIsDead_-_paper_-_sam.pdf
Relational Model?
Relational Model?
Chris Date
Date on Database: Writings 2000-2006
Relational Model?
Chris Date
Date on Database: Writings 2000-2006
Relational Model?
Chris Date
Date on Database: Writings 2000-2006
Relational Model?
Chris Date
Date on Database: Writings 2000-2006
Relational Model?
Chris Date
Date on Database: Writings 2000-2006
Relational Model?
Chris Date
Date on Database: Writings 2000-2006
A
Relational Model?
Chris Date
Date on Database: Writings 2000-2006
A B
Relational Model?
Chris Date
Date on Database: Writings 2000-2006
A B
C
C D C D C D
Relational Model?
Chris Date
Date on Database: Writings 2000-2006
A B C D
{x: , y: }
{x: , y: }
{x: , y: }
C D C D C D
Relational Model?
Non-Relational Operations
queries that process their own output
Chris Date
Date on Database: Writings 2000-2006
CREATE TABLE t ( id INTEGER, parent INTEGER, )
CREATE TABLE t ( id INTEGER, parent INTEGER, )
CREATE TABLE t ( id INTEGER, parent INTEGER, )
1999 2001 2003 2005 2007 2009 2011 2013 2015 2017
5.1 10.2
8.0 MySQL 8.4
1.0 3.8.3
7.0
11gR2
2005
http://www.acm.org:80/sigmod/record/issues/0206/standard.pdf (via Wayback machine)
Schemaless
documents in a single column
Schemaless
documents in a single column
Later:
Analytical
window functions
Schemaless
documents in a single column
Later:
Analytical
window functions
Schemaless
documents in a single column
Later:
Cockroach DB, VoltDB
Later:
id 1 2 3 4 5 6 value +10 +20
+50
id 1 2 3 4 5 6 value +10 +20
+50
bal
id 1 2 3 4 5 6 value +10 +20
+50
bal
+10
id 1 2 3 4 5 6 value +10 +20
+50
bal
+10 +30 +20 +70 +40 +20
id 1 2 3 4 5 6 value +10 +20
+50
bal
+10 +30 +20 +70 +40 +20
id 1 2 3 4 5 6 value +10 +20
+50
bal
+10 +30 +20 +70 +40 +20
id 1 2 3 4 5 6 value +10 +20
+50
bal
+10 +30 +20 +70 +40 +20
id 1 2 3 4 5 6 value +10 +20
+50
bal
+10 +30 +20 +70 +40 +20
id 1 2 3 4 5 6 value +10 +20
+50
bal
+10 +30 +20 +70 +40 +20
id 1 2 3 4 5 6 value +10 +20
+50
bal
+10 +30 +20 +70 +40 +20
id 1 2 3 4 5 6 value +10 +20
+50
bal
+10 +30 +20 +70 +40 +20
id 1 2 3 4 5 6 value +10 +20
+50
bal
+10 +30 +20 +70 +40 +20
id value bal 1 +10 2 +20 3
4 +50 5
6
+10 +30 +20 +70 +40 +20
id value bal 1 +10 2 +20 3
4 +50 5
6
+10 +30 +20 +70 +40 +20
id value bal 1 +10 2 +20 3
4 +50 5
6
+10 +30 +20 +70 +40 +20
id value bal 1 +10 2 +20 3
4 +50 5
6
+10 +30 +20 +70 +40 +20
id value bal 1 +10 2 +20 3
4 +50 5
6
+10 +30 +20 +70 +40 +20
1999 2001 2003 2005 2007 2009 2011 2013 2015 2017
5.1 10.2
8.0 MySQL 8.4
1.0 3.25.0
7.0
8i
2005[0] 2012
[0]Without framing
1999 2001 2003 2005 2007 2009 2011 2013 2015 2017
5.1 10.2
8.0 MySQL 8.4
1.0 3.25.0
7.0
8i
2005[0] 2012
[0]Without framing
Impala Spark NuoDB BigQuery Hive
SELECT d1.val FROM data d1 JOIN data d2 ON (d1.val < d2.val OR (d1.val=d2.val AND d1.id<d2.id)) GROUP BY d1.val HAVING count(*) = (SELECT FLOOR(COUNT(*)/2) FROM data d3)
SELECT d1.val FROM data d1 JOIN data d2 ON (d1.val < d2.val OR (d1.val=d2.val AND d1.id<d2.id)) GROUP BY d1.val HAVING count(*) = (SELECT FLOOR(COUNT(*)/2) FROM data d3)
Number rows
SELECT d1.val FROM data d1 JOIN data d2 ON (d1.val < d2.val OR (d1.val=d2.val AND d1.id<d2.id)) GROUP BY d1.val HAVING count(*) = (SELECT FLOOR(COUNT(*)/2) FROM data d3)
Number rows Pick middle one
SELECT d1.val FROM data d1 JOIN data d2 ON (d1.val < d2.val OR (d1.val=d2.val AND d1.id<d2.id)) GROUP BY d1.val HAVING count(*) = (SELECT FLOOR(COUNT(*)/2) FROM data d3)
Number rows Pick middle one
SELECT d1.val FROM data d1 JOIN data d2 ON (d1.val < d2.val OR (d1.val=d2.val AND d1.id<d2.id)) GROUP BY d1.val HAVING count(*) = (SELECT FLOOR(COUNT(*)/2) FROM data d3)
Number rows Pick middle one
SELECT d1.val FROM data d1 JOIN data d2 ON (d1.val < d2.val OR (d1.val=d2.val AND d1.id<d2.id)) GROUP BY d1.val HAVING count(*) = (SELECT FLOOR(COUNT(*)/2) FROM data d3)
Number rows Pick middle one
All employees must
after using
SELECT d1.val FROM data d1 JOIN data d2 ON (d1.val < d2.val OR (d1.val=d2.val AND d1.id<d2.id)) GROUP BY d1.val HAVING count(*) = (SELECT FLOOR(COUNT(*)/2) FROM data d3)
Number rows Pick middle one
All employees must
after using
SELECT PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY val) FROM data
SELECT PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY val) FROM data
SELECT PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY val) FROM data
SELECT PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY val) FROM data
SELECT PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY val) FROM data
Two variants:
(categories)
(linear interpolation)
1 2 3 4
0.25 0.5 0.75 1
1 2 3 4
SELECT PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY val) FROM data
Two variants:
(categories)
(linear interpolation)
1 2 3 4
0.25 0.5 0.75 1
1 2 3 4
0.25 0.5 0.75 1
1 2 3 4 PERCENTILE_DISC
SELECT PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY val) FROM data
Two variants:
(categories)
(linear interpolation)
1 2 3 4
0.25 0.5 0.75 1
1 2 3 4
0.25 0.5 0.75 1
1 2 3 4 PERCENTILE_DISC
0.25 0.5 0.75 1
1 2 3 4 PERCENTILE_DISC
SELECT PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY val) FROM data
Two variants:
(categories)
(linear interpolation)
1 2 3 4
0.25 0.5 0.75 1
1 2 3 4
0.25 0.5 0.75 1
1 2 3 4 PERCENTILE_DISC
0.25 0.5 0.75 1
1 2 3 4 PERCENTILE_DISC
0.25 0.5 0.75 1
1 2 3 4 PERCENTILE_DISC(0.5)
SELECT PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY val) FROM data
Two variants:
(categories)
(linear interpolation)
1 2 3 4
0.25 0.5 0.75 1
1 2 3 4
0.25 0.5 0.75 1
1 2 3 4 PERCENTILE_DISC
0.25 0.5 0.75 1
1 2 3 4 PERCENTILE_DISC
0.25 0.5 0.75 1
1 2 3 4 PERCENTILE_DISC(0.5)
0.25 0.5 0.75 1
1 2 3 4 PERCENTILE_CONT PERCENTILE_DISC(0.5)
SELECT PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY val) FROM data
Two variants:
(categories)
(linear interpolation)
1 2 3 4
0.25 0.5 0.75 1
1 2 3 4
0.25 0.5 0.75 1
1 2 3 4 PERCENTILE_DISC
0.25 0.5 0.75 1
1 2 3 4 PERCENTILE_DISC
0.25 0.5 0.75 1
1 2 3 4 PERCENTILE_DISC(0.5)
0.25 0.5 0.75 1
1 2 3 4 PERCENTILE_CONT PERCENTILE_DISC(0.5)
0.25 0.5 0.75 1
1 2 3 4 PERCENTILE_CONT(0.5) PERCENTILE_DISC(0.5)
SELECT PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY val) FROM data
Two variants:
(categories)
(linear interpolation)
1999 2001 2003 2005 2007 2009 2011 2013 2015 2017
5.1 10.3.7
[0]
9.4
1.0
9iR1
2012[0]
[0]Only as window function (OVER required).
1999 2001 2003 2005 2007 2009 2011 2013 2015 2017
5.1 10.3.7
[0]
9.4
1.0
9iR1
2012[0]
[0]Only as window function (OVER required).
BigQuery Hive-16255 RESOLVED Fix Version: 4.0.0
http://standards.iso.org/ittf/PubliclyAvailableStandards/c067367_ISO_IEC_TR_19075-6_2017.zip
http://standards.iso.org/ittf/PubliclyAvailableStandards/c067367_ISO_IEC_TR_19075-6_2017.zip
http://standards.iso.org/ittf/PubliclyAvailableStandards/c067367_ISO_IEC_TR_19075-6_2017.zip
[ { "id": 42, "a1": "foo" }, { "id": 43, "a1": "bar" } ]
[ { "id": 42, "a1": "foo" }, { "id": 43, "a1": "bar" } ]
Bind Parameter
[ { "id": 42, "a1": "foo" }, { "id": 43, "a1": "bar" } ]
SQL/JSON Path
select elements from a JSON document
SQL standard
Bind Parameter
[ { "id": 42, "a1": "foo" }, { "id": 43, "a1": "bar" } ]
SQL/JSON Path
select elements from a JSON document
SQL standard
Bind Parameter
[ { "id": 42, "a1": "foo" }, { "id": 43, "a1": "bar" } ]
SQL/JSON Path
select elements from a JSON document
SQL standard
Bind Parameter
[ { "id": 42, "a1": "foo" }, { "id": 43, "a1": "bar" } ]
[ { "id": 42, "a1": "foo" }, { "id": 43, "a1": "bar" } ]
1999 2001 2003 2005 2007 2009 2011 2013 2015 2017
5.1
8.0 MySQL
1.0
11.1.4.4
[0]
12cR1
2016[1]
[0]Ridicoulus limitations: only 'strict $' as row expression [1]OPENJSON provides similar functionality
1999 2001 2003 2005 2007 2009 2011 2013 2015 2017
5.1
8.0 MySQL
1.0
11.1.4.4
[0]
12cR1
2016[1]
[0]Ridicoulus limitations: only 'strict $' as row expression [1]OPENJSON provides similar functionality
MDEV-17399 Tagged with fix/Version: 10.5 Patch available
http://cs.ulb.ac.be/public/_media/teaching/infoh415/tempfeaturessql2011.pdf
Application Versioning
happen in the real world?
http://cs.ulb.ac.be/public/_media/teaching/infoh415/tempfeaturessql2011.pdf
Application Versioning
happen in the real world?
New syntax (excerpt)
UPDATE and DELETE
constraints & PRIMARY KEYS
OVERLAPS in WHERE,HAVING,…
System Versioning
(almost) transparent
about something Application Versioning
happen in the real world?
New syntax (excerpt)
UPDATE and DELETE
constraints & PRIMARY KEYS
OVERLAPS in WHERE,HAVING,…
System Versioning
(almost) transparent
about something Application Versioning
happen in the real world?
New syntax (excerpt)
UPDATE and DELETE
constraints & PRIMARY KEYS
OVERLAPS in WHERE,HAVING,… Transparent changes, new syntax for queries
use the system time automatically
SYSTEM_TIME AS OF
id data from till 1 X 10:00
id data from till 1 X 10:00
id data from till 1 X 10:00 11:00 1 Y 11:00
id data from till 1 X 10:00
id data from till 1 X 10:00 11:00 1 Y 11:00
id data from till 1 X 10:00 11:00 1 Y 11:00 12:00
id data from till 1 X 10:00 11:00 1 Y 11:00 12:00
id data from till 1 X 10:00 11:00 1 Y 11:00 12:00
id data from till
id data from till 1 X 10:00 11:00 1 Y 11:00 12:00
id data from till
id data from till 1 X 10:00 11:00
1999 2001 2003 2005 2007 2009 2011 2013 2015 2017
5.1 10.3
1.0
10.1
10gR1[0] 11gR1[1]
2016
[0]Short term using Flashback. [1]Flashback Archive. Proprietery syntax.
https://webstore.iec.ch/publication/59685
https://webstore.iec.ch/publication/59685
https://webstore.iec.ch/publication/59685
@ModernSQL by @MarkusWinand