SlideShare a Scribd company logo
8th of October 2014 
Zen SQL 
Best practices to query and database design 
by Clément Prévost
8th of October 2014 
The Zen way to SQL 
● State of the art 
● Readability best practices: 
a. Database schema 
b. Query
8th of October 2014 
State of the art 
● ORM (Doctrine, ActiveRecord, ...) 
○ Hides the database schema and queries, follow your 
applicative coding best practices 
● Query Builder (ZendDbSql, …) 
○ Hides the queries, not the schema 
● Raw (Migration scripts, performance critical task, 
Analytics) 
○ DIY
8th of October 2014 
The Zen way to SQL 
● State of the art 
● Readability best practices: 
a. Database schema 
b. Query
a) Database schema best practices 
8th of October 2014 
A. KISS 
○ Beware of overengineering 
○ Don’t let optimizations get in the way of simplicity 
B. Explicitness is the key 
○ Ban abbreviations, “status” column and add 
comments 
C. Your business WILL evolve, same with your schema 
○ Never be afraid to refactor, rename and move stuff 
around
8th of October 2014 
Case study: Database schema BP
8th of October 2014 
1 
3 
2 
1 
2 
3 
3
8th of October 2014 
The Zen way to SQL 
● State of the art 
● Readability best practices: 
a. Database schema 
b. Query
8th of October 2014 
b) Query best practices 
A. Comments and documentation, Avoid deep nesting, 
Reuse external libraries 
B. Know your enemy: Long vs. complex queries 
C. Tools: IDE, Database specificity, SQL capabilities
8th of October 2014
8th of October 2014
8th of October 2014
8th of October 2014 
Key things to remember 
● Work it step by step 
○ Have a perfect schema, then work on beautiful 
queries 
● Know your tools, learn advanced SQL 
● You already know how 
○ Good coding practices also apply to SQL (queries 
AND schema)
8th of October 2014 
Questions ? 
For online questions, please leave a comment on the article.
8th of October 2014 
Join the community ! 
(in Paris) 
Social networks : 
● Follow us on Twitter : https://twitter.com/steamlearn 
● Like us on Facebook : https://www.facebook.com/steamlearn 
SteamLearn is an Inovia initiative : inovia.fr 
You wish to be in the audience ? Contact us at 
learn@steamhouse.fr
8th of October 2014 
Sources 
1. http://www.slideshare.net/Samuel90/software-development-vs-software-maintenance 
2. http://code.tutsplus.com/tutorials/top-15-best-practices-for-writing-super-readable-code--net- 
8118 
3. http://www.postgresql.org/docs/9.3/static/view-pg-available-extensions.html 
4. http://postgres-bits.herokuapp.com/ 
5. http://www.postgresql.org/docs/9.3/static/index.html

More Related Content

PDF
Qt Design Patterns
PPT
Railsgirls presentation
PDF
Steam Learn: Composer
PDF
2015.02.05 alexis von glasow - faster php testing process with atoum
PDF
Steam Learn: REST Good practices
PDF
Steam Learn: Faster php testing process with Atoum
PDF
Steam Learn: Introduction to SWIFT
PDF
Steam Learn : Varnish or How to reduce the load of your web server
Qt Design Patterns
Railsgirls presentation
Steam Learn: Composer
2015.02.05 alexis von glasow - faster php testing process with atoum
Steam Learn: REST Good practices
Steam Learn: Faster php testing process with Atoum
Steam Learn: Introduction to SWIFT
Steam Learn : Varnish or How to reduce the load of your web server

Viewers also liked (8)

PDF
Steam Learn: Introduction to RDBMS indexes
PDF
Steam Learn: How to write good tests
PDF
Steam Learn: Email deliverability
PDF
Steam Learn: Cheat sheet for Vim
PDF
Steam Learn: Introduction to NoSQL with MongoDB
PDF
Steam Learn: Speedrun et TAS
PDF
Steam Learn: An introduction to Redis
PDF
Steam Learn: Javascript and OOP
Steam Learn: Introduction to RDBMS indexes
Steam Learn: How to write good tests
Steam Learn: Email deliverability
Steam Learn: Cheat sheet for Vim
Steam Learn: Introduction to NoSQL with MongoDB
Steam Learn: Speedrun et TAS
Steam Learn: An introduction to Redis
Steam Learn: Javascript and OOP
Ad

Similar to Steam Learn: Zen SQL (20)

PDF
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
PDF
Lightening Talk - PostgreSQL Worst Practices
PPTX
Sql server infernals
PPTX
My Database Skills Killed the Server
PDF
10 SQL Tricks that You Didn't Think Were Possible
PDF
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...
PDF
Qcon talk
PDF
Data antipatterns NYC Devops - 2014
PDF
Designing for performance: Database Related Worst Practices
ODP
Performance tuning
PPTX
Mastering-SQL-Your-Guide-to-Database-Development.pptx
PDF
Database story by DevOps
PPTX
Top 10 tips for Oracle performance (Updated April 2015)
PDF
Designing for Performance: Database Related Worst Practices
PPTX
Pl sql best practices document
PPTX
Tuning a database for millions of users
PDF
Five steps perform_2013
PPTX
SQL Server Tips & Tricks
PPTX
SQL Tutorial for Marketers
PPTX
SQL Server Worst Practices - EN
PostgreSQL worst practices, version FOSDEM PGDay 2017 by Ilya Kosmodemiansky
Lightening Talk - PostgreSQL Worst Practices
Sql server infernals
My Database Skills Killed the Server
10 SQL Tricks that You Didn't Think Were Possible
OSA Con 2022 - Tips and Tricks to Keep Your Queries under 100ms with ClickHou...
Qcon talk
Data antipatterns NYC Devops - 2014
Designing for performance: Database Related Worst Practices
Performance tuning
Mastering-SQL-Your-Guide-to-Database-Development.pptx
Database story by DevOps
Top 10 tips for Oracle performance (Updated April 2015)
Designing for Performance: Database Related Worst Practices
Pl sql best practices document
Tuning a database for millions of users
Five steps perform_2013
SQL Server Tips & Tricks
SQL Tutorial for Marketers
SQL Server Worst Practices - EN
Ad

