SlideShare une entreprise Scribd logo
1  sur  30
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

Contenu connexe

En vedette

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 SummitPreClinOmics
 
Lentera News edisi #16 Juli 2015
Lentera News edisi #16 Juli 2015Lentera News edisi #16 Juli 2015
Lentera News edisi #16 Juli 2015Ananta 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
 
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 2Jitendra 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 2013Air 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
 
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 proektCre8ive8
 

En vedette (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
 

Similaire à 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 JVMHolden 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 v2Federico 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 NYCHolden 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 ServerWally Pons
 
Etl confessions pg conf us 2017
Etl confessions   pg conf us 2017Etl confessions   pg conf us 2017
Etl confessions pg conf us 2017Corey 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 tuningngupt28
 
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 OracleEDB
 
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 2016Dan 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 2016Dan Lynn
 
The immutable database datomic
The immutable database   datomicThe immutable database   datomic
The immutable database datomicLaurence 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 ApplicationMongoDB
 

Similaire à 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
 

Plus de Open Academy

BDD demisztifikálva
BDD demisztifikálvaBDD demisztifikálva
BDD demisztifikálvaOpen 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ésOpen Academy
 
A Windows Phone világa
A Windows Phone világaA Windows Phone világa
A Windows Phone világaOpen 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
 
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 gyakorlatbanOpen 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ábanOpen 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égeiOpen Academy
 
Naplózás a gyakorlatban
Naplózás a gyakorlatbanNaplózás a gyakorlatban
Naplózás a gyakorlatbanOpen 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ésOpen Academy
 
Multiplatform mobil fejlesztések
Multiplatform mobil fejlesztésekMultiplatform mobil fejlesztések
Multiplatform mobil fejlesztésekOpen 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 projektekbenOpen Academy
 

Plus de 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
 

Dernier

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Dernier (20)

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

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