SlideShare a Scribd company logo
What SQL should
actually be...
Rafael Ördög, PhD.
Would you ever do this?
function initializeAutoSave() {
setTimeOut(2000, function() {
$('input#save').click();
initializeAutoSave();
});
}
How about doing this?
function createThumbnail($sourceImage) {
$size = Config::get('thumb-size');
$targetImage =
$this->getTargetName($sourceImage);
system("convert {$sourceImage}
--resize {$size}x{$size}
{$thumbImage}");
}
And yet we somehow accept this...
$dbh->exec("SELECT field FROM table");
And if we loathe this:
<script type="text/javascript">
<?php foreach($buttons as $button):?>
initButton(<?=$button["id"]?>,
<?=$button["usefulVar"]?>);
<?php endforeach; ?>
</script>
Why aren't we horrified by this?
function doSomeImportantAndComplexStuffInTheDatabase() {
$dbh->exec("UPDTATE {$this->generateComplexJoins()}" .
"SET {$this->generateFieldsAndValueSubQueries()}" .
"WHERE {$this->generateWhere()}");
}
function generateWhere() {
$result = "TRUE";
foreach($this->importantStuffs as $stuff) {
$result += " AND ".$stuff->subWhere();
}
}
Donald D. Chamberlin
the father of SQL
Origin of SQL
SEQUEL: A STRUCTURED ENGLISH QUERY
LANGUAGE (1974)
by Donald D. Chamberlin
Origin of SQL
SEQUEL: A STRUCTURED ENGLISH QUERY
LANGUAGE (1974)
by Donald D. Chamberlin
"However, there is also a large class of users
who, while they are not computer specialists,
would be willing to learn to interact with a
computer in a reasonably high-level, non-
procedural query language."
SQL is User Interface
● It's not an API
○ So that's why we need an ORM tool...
● It's not a protocol
● It's not even designed for programmers
● It was however derived from another
database CLI called SQUARE, that looks a
bit more like a protocol:
○ NAME, SAL EMP DEPT, MGR ('TOY', 'ANDERSON')
VS
○ SELECT NAME, SAL FROM EMP WHERE DEPT = 'TOY' AND MGR = 'ANDERSON'
The command line user interface is
not an API
● Leaking logic to other languages
● Dynamically generated code is hard to debug
● Security issues
○ Escaping is a horror scene
● Large overhead
○ Process launch overheads
○ Parse overhead
○ Command generation overhead
● Fragility
○ It's more prominent with a GUI, but CLIs are not much better
○ Have you ever tried to maintain a moderately sized
Greasemonkey script? It's a nightmare!
SQL is a bad UI by todays standards,
but it's even worse as an API
● Fails to separate concerns
○ Changing a query to improve performance may involve
breaking business logic
○ Requesting a little more data can have a large
performance hit
○ You could not optimize SQL queries with AOP
● Leaking concepts
○ We leak our entire datastructure to the DB
■ That is why a good ORM should generate DDL from
source code and not the way around
○ To solve performance issues we may even leak some of
our business logic. (Aggregating data.)
■ To the one thing that is hard to scale
Origin of SQL
SEQUEL: A STRUCTURED ENGLISH QUERY
LANGUAGE (1974)
by Donald D. Chamberlin
"SEQUEL identifies a set of simple operations
on tabular structures, which can be shown to
be of equivalent power to the first order
predicate calculus."
Non tabular structures
● Connections between people
● Ownership relations
● Documents (like articles, or presentations)
● Data that belongs to a video on YouTube:
○ Video
○ Comments
○ Likes
○ etc.
● Or more abstractly
○ hierarchies
○ graphs
So we have non tabular data
Customer
Order id
Order item
Order item
Order item
Payment details
And tables to store that in
Customer
Order id
Order item
Order item
Order item
Payment details
OrdersCustomersItemsPayments
And tables to store that in
Customer
Order id
Order item
Order item
Order item
Payment details
OrdersCustomersItemsPayments
Impedancemismatch
Data normalization
Customer
Order id
Order item
Order item
Order item
Payment details
OrdersCustomersItemsPayments
So we normalize our structures
● Strongly related data will be scattered all around
the hard drive
● Performance issues
● DBA requests a denormalization
○ Again: changing code for performance reason in a way
that potentially breaks business logic
● Denormalized data is not indexed by the SQL
database
○ So we create index tables...
● The code using the denormalized tables will be
a lot harder to maintain and understand
SQL tries too hard, and we abuse it
● SQL databases are more than just tabular data
stores
○ They enforce a data transfer mechanism
■ Why do I need to use TCP/IP to reach a local DB?
■ And I even need to authenticate!
○ They are indexing services but with very limited
capabilities.
● Why do we use SQL database for
○ Storing temporary data locally (maybe files or memory?)
○ Storing documents (maybe document stores?)
○ Message queues (it's terrible for that!)
○ Inter process communication (I mean... REALLY?!)
● It enforces a data transfer mechanism so it is really
slow to run tests using the database
○ Even if the data is in an in-memory table
○ So we don't test the DB... or only if we must...
● On the other hand since it's a complicated and
frequently used API, one would be tempted to write a
complete fake
○ One that stores stuff in memory, and won't use TCP/IP to
communicate
○ It's almost impossible to do that well, so we don't...
● But SQL queries may change in case of performance
optimization in ways that it breaks logic...
It makes testing hard
So what would be better?
● A native API instead of string commands. I
should be able to independently specify:
○ what data to collect or save
○ how that should be done
○ what to index
○ the way these commands are sent to the db
● The API should be as simple as possible
● Schema less data structure
○ And if you like static typing, then you can define your
schema as data structures or classes
In an SQL database the data
structure is leaked to the DB
SQL DB
Leaked
structure
APP
Dependence
That is the primary reason we
introduced the DB Layer
SQL DB
Leaked
structure
APP
Dependence
DBLayer
Dependence
A schema less database puts the schema to
the right side of the DB layer boundary
NoSQL DB
Data
Structure
APP
Dependence
DBLayer Dependence
And by the way we are hiring:
c0de-x.com
@devillsroom

More Related Content

Viewers also liked

Sascon social commerce presentation
Sascon social commerce presentationSascon social commerce presentation
Sascon social commerce presentationyrewol
 
FATZO Mouse - Semaglutide Poster - 2015 GTC-Diabetes Summit
FATZO Mouse - Semaglutide Poster - 2015 GTC-Diabetes SummitFATZO Mouse - Semaglutide Poster - 2015 GTC-Diabetes Summit
FATZO Mouse - Semaglutide Poster - 2015 GTC-Diabetes Summit
PreClinOmics
 
Lentera News edisi #16 Juli 2015
Lentera News edisi #16 Juli 2015Lentera News edisi #16 Juli 2015
Lentera News edisi #16 Juli 2015
Ananta Bangun
 
The Case for Continual Realignment of the IT Function
The Case for Continual Realignment of the IT FunctionThe Case for Continual Realignment of the IT Function
The Case for Continual Realignment of the IT FunctionFormicio
 
How to be Creative
How to be CreativeHow to be Creative
How to be Creative
Bipul Deb Nath
 
Tdr-L'aigua
Tdr-L'aiguaTdr-L'aigua
Tdr-L'aiguachoriol
 
Organizational fitness2013
Organizational fitness2013Organizational fitness2013
Organizational fitness2013Globant
 
Homage to sri aurobindo, part 2
Homage to sri aurobindo, part 2Homage to sri aurobindo, part 2
Homage to sri aurobindo, part 2
Jitendra Sharma
 
Power point presentations
Power point presentationsPower point presentations
Power point presentationsbauder
 
Biomedical engineering
Biomedical engineeringBiomedical engineering
Biomedical engineeringanderson-_-25
 
Afs presentation from SHFCA, March 2013
Afs presentation from SHFCA, March 2013Afs presentation from SHFCA, March 2013
Afs presentation from SHFCA, March 2013
Air Fuel Synthesis
 
INFLUENȚA FACTORILOR DE MEDIU ASUPRA DEGRADĂRII OPERELOR DE ARTĂ MONUMENTALE ...
INFLUENȚA FACTORILOR DE MEDIU ASUPRA DEGRADĂRIIOPERELOR DE ARTĂ MONUMENTALE ...INFLUENȚA FACTORILOR DE MEDIU ASUPRA DEGRADĂRIIOPERELOR DE ARTĂ MONUMENTALE ...
INFLUENȚA FACTORILOR DE MEDIU ASUPRA DEGRADĂRII OPERELOR DE ARTĂ MONUMENTALE ...
Alexandru Vlad Murzac
 
Best Residential Interior Designer In Pune
Best Residential Interior Designer In PuneBest Residential Interior Designer In Pune
Best Residential Interior Designer In Pune
sudhir pawar & associates
 
Inorme 2 trimestre 2014 biblioteca del pio x
Inorme 2 trimestre 2014   biblioteca del pio xInorme 2 trimestre 2014   biblioteca del pio x
Inorme 2 trimestre 2014 biblioteca del pio xDaniel Francisco Doffo
 
Teoria si metodologia_instruirii_autor_conf_univ_dr_irina_maciuc (1)
Teoria si metodologia_instruirii_autor_conf_univ_dr_irina_maciuc (1)Teoria si metodologia_instruirii_autor_conf_univ_dr_irina_maciuc (1)
Teoria si metodologia_instruirii_autor_conf_univ_dr_irina_maciuc (1)Gheorghitoiumaria
 
Razvoj i prezentacija na proekt
Razvoj i prezentacija na proektRazvoj i prezentacija na proekt
Razvoj i prezentacija na proekt
Cre8ive8
 

Viewers also liked (18)

Series y libros.htm
Series y libros.htmSeries y libros.htm
Series y libros.htm
 
Sascon social commerce presentation
Sascon social commerce presentationSascon social commerce presentation
Sascon social commerce presentation
 
FATZO Mouse - Semaglutide Poster - 2015 GTC-Diabetes Summit
FATZO Mouse - Semaglutide Poster - 2015 GTC-Diabetes SummitFATZO Mouse - Semaglutide Poster - 2015 GTC-Diabetes Summit
FATZO Mouse - Semaglutide Poster - 2015 GTC-Diabetes Summit
 
Bolroo
BolrooBolroo
Bolroo
 
Lentera News edisi #16 Juli 2015
Lentera News edisi #16 Juli 2015Lentera News edisi #16 Juli 2015
Lentera News edisi #16 Juli 2015
 
The Case for Continual Realignment of the IT Function
The Case for Continual Realignment of the IT FunctionThe Case for Continual Realignment of the IT Function
The Case for Continual Realignment of the IT Function
 
How to be Creative
How to be CreativeHow to be Creative
How to be Creative
 
Tdr-L'aigua
Tdr-L'aiguaTdr-L'aigua
Tdr-L'aigua
 
Organizational fitness2013
Organizational fitness2013Organizational fitness2013
Organizational fitness2013
 
Homage to sri aurobindo, part 2
Homage to sri aurobindo, part 2Homage to sri aurobindo, part 2
Homage to sri aurobindo, part 2
 
Power point presentations
Power point presentationsPower point presentations
Power point presentations
 
Biomedical engineering
Biomedical engineeringBiomedical engineering
Biomedical engineering
 
Afs presentation from SHFCA, March 2013
Afs presentation from SHFCA, March 2013Afs presentation from SHFCA, March 2013
Afs presentation from SHFCA, March 2013
 
INFLUENȚA FACTORILOR DE MEDIU ASUPRA DEGRADĂRII OPERELOR DE ARTĂ MONUMENTALE ...
INFLUENȚA FACTORILOR DE MEDIU ASUPRA DEGRADĂRIIOPERELOR DE ARTĂ MONUMENTALE ...INFLUENȚA FACTORILOR DE MEDIU ASUPRA DEGRADĂRIIOPERELOR DE ARTĂ MONUMENTALE ...
INFLUENȚA FACTORILOR DE MEDIU ASUPRA DEGRADĂRII OPERELOR DE ARTĂ MONUMENTALE ...
 
Best Residential Interior Designer In Pune
Best Residential Interior Designer In PuneBest Residential Interior Designer In Pune
Best Residential Interior Designer In Pune
 
Inorme 2 trimestre 2014 biblioteca del pio x
Inorme 2 trimestre 2014   biblioteca del pio xInorme 2 trimestre 2014   biblioteca del pio x
Inorme 2 trimestre 2014 biblioteca del pio x
 
Teoria si metodologia_instruirii_autor_conf_univ_dr_irina_maciuc (1)
Teoria si metodologia_instruirii_autor_conf_univ_dr_irina_maciuc (1)Teoria si metodologia_instruirii_autor_conf_univ_dr_irina_maciuc (1)
Teoria si metodologia_instruirii_autor_conf_univ_dr_irina_maciuc (1)
 
Razvoj i prezentacija na proekt
Razvoj i prezentacija na proektRazvoj i prezentacija na proekt
Razvoj i prezentacija na proekt
 

Similar to What SQL should actually be...

Improving PySpark performance: Spark Performance Beyond the JVM
Improving PySpark performance: Spark Performance Beyond the JVMImproving PySpark performance: Spark Performance Beyond the JVM
Improving PySpark performance: Spark Performance Beyond the JVM
Holden Karau
 
Tales from the Field
Tales from the FieldTales from the Field
Tales from the FieldMongoDB
 
How MySQL can boost (or kill) your application v2
How MySQL can boost (or kill) your application v2How MySQL can boost (or kill) your application v2
How MySQL can boost (or kill) your application v2
Federico Razzoli
 
The magic of (data parallel) distributed systems and where it all breaks - Re...
The magic of (data parallel) distributed systems and where it all breaks - Re...The magic of (data parallel) distributed systems and where it all breaks - Re...
The magic of (data parallel) distributed systems and where it all breaks - Re...
Holden Karau
 
Keeping the fun in functional w/ Apache Spark @ Scala Days NYC
Keeping the fun in functional   w/ Apache Spark @ Scala Days NYCKeeping the fun in functional   w/ Apache Spark @ Scala Days NYC
Keeping the fun in functional w/ Apache Spark @ Scala Days NYC
Holden Karau
 
Beyond Shuffling - Effective Tips and Tricks for Scaling Spark (Vancouver Sp...
Beyond Shuffling  - Effective Tips and Tricks for Scaling Spark (Vancouver Sp...Beyond Shuffling  - Effective Tips and Tricks for Scaling Spark (Vancouver Sp...
Beyond Shuffling - Effective Tips and Tricks for Scaling Spark (Vancouver Sp...
Holden Karau
 
Randomizing Data With SQL Server
Randomizing Data With SQL ServerRandomizing Data With SQL Server
Randomizing Data With SQL Server
Wally Pons
 
Etl confessions pg conf us 2017
Etl confessions   pg conf us 2017Etl confessions   pg conf us 2017
Etl confessions pg conf us 2017
Corey Huinker
 
Data Pipline Observability meetup
Data Pipline Observability meetup Data Pipline Observability meetup
Data Pipline Observability meetup
Omid Vahdaty
 
Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...
Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...
Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...
Holden Karau
 
Big Data in 200 km/h | AWS Big Data Demystified #1.3
Big Data in 200 km/h | AWS Big Data Demystified #1.3  Big Data in 200 km/h | AWS Big Data Demystified #1.3
Big Data in 200 km/h | AWS Big Data Demystified #1.3
Omid Vahdaty
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuning
ngupt28
 
Speeding up Page Load Times by Using Starling
Speeding up Page Load Times by Using StarlingSpeeding up Page Load Times by Using Starling
Speeding up Page Load Times by Using StarlingErik Osterman
 
PostgreSQL - масштабирование в моде, Valentine Gogichashvili (Zalando SE)
PostgreSQL - масштабирование в моде, Valentine Gogichashvili (Zalando SE)PostgreSQL - масштабирование в моде, Valentine Gogichashvili (Zalando SE)
PostgreSQL - масштабирование в моде, Valentine Gogichashvili (Zalando SE)
Ontico
 
SPL_ALL_EN.pptx
SPL_ALL_EN.pptxSPL_ALL_EN.pptx
SPL_ALL_EN.pptx
政宏 张
 
Stumbling stones when migrating from Oracle
 Stumbling stones when migrating from Oracle Stumbling stones when migrating from Oracle
Stumbling stones when migrating from Oracle
EDB
 
Dirty data? Clean it up! - Datapalooza Denver 2016
Dirty data? Clean it up! - Datapalooza Denver 2016Dirty data? Clean it up! - Datapalooza Denver 2016
Dirty data? Clean it up! - Datapalooza Denver 2016
Dan Lynn
 
Dirty Data? Clean it up! - Rocky Mountain DataCon 2016
Dirty Data? Clean it up! - Rocky Mountain DataCon 2016Dirty Data? Clean it up! - Rocky Mountain DataCon 2016
Dirty Data? Clean it up! - Rocky Mountain DataCon 2016
Dan Lynn
 
The immutable database datomic
The immutable database   datomicThe immutable database   datomic
The immutable database datomic
Laurence Chen
 
Webinar: Avoiding Sub-optimal Performance in your Retail Application
Webinar: Avoiding Sub-optimal Performance in your Retail ApplicationWebinar: Avoiding Sub-optimal Performance in your Retail Application
Webinar: Avoiding Sub-optimal Performance in your Retail Application
MongoDB
 

Similar to What SQL should actually be... (20)

Improving PySpark performance: Spark Performance Beyond the JVM
Improving PySpark performance: Spark Performance Beyond the JVMImproving PySpark performance: Spark Performance Beyond the JVM
Improving PySpark performance: Spark Performance Beyond the JVM
 
Tales from the Field
Tales from the FieldTales from the Field
Tales from the Field
 
How MySQL can boost (or kill) your application v2
How MySQL can boost (or kill) your application v2How MySQL can boost (or kill) your application v2
How MySQL can boost (or kill) your application v2
 
The magic of (data parallel) distributed systems and where it all breaks - Re...
The magic of (data parallel) distributed systems and where it all breaks - Re...The magic of (data parallel) distributed systems and where it all breaks - Re...
The magic of (data parallel) distributed systems and where it all breaks - Re...
 
Keeping the fun in functional w/ Apache Spark @ Scala Days NYC
Keeping the fun in functional   w/ Apache Spark @ Scala Days NYCKeeping the fun in functional   w/ Apache Spark @ Scala Days NYC
Keeping the fun in functional w/ Apache Spark @ Scala Days NYC
 
Beyond Shuffling - Effective Tips and Tricks for Scaling Spark (Vancouver Sp...
Beyond Shuffling  - Effective Tips and Tricks for Scaling Spark (Vancouver Sp...Beyond Shuffling  - Effective Tips and Tricks for Scaling Spark (Vancouver Sp...
Beyond Shuffling - Effective Tips and Tricks for Scaling Spark (Vancouver Sp...
 
Randomizing Data With SQL Server
Randomizing Data With SQL ServerRandomizing Data With SQL Server
Randomizing Data With SQL Server
 
Etl confessions pg conf us 2017
Etl confessions   pg conf us 2017Etl confessions   pg conf us 2017
Etl confessions pg conf us 2017
 
Data Pipline Observability meetup
Data Pipline Observability meetup Data Pipline Observability meetup
Data Pipline Observability meetup
 
Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...
Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...
Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...
 
Big Data in 200 km/h | AWS Big Data Demystified #1.3
Big Data in 200 km/h | AWS Big Data Demystified #1.3  Big Data in 200 km/h | AWS Big Data Demystified #1.3
Big Data in 200 km/h | AWS Big Data Demystified #1.3
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuning
 
Speeding up Page Load Times by Using Starling
Speeding up Page Load Times by Using StarlingSpeeding up Page Load Times by Using Starling
Speeding up Page Load Times by Using Starling
 
PostgreSQL - масштабирование в моде, Valentine Gogichashvili (Zalando SE)
PostgreSQL - масштабирование в моде, Valentine Gogichashvili (Zalando SE)PostgreSQL - масштабирование в моде, Valentine Gogichashvili (Zalando SE)
PostgreSQL - масштабирование в моде, Valentine Gogichashvili (Zalando SE)
 
SPL_ALL_EN.pptx
SPL_ALL_EN.pptxSPL_ALL_EN.pptx
SPL_ALL_EN.pptx
 
Stumbling stones when migrating from Oracle
 Stumbling stones when migrating from Oracle Stumbling stones when migrating from Oracle
Stumbling stones when migrating from Oracle
 
Dirty data? Clean it up! - Datapalooza Denver 2016
Dirty data? Clean it up! - Datapalooza Denver 2016Dirty data? Clean it up! - Datapalooza Denver 2016
Dirty data? Clean it up! - Datapalooza Denver 2016
 
Dirty Data? Clean it up! - Rocky Mountain DataCon 2016
Dirty Data? Clean it up! - Rocky Mountain DataCon 2016Dirty Data? Clean it up! - Rocky Mountain DataCon 2016
Dirty Data? Clean it up! - Rocky Mountain DataCon 2016
 
The immutable database datomic
The immutable database   datomicThe immutable database   datomic
The immutable database datomic
 
Webinar: Avoiding Sub-optimal Performance in your Retail Application
Webinar: Avoiding Sub-optimal Performance in your Retail ApplicationWebinar: Avoiding Sub-optimal Performance in your Retail Application
Webinar: Avoiding Sub-optimal Performance in your Retail Application
 

More from Open Academy

BDD demisztifikálva
BDD demisztifikálvaBDD demisztifikálva
BDD demisztifikálva
Open Academy
 
Dev tools rendering & memory profiling
Dev tools rendering & memory profilingDev tools rendering & memory profiling
Dev tools rendering & memory profilingOpen Academy
 
Firefox OS: hackelni könnyű
Firefox OS:  hackelni könnyűFirefox OS:  hackelni könnyű
Firefox OS: hackelni könnyű
Open Academy
 
BlackBerry10 alapú natív alkalmazásfejlesztés
BlackBerry10 alapú natív alkalmazásfejlesztésBlackBerry10 alapú natív alkalmazásfejlesztés
BlackBerry10 alapú natív alkalmazásfejlesztésOpen Academy
 
Android fejlesztés
Android fejlesztésAndroid fejlesztés
Android fejlesztés
Open Academy
 
Magvas gondolatok
Magvas gondolatokMagvas gondolatok
Magvas gondolatok
Open Academy
 
A Windows Phone világa
A Windows Phone világaA Windows Phone világa
A Windows Phone világa
Open Academy
 
Okostelefonok és táblagépek menedzsmentje
Okostelefonok és táblagépek menedzsmentjeOkostelefonok és táblagépek menedzsmentje
Okostelefonok és táblagépek menedzsmentjeOpen Academy
 
Windows 8
Windows 8Windows 8
Windows 8
Open Academy
 
Ipari felhő infrastruktúrák a gyakorlatban
Ipari felhő infrastruktúrák a gyakorlatbanIpari felhő infrastruktúrák a gyakorlatban
Ipari felhő infrastruktúrák a gyakorlatban
Open Academy
 
Túlélés a Három Betűs Rövidítések világában
Túlélés a Három Betűs Rövidítések világábanTúlélés a Három Betűs Rövidítések világában
Túlélés a Három Betűs Rövidítések világában
Open Academy
 
Adminisztratív protokollok ellenőrzési lehetőségei
Adminisztratív protokollok ellenőrzési lehetőségeiAdminisztratív protokollok ellenőrzési lehetőségei
Adminisztratív protokollok ellenőrzési lehetőségei
Open Academy
 
Naplózás a gyakorlatban
Naplózás a gyakorlatbanNaplózás a gyakorlatban
Naplózás a gyakorlatban
Open Academy
 
Hogyan optimalizáljunk C/C++ kódokat!
Hogyan optimalizáljunk C/C++ kódokat!Hogyan optimalizáljunk C/C++ kódokat!
Hogyan optimalizáljunk C/C++ kódokat!
Open Academy
 
Hogy kerül a csizma az asztalra?
Hogy kerül a csizma az asztalra?Hogy kerül a csizma az asztalra?
Hogy kerül a csizma az asztalra?
Open Academy
 
AGILIS / SCRUM fejlesztés
AGILIS / SCRUM fejlesztésAGILIS / SCRUM fejlesztés
AGILIS / SCRUM fejlesztés
Open Academy
 
Multiplatform mobil fejlesztések
Multiplatform mobil fejlesztésekMultiplatform mobil fejlesztések
Multiplatform mobil fejlesztések
Open Academy
 
Webműves Kelemen tanácsai, avagy mi kell a PHP falába?
Webműves Kelemen tanácsai, avagy mi kell a PHP falába?Webműves Kelemen tanácsai, avagy mi kell a PHP falába?
Webműves Kelemen tanácsai, avagy mi kell a PHP falába?
Open Academy
 
Verziókövető rendszerek alkalmazása fejlesztési projektekben
Verziókövető rendszerek alkalmazása fejlesztési projektekbenVerziókövető rendszerek alkalmazása fejlesztési projektekben
Verziókövető rendszerek alkalmazása fejlesztési projektekben
Open Academy
 

More from Open Academy (20)

BDD demisztifikálva
BDD demisztifikálvaBDD demisztifikálva
BDD demisztifikálva
 
Dev tools rendering & memory profiling
Dev tools rendering & memory profilingDev tools rendering & memory profiling
Dev tools rendering & memory profiling
 
Firefox OS: hackelni könnyű
Firefox OS:  hackelni könnyűFirefox OS:  hackelni könnyű
Firefox OS: hackelni könnyű
 
Coding dojo
Coding dojoCoding dojo
Coding dojo
 
BlackBerry10 alapú natív alkalmazásfejlesztés
BlackBerry10 alapú natív alkalmazásfejlesztésBlackBerry10 alapú natív alkalmazásfejlesztés
BlackBerry10 alapú natív alkalmazásfejlesztés
 
Android fejlesztés
Android fejlesztésAndroid fejlesztés
Android fejlesztés
 
Magvas gondolatok
Magvas gondolatokMagvas gondolatok
Magvas gondolatok
 
A Windows Phone világa
A Windows Phone világaA Windows Phone világa
A Windows Phone világa
 
Okostelefonok és táblagépek menedzsmentje
Okostelefonok és táblagépek menedzsmentjeOkostelefonok és táblagépek menedzsmentje
Okostelefonok és táblagépek menedzsmentje
 
Windows 8
Windows 8Windows 8
Windows 8
 
Ipari felhő infrastruktúrák a gyakorlatban
Ipari felhő infrastruktúrák a gyakorlatbanIpari felhő infrastruktúrák a gyakorlatban
Ipari felhő infrastruktúrák a gyakorlatban
 
Túlélés a Három Betűs Rövidítések világában
Túlélés a Három Betűs Rövidítések világábanTúlélés a Három Betűs Rövidítések világában
Túlélés a Három Betűs Rövidítések világában
 
Adminisztratív protokollok ellenőrzési lehetőségei
Adminisztratív protokollok ellenőrzési lehetőségeiAdminisztratív protokollok ellenőrzési lehetőségei
Adminisztratív protokollok ellenőrzési lehetőségei
 
Naplózás a gyakorlatban
Naplózás a gyakorlatbanNaplózás a gyakorlatban
Naplózás a gyakorlatban
 
Hogyan optimalizáljunk C/C++ kódokat!
Hogyan optimalizáljunk C/C++ kódokat!Hogyan optimalizáljunk C/C++ kódokat!
Hogyan optimalizáljunk C/C++ kódokat!
 
Hogy kerül a csizma az asztalra?
Hogy kerül a csizma az asztalra?Hogy kerül a csizma az asztalra?
Hogy kerül a csizma az asztalra?
 
AGILIS / SCRUM fejlesztés
AGILIS / SCRUM fejlesztésAGILIS / SCRUM fejlesztés
AGILIS / SCRUM fejlesztés
 
Multiplatform mobil fejlesztések
Multiplatform mobil fejlesztésekMultiplatform mobil fejlesztések
Multiplatform mobil fejlesztések
 
Webműves Kelemen tanácsai, avagy mi kell a PHP falába?
Webműves Kelemen tanácsai, avagy mi kell a PHP falába?Webműves Kelemen tanácsai, avagy mi kell a PHP falába?
Webműves Kelemen tanácsai, avagy mi kell a PHP falába?
 
Verziókövető rendszerek alkalmazása fejlesztési projektekben
Verziókövető rendszerek alkalmazása fejlesztési projektekbenVerziókövető rendszerek alkalmazása fejlesztési projektekben
Verziókövető rendszerek alkalmazása fejlesztési projektekben
 

Recently uploaded

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 

Recently uploaded (20)

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 

What SQL should actually be...

  • 1. What SQL should actually be... Rafael Ördög, PhD.
  • 2.
  • 3.
  • 4. Would you ever do this? function initializeAutoSave() { setTimeOut(2000, function() { $('input#save').click(); initializeAutoSave(); }); }
  • 5. How about doing this? function createThumbnail($sourceImage) { $size = Config::get('thumb-size'); $targetImage = $this->getTargetName($sourceImage); system("convert {$sourceImage} --resize {$size}x{$size} {$thumbImage}"); }
  • 6. And yet we somehow accept this... $dbh->exec("SELECT field FROM table");
  • 7. And if we loathe this: <script type="text/javascript"> <?php foreach($buttons as $button):?> initButton(<?=$button["id"]?>, <?=$button["usefulVar"]?>); <?php endforeach; ?> </script>
  • 8. Why aren't we horrified by this? function doSomeImportantAndComplexStuffInTheDatabase() { $dbh->exec("UPDTATE {$this->generateComplexJoins()}" . "SET {$this->generateFieldsAndValueSubQueries()}" . "WHERE {$this->generateWhere()}"); } function generateWhere() { $result = "TRUE"; foreach($this->importantStuffs as $stuff) { $result += " AND ".$stuff->subWhere(); } }
  • 9.
  • 10. Donald D. Chamberlin the father of SQL
  • 11. Origin of SQL SEQUEL: A STRUCTURED ENGLISH QUERY LANGUAGE (1974) by Donald D. Chamberlin
  • 12. Origin of SQL SEQUEL: A STRUCTURED ENGLISH QUERY LANGUAGE (1974) by Donald D. Chamberlin "However, there is also a large class of users who, while they are not computer specialists, would be willing to learn to interact with a computer in a reasonably high-level, non- procedural query language."
  • 13. SQL is User Interface ● It's not an API ○ So that's why we need an ORM tool... ● It's not a protocol ● It's not even designed for programmers ● It was however derived from another database CLI called SQUARE, that looks a bit more like a protocol: ○ NAME, SAL EMP DEPT, MGR ('TOY', 'ANDERSON') VS ○ SELECT NAME, SAL FROM EMP WHERE DEPT = 'TOY' AND MGR = 'ANDERSON'
  • 14. The command line user interface is not an API ● Leaking logic to other languages ● Dynamically generated code is hard to debug ● Security issues ○ Escaping is a horror scene ● Large overhead ○ Process launch overheads ○ Parse overhead ○ Command generation overhead ● Fragility ○ It's more prominent with a GUI, but CLIs are not much better ○ Have you ever tried to maintain a moderately sized Greasemonkey script? It's a nightmare!
  • 15. SQL is a bad UI by todays standards, but it's even worse as an API ● Fails to separate concerns ○ Changing a query to improve performance may involve breaking business logic ○ Requesting a little more data can have a large performance hit ○ You could not optimize SQL queries with AOP ● Leaking concepts ○ We leak our entire datastructure to the DB ■ That is why a good ORM should generate DDL from source code and not the way around ○ To solve performance issues we may even leak some of our business logic. (Aggregating data.) ■ To the one thing that is hard to scale
  • 16. Origin of SQL SEQUEL: A STRUCTURED ENGLISH QUERY LANGUAGE (1974) by Donald D. Chamberlin "SEQUEL identifies a set of simple operations on tabular structures, which can be shown to be of equivalent power to the first order predicate calculus."
  • 17. Non tabular structures ● Connections between people ● Ownership relations ● Documents (like articles, or presentations) ● Data that belongs to a video on YouTube: ○ Video ○ Comments ○ Likes ○ etc. ● Or more abstractly ○ hierarchies ○ graphs
  • 18. So we have non tabular data Customer Order id Order item Order item Order item Payment details
  • 19. And tables to store that in Customer Order id Order item Order item Order item Payment details OrdersCustomersItemsPayments
  • 20. And tables to store that in Customer Order id Order item Order item Order item Payment details OrdersCustomersItemsPayments Impedancemismatch
  • 21. Data normalization Customer Order id Order item Order item Order item Payment details OrdersCustomersItemsPayments
  • 22. So we normalize our structures ● Strongly related data will be scattered all around the hard drive ● Performance issues ● DBA requests a denormalization ○ Again: changing code for performance reason in a way that potentially breaks business logic ● Denormalized data is not indexed by the SQL database ○ So we create index tables... ● The code using the denormalized tables will be a lot harder to maintain and understand
  • 23. SQL tries too hard, and we abuse it ● SQL databases are more than just tabular data stores ○ They enforce a data transfer mechanism ■ Why do I need to use TCP/IP to reach a local DB? ■ And I even need to authenticate! ○ They are indexing services but with very limited capabilities. ● Why do we use SQL database for ○ Storing temporary data locally (maybe files or memory?) ○ Storing documents (maybe document stores?) ○ Message queues (it's terrible for that!) ○ Inter process communication (I mean... REALLY?!)
  • 24. ● It enforces a data transfer mechanism so it is really slow to run tests using the database ○ Even if the data is in an in-memory table ○ So we don't test the DB... or only if we must... ● On the other hand since it's a complicated and frequently used API, one would be tempted to write a complete fake ○ One that stores stuff in memory, and won't use TCP/IP to communicate ○ It's almost impossible to do that well, so we don't... ● But SQL queries may change in case of performance optimization in ways that it breaks logic... It makes testing hard
  • 25.
  • 26. So what would be better? ● A native API instead of string commands. I should be able to independently specify: ○ what data to collect or save ○ how that should be done ○ what to index ○ the way these commands are sent to the db ● The API should be as simple as possible ● Schema less data structure ○ And if you like static typing, then you can define your schema as data structures or classes
  • 27. In an SQL database the data structure is leaked to the DB SQL DB Leaked structure APP Dependence
  • 28. That is the primary reason we introduced the DB Layer SQL DB Leaked structure APP Dependence DBLayer Dependence
  • 29. A schema less database puts the schema to the right side of the DB layer boundary NoSQL DB Data Structure APP Dependence DBLayer Dependence
  • 30. And by the way we are hiring: c0de-x.com @devillsroom