More from inovia (18)

PDF
10 tips for Redux at scale
PDF
10 essentials steps for kafka streaming services
PDF
Redux at scale
PDF
DocuSign's Road to react
PPTX
API Gateway: Nginx way
PPTX
Kafka: meetup microservice
PPTX
Microservice: starting point
PPTX
Correlation id (tid)
PPTX
Meetic back end redesign - Meetup microservices
PPTX
Security in microservices architectures
PPTX
Building a Secure, Performant Network Fabric for Microservice Applications
PPTX
Microservices vs SOA
PPTX
CQRS, an introduction by JC Bohin
PPTX
Domain Driven Design
PPTX
Oauth2, open-id connect with microservices
PPTX
You probably don't need microservices
PPTX
Api Gateway - What's the use of an api gateway?
PDF
Steam Learn: Asynchronous Javascript
10 tips for Redux at scale
10 essentials steps for kafka streaming services
Redux at scale
DocuSign's Road to react
API Gateway: Nginx way
Kafka: meetup microservice
Microservice: starting point
Correlation id (tid)
Meetic back end redesign - Meetup microservices
Security in microservices architectures
Building a Secure, Performant Network Fabric for Microservice Applications
Microservices vs SOA
CQRS, an introduction by JC Bohin
Domain Driven Design
Oauth2, open-id connect with microservices
You probably don't need microservices
Api Gateway - What's the use of an api gateway?
Steam Learn: Asynchronous Javascript

Recently uploaded (20)

PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
PDF
Complete Guide to Website Development in Malaysia for SMEs
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PDF
Download FL Studio Crack Latest version 2025 ?
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Patient Appointment Booking in Odoo with online payment
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
Salesforce Agentforce AI Implementation.pdf
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
Website Design Services for Small Businesses.pdf
PPTX
history of c programming in notes for students .pptx
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
Digital Systems & Binary Numbers (comprehensive )
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Computer Software and OS of computer science of grade 11.pptx
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
Complete Guide to Website Development in Malaysia for SMEs
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
Download FL Studio Crack Latest version 2025 ?
Design an Analysis of Algorithms I-SECS-1021-03
Odoo Companies in India – Driving Business Transformation.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Patient Appointment Booking in Odoo with online payment
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Advanced SystemCare Ultimate Crack + Portable (2025)
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Autodesk AutoCAD Crack Free Download 2025
Salesforce Agentforce AI Implementation.pdf
Why Generative AI is the Future of Content, Code & Creativity?
Website Design Services for Small Businesses.pdf
history of c programming in notes for students .pptx
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...

Steam Learn: Zen SQL

  • 1. 8th of October 2014 Zen SQL Best practices to query and database design by Clément Prévost
  • 2. 8th of October 2014 The Zen way to SQL ● State of the art ● Readability best practices: a. Database schema b. Query
  • 3. 8th of October 2014 State of the art ● ORM (Doctrine, ActiveRecord, ...) ○ Hides the database schema and queries, follow your applicative coding best practices ● Query Builder (ZendDbSql, …) ○ Hides the queries, not the schema ● Raw (Migration scripts, performance critical task, Analytics) ○ DIY
  • 4. 8th of October 2014 The Zen way to SQL ● State of the art ● Readability best practices: a. Database schema b. Query
  • 5. a) Database schema best practices 8th of October 2014 A. KISS ○ Beware of overengineering ○ Don’t let optimizations get in the way of simplicity B. Explicitness is the key ○ Ban abbreviations, “status” column and add comments C. Your business WILL evolve, same with your schema ○ Never be afraid to refactor, rename and move stuff around
  • 6. 8th of October 2014 Case study: Database schema BP
  • 7. 8th of October 2014 1 3 2 1 2 3 3
  • 8. 8th of October 2014 The Zen way to SQL ● State of the art ● Readability best practices: a. Database schema b. Query
  • 9. 8th of October 2014 b) Query best practices A. Comments and documentation, Avoid deep nesting, Reuse external libraries B. Know your enemy: Long vs. complex queries C. Tools: IDE, Database specificity, SQL capabilities
  • 13. 8th of October 2014 Key things to remember ● Work it step by step ○ Have a perfect schema, then work on beautiful queries ● Know your tools, learn advanced SQL ● You already know how ○ Good coding practices also apply to SQL (queries AND schema)
  • 14. 8th of October 2014 Questions ? For online questions, please leave a comment on the article.
  • 15. 8th of October 2014 Join the community ! (in Paris) Social networks : ● Follow us on Twitter : https://twitter.com/steamlearn ● Like us on Facebook : https://www.facebook.com/steamlearn SteamLearn is an Inovia initiative : inovia.fr You wish to be in the audience ? Contact us at learn@steamhouse.fr
  • 16. 8th of October 2014 Sources 1. http://www.slideshare.net/Samuel90/software-development-vs-software-maintenance 2. http://code.tutsplus.com/tutorials/top-15-best-practices-for-writing-super-readable-code--net- 8118 3. http://www.postgresql.org/docs/9.3/static/view-pg-available-extensions.html 4. http://postgres-bits.herokuapp.com/ 5. http://www.postgresql.org/docs/9.3/static/index.